Browse Source

Added automatic package generation, improved documentation.

tags/0.1.2
tastytea 6 months ago
parent
commit
84b97fdf9f
Signed by: tastytea <tastytea@tastytea.de> GPG Key ID: CFC39497F1B26E07
5 changed files with 140 additions and 37 deletions
  1. 38
    6
      .drone.yml
  2. 2
    0
      CMakeLists.txt
  3. 44
    7
      README.md
  4. 11
    24
      example.cpp
  5. 45
    0
      packages.CMakeLists.txt

+ 38
- 6
.drone.yml View File

@@ -19,7 +19,7 @@ pipeline:
19 19
       - apt-get update -q
20 20
       - apt-get install -qy -t xenial g++-5
21 21
       - apt-get install -qy cmake pkg-config
22
-      - apt-get install -qy libcrypto++-dev libmagick++-dev
22
+      - apt-get install -qy libmagick++-dev
23 23
       - rm -rf build && mkdir -p build && cd build
24 24
       - cmake -DCMAKE_INSTALL_PREFIX=/usr ..
25 25
       - make VERBOSE=1
@@ -37,14 +37,24 @@ pipeline:
37 37
       - rm /etc/apt/apt.conf.d/docker-clean
38 38
       - apt-get update -q
39 39
       - apt-get install -qy g++-6 cmake pkg-config
40
-      - apt-get install -qy libcrypto++-dev libmagick++-dev
40
+      - apt-get install -qy libmagick++-dev
41 41
       - apt-get install -qy dpkg-dev d-shlibs rpm file wget
42
+      - gpg --no-tty --import /var/autosign_gpg.key
42 43
       - rm -rf build && mkdir -p build && cd build
43 44
       - cmake -DCMAKE_INSTALL_PREFIX=/usr ..
44 45
       - make VERBOSE=1
45 46
       - make install DESTDIR=install
47
+      - make package
48
+      - cmake -DWITH_DEB=ON ..
49
+      - make package
50
+      - cmake -DWITH_DEB=OFF -DWITH_RPM=ON ..
51
+      - make package
52
+      - gpg --verbose --detach-sign *.tar.gz
53
+      - gpg --verbose --detach-sign *.deb
54
+      - gpg --verbose --detach-sign *.rpm
46 55
     volumes:
47 56
       - /var/cache/debian-package-cache:/var/cache/apt/archives
57
+      - /home/tastytea/misc/autosign_gpg.key:/var/autosign_gpg.key
48 58
 
49 59
   gcc7:
50 60
     image: debian:stretch-slim
@@ -66,7 +76,7 @@ pipeline:
66 76
       - apt-get update -q
67 77
       - apt-get install -qy -t xenial g++-7
68 78
       - apt-get install -qy cmake pkg-config
69
-      - apt-get install -qy libcrypto++-dev libmagick++-dev
79
+      - apt-get install -qy libmagick++-dev
70 80
       - rm -rf build && mkdir -p build && cd build
71 81
       - cmake -DCMAKE_INSTALL_PREFIX=/usr ..
72 82
       - make VERBOSE=1
@@ -93,7 +103,7 @@ pipeline:
93 103
       - apt-get update -q
94 104
       - apt-get install -qy -t xenial g++-8
95 105
       - apt-get install -qy cmake pkg-config
96
-      - apt-get install -qy libcrypto++-dev libmagick++-dev
106
+      - apt-get install -qy libmagick++-dev
97 107
       - rm -rf build && mkdir -p build && cd build
98 108
       - cmake -DCMAKE_INSTALL_PREFIX=/usr ..
99 109
       - make VERBOSE=1
@@ -116,7 +126,7 @@ pipeline:
116 126
       - apt-get update -q
117 127
       - apt-get install -qy -t stretch-backports clang-5.0
118 128
       - apt-get install -qy cmake pkg-config
119
-      - apt-get install -qy libcrypto++-dev libmagick++-dev
129
+      - apt-get install -qy libmagick++-dev
120 130
       - rm -rf build && mkdir -p build && cd build
121 131
       - cmake -DCMAKE_INSTALL_PREFIX=/usr ..
122 132
       - make VERBOSE=1
@@ -139,13 +149,26 @@ pipeline:
139 149
       - apt-get update -q
140 150
       - apt-get install -qy -t stretch-backports clang-6.0
141 151
       - apt-get install -qy cmake pkg-config
142
-      - apt-get install -qy libcrypto++-dev libmagick++-dev
152
+      - apt-get install -qy libmagick++-dev
143 153
       - rm -rf build && mkdir -p build && cd build
144 154
       - cmake -DCMAKE_INSTALL_PREFIX=/usr ..
145 155
       - make VERBOSE=1
146 156
     volumes:
147 157
       - /var/cache/debian-package-cache:/var/cache/apt/archives
148 158
 
159
+  prepare_release:
160
+    image: debian:stretch-slim
161
+    pull: true
162
+    when:
163
+      event: tag
164
+    commands:
165
+      - cp -v build/identiconpp-${DRONE_TAG}_x86_64.tar.gz .
166
+      - cp -v build/identiconpp-${DRONE_TAG}_x86_64.tar.gz.sig .
167
+      - cp -v build/identiconpp_${DRONE_TAG}-0_amd64.deb .
168
+      - cp -v build/identiconpp_${DRONE_TAG}-0_amd64.deb.sig .
169
+      - cp -v build/identiconpp-${DRONE_TAG}-0.x86_64.rpm .
170
+      - cp -v build/identiconpp-${DRONE_TAG}-0.x86_64.rpm.sig .
171
+
149 172
   gitea_release:
150 173
     image: plugins/gitea-release
151 174
     pull: true
@@ -155,6 +178,15 @@ pipeline:
155 178
     secrets: [ gitea_token ]
156 179
     title: ${DRONE_TAG}
157 180
     prerelease: true
181
+    files:
182
+      - libravatarserv-${DRONE_TAG}_x86_64.tar.gz
183
+      - libravatarserv-${DRONE_TAG}_x86_64.tar.gz.sig
184
+      - libravatarserv_${DRONE_TAG}-0_amd64.deb
185
+      - libravatarserv_${DRONE_TAG}-0_amd64.deb.sig
186
+      - libravatarserv-${DRONE_TAG}-0.x86_64.rpm
187
+      - libravatarserv-${DRONE_TAG}-0.x86_64.rpm.sig
188
+    checksum:
189
+      - sha512
158 190
 
159 191
   notify:
160 192
     image: drillster/drone-email

+ 2
- 0
CMakeLists.txt View File

@@ -39,3 +39,5 @@ target_link_libraries(example ${CMAKE_PROJECT_NAME})
39 39
 install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
40 40
 install(FILES src/${CMAKE_PROJECT_NAME}.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
41 41
 install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
42
+
43
+include(packages.CMakeLists.txt)

+ 44
- 7
README.md View File

@@ -1,22 +1,55 @@
1 1
 **identiconpp** is a library to generate identicons. Written in C++.
2 2
 
3
-There are currently 2 types of identicons supported. libravatar/sigil and
4
-simple.
3
+You get the images as `Magick::Image`. This allows you to make all kinds of
4
+modifications.
5 5
 
6 6
 ## Features
7 7
 
8
+* [x] Simple identicons
9
+* [ ] libravatar/sigil identicons
10
+
8 11
 ## Usage
9 12
 
10 13
 The HTML reference can be generated with build_doc.sh, if doxygen is installed.
11 14
 It is also available at [doc.schlomp.space/identiconpp/]
12 15
 (https://doc.schlomp.space/identiconpp/classIdenticonpp.html).
13 16
 
17
+### Example
18
+
19
+```C++
20
+// Compile with g++ $(Magick++-config --cppflags --ldflags) -lidenticonpp
21
+#include <identiconpp.hpp>
22
+#include <Magick++/Image.h>
23
+
24
+int main()
25
+{
26
+    Identiconpp identicon(5, 5, Identiconpp::identicon_type::simple,
27
+                          "ffffff88", { "800000ff" });
28
+    Magick::Image img;
29
+    img = identicon.generate("55502f40dc8b7c769880b10874abc9d0", 200);
30
+    img.write("identicon.png");
31
+}
32
+```
33
+
14 34
 ## Install
15 35
 
16
-<!-- ### Gentoo
36
+### Gentoo
17 37
 
18 38
 Gentoo ebuilds are available via my
19
-[repository](https://schlomp.space/tastytea/overlay). -->
39
+[repository](https://schlomp.space/tastytea/overlay).
40
+
41
+### Automatically generated packages
42
+
43
+Binary packages are generated automatically for each
44
+[release](https://schlomp.space/tastytea/libravatarserv/releases) in the
45
+formats:
46
+
47
+* deb
48
+* rpm
49
+* tar.gz
50
+
51
+They are generated on Debian Stretch 64 bit and signed with my
52
+[automatic signing key](https://tastytea.de/tastytea_autosign.asc).
20 53
 
21 54
 ### From source
22 55
 
@@ -25,11 +58,10 @@ Gentoo ebuilds are available via my
25 58
 * C++ compiler (tested: [gcc](https://gcc.gnu.org/) 5/6/7/8,
26 59
   [clang](https://llvm.org/) 5/6)
27 60
 * [cmake](https://cmake.org/) (at least 3.2)
28
-* [crypto++](https://cryptopp.com) (tested: 7.0 / 5.6)
29 61
 * [imagemagick](https://www.imagemagick.org/) (tested: 7.0 / 6.7)
30 62
 
31
-On a Debian system, install the packages: `build-essential cmake libcrypto++-dev
32
-libmagick++-dev`.
63
+On a Debian system, install the packages:
64
+`build-essential cmake libmagick++-dev`.
33 65
 
34 66
 #### Compile
35 67
 
@@ -44,6 +76,11 @@ make install
44 76
 ##### cmake options
45 77
 
46 78
 * `-DCMAKE_BUILD_TYPE=Debug` for a debug build
79
+* One of:
80
+    * `-DWITH_DEB=YES` to generate a deb-package
81
+    * `-DWITH_RPM=YES` to generate an rpm-package
82
+
83
+To generate a binary package, execute `make package`
47 84
 
48 85
 ## Contributing
49 86
 

+ 11
- 24
example.cpp View File

@@ -5,6 +5,7 @@
5 5
 #include <iostream>
6 6
 #include <string>
7 7
 #include "identiconpp.hpp"
8
+#include <Magick++/Image.h>
8 9
 
9 10
 using std::cout;
10 11
 using std::endl;
@@ -12,15 +13,16 @@ using std::string;
12 13
 
13 14
 int main(int argc, char *argv[])
14 15
 {
15
-    string algorithm = "simple";
16
+    string digest =
17
+        "973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b";
18
+    Magick::Image img;
19
+
16 20
     if (argc > 1)
17 21
     {
18
-        algorithm = argv[1];
22
+        digest = argv[1];
19 23
     }
20 24
 
21
-    if (algorithm == "simple")
22 25
     {
23
-        cout << "You selected the \"simple\" algorithm.\n";
24 26
         Identiconpp identicon(13, 10, Identiconpp::identicon_type::simple,
25 27
             "ffffff88",
26 28
             { 
@@ -31,20 +33,11 @@ int main(int argc, char *argv[])
31 33
                 "00ffffff",
32 34
                 "0000ffff"
33 35
             });
34
-
35
-        Magick::Image img;
36
-        img = identicon.generate("55502f40dc8b7c769880b10874abc9d0");
37
-        img.write("identicon_example_simple1.png");
38
-        img = identicon.generate
39
-        (
40
-            "973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b",
41
-            500
42
-        );
43
-        img.write("identicon_example_simple2.png");
36
+        img = identicon.generate(digest, 500);
37
+        img.write("identicon_example_simple.png");
44 38
     }
45
-    else if (algorithm == "libravatar")
39
+
46 40
     {
47
-        cout << "You selected the \"libravatar\" algorithm.\n";
48 41
         Identiconpp identicon(10, 10, Identiconpp::identicon_type::libravatar,
49 42
             "ffffffff",
50 43
             {
@@ -55,15 +48,9 @@ int main(int argc, char *argv[])
55 48
                 "00ffffff",
56 49
                 "0000ffff"
57 50
             });
58
-
59
-        Magick::Image img;
60
-        img = identicon.generate("55502f40dc8b7c769880b10874abc9d0");
51
+        img = identicon.generate(digest, 500);
61 52
         img.write("identicon_example_libravatar.png");
62 53
     }
63
-    else
64
-    {
65
-        cout << "The algorithm \"" << algorithm << "\" is not known.\n";
66
-        return 1;
67
-    }
54
+
68 55
     return 0;
69 56
 }

+ 45
- 0
packages.CMakeLists.txt View File

@@ -0,0 +1,45 @@
1
+# Packages
2
+set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
3
+set(CPACK_PACKAGE_VERSION_MAJOR ${${CMAKE_PROJECT_NAME}_VERSION_MAJOR})
4
+set(CPACK_PACKAGE_VERSION_MINOR ${${CMAKE_PROJECT_NAME}_VERSION_MINOR})
5
+set(CPACK_PACKAGE_VERSION_PATCH ${${CMAKE_PROJECT_NAME}_VERSION_PATCH})
6
+set(CPACK_PACKAGE_VERSION ${${CMAKE_PROJECT_NAME}_VERSION})
7
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library to generate identicons. Written in C++.")
8
+set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
9
+set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
10
+set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
11
+list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git"
12
+                                      "/.gitignore"
13
+                                      "/build/"
14
+                                      "/doc/"
15
+                                      "\\\\.sublime-"
16
+                                      "/.drone.yml")
17
+execute_process(COMMAND uname -m
18
+                OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
19
+                OUTPUT_STRIP_TRAILING_WHITESPACE)
20
+set(CPACK_PACKAGE_FILE_NAME
21
+    "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_ARCHITECTURE}")
22
+set(CPACK_GENERATOR "TGZ")
23
+set(CPACK_SOURCE_GENERATOR "TGZ")
24
+
25
+if (WITH_DEB)
26
+    set(CPACK_GENERATOR "DEB")
27
+    set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://schlomp.space/tastytea/${CMAKE_PROJECT_NAME}")
28
+    set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
29
+    execute_process(COMMAND dpkg --print-architecture
30
+                    OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
31
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
32
+    set(CPACK_PACKAGE_FILE_NAME
33
+        "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
34
+endif()
35
+
36
+if (WITH_RPM)
37
+    set(CPACK_GENERATOR "RPM")
38
+    set(CPACK_RPM_PACKAGE_LICENSE "GPL-3")
39
+    set(CPACK_RPM_PACKAGE_URL "https://schlomp.space/tastytea/${CMAKE_PROJECT_NAME}")
40
+    set(CPACK_RPM_PACKAGE_REQUIRES "libMagick++, libxdg-basedir >= 1.2.0")
41
+    set(CPACK_PACKAGE_FILE_NAME
42
+         "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}")
43
+endif()
44
+
45
+include(CPack)

Loading…
Cancel
Save