Added automatic package generation, improved documentation.
All checks were successful
the build was successful

This commit is contained in:
tastytea 2018-12-26 06:30:05 +01:00
parent 9367ce7ce7
commit 84b97fdf9f
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
5 changed files with 140 additions and 37 deletions

View File

@ -19,7 +19,7 @@ pipeline:
- apt-get update -q
- apt-get install -qy -t xenial g++-5
- apt-get install -qy cmake pkg-config
- apt-get install -qy libcrypto++-dev libmagick++-dev
- apt-get install -qy libmagick++-dev
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
- make VERBOSE=1
@ -37,14 +37,24 @@ pipeline:
- rm /etc/apt/apt.conf.d/docker-clean
- apt-get update -q
- apt-get install -qy g++-6 cmake pkg-config
- apt-get install -qy libcrypto++-dev libmagick++-dev
- apt-get install -qy libmagick++-dev
- apt-get install -qy dpkg-dev d-shlibs rpm file wget
- gpg --no-tty --import /var/autosign_gpg.key
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
- make VERBOSE=1
- make install DESTDIR=install
- make package
- cmake -DWITH_DEB=ON ..
- make package
- cmake -DWITH_DEB=OFF -DWITH_RPM=ON ..
- make package
- gpg --verbose --detach-sign *.tar.gz
- gpg --verbose --detach-sign *.deb
- gpg --verbose --detach-sign *.rpm
volumes:
- /var/cache/debian-package-cache:/var/cache/apt/archives
- /home/tastytea/misc/autosign_gpg.key:/var/autosign_gpg.key
gcc7:
image: debian:stretch-slim
@ -66,7 +76,7 @@ pipeline:
- apt-get update -q
- apt-get install -qy -t xenial g++-7
- apt-get install -qy cmake pkg-config
- apt-get install -qy libcrypto++-dev libmagick++-dev
- apt-get install -qy libmagick++-dev
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
- make VERBOSE=1
@ -93,7 +103,7 @@ pipeline:
- apt-get update -q
- apt-get install -qy -t xenial g++-8
- apt-get install -qy cmake pkg-config
- apt-get install -qy libcrypto++-dev libmagick++-dev
- apt-get install -qy libmagick++-dev
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
- make VERBOSE=1
@ -116,7 +126,7 @@ pipeline:
- apt-get update -q
- apt-get install -qy -t stretch-backports clang-5.0
- apt-get install -qy cmake pkg-config
- apt-get install -qy libcrypto++-dev libmagick++-dev
- apt-get install -qy libmagick++-dev
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
- make VERBOSE=1
@ -139,13 +149,26 @@ pipeline:
- apt-get update -q
- apt-get install -qy -t stretch-backports clang-6.0
- apt-get install -qy cmake pkg-config
- apt-get install -qy libcrypto++-dev libmagick++-dev
- apt-get install -qy libmagick++-dev
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
- make VERBOSE=1
volumes:
- /var/cache/debian-package-cache:/var/cache/apt/archives
prepare_release:
image: debian:stretch-slim
pull: true
when:
event: tag
commands:
- cp -v build/identiconpp-${DRONE_TAG}_x86_64.tar.gz .
- cp -v build/identiconpp-${DRONE_TAG}_x86_64.tar.gz.sig .
- cp -v build/identiconpp_${DRONE_TAG}-0_amd64.deb .
- cp -v build/identiconpp_${DRONE_TAG}-0_amd64.deb.sig .
- cp -v build/identiconpp-${DRONE_TAG}-0.x86_64.rpm .
- cp -v build/identiconpp-${DRONE_TAG}-0.x86_64.rpm.sig .
gitea_release:
image: plugins/gitea-release
pull: true
@ -155,6 +178,15 @@ pipeline:
secrets: [ gitea_token ]
title: ${DRONE_TAG}
prerelease: true
files:
- libravatarserv-${DRONE_TAG}_x86_64.tar.gz
- libravatarserv-${DRONE_TAG}_x86_64.tar.gz.sig
- libravatarserv_${DRONE_TAG}-0_amd64.deb
- libravatarserv_${DRONE_TAG}-0_amd64.deb.sig
- libravatarserv-${DRONE_TAG}-0.x86_64.rpm
- libravatarserv-${DRONE_TAG}-0.x86_64.rpm.sig
checksum:
- sha512
notify:
image: drillster/drone-email

View File

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

View File

@ -1,22 +1,55 @@
**identiconpp** is a library to generate identicons. Written in C++.
There are currently 2 types of identicons supported. libravatar/sigil and
simple.
You get the images as `Magick::Image`. This allows you to make all kinds of
modifications.
## Features
* [x] Simple identicons
* [ ] libravatar/sigil identicons
## Usage
The HTML reference can be generated with build_doc.sh, if doxygen is installed.
It is also available at [doc.schlomp.space/identiconpp/]
(https://doc.schlomp.space/identiconpp/classIdenticonpp.html).
### Example
```C++
// Compile with g++ $(Magick++-config --cppflags --ldflags) -lidenticonpp
#include <identiconpp.hpp>
#include <Magick++/Image.h>
int main()
{
Identiconpp identicon(5, 5, Identiconpp::identicon_type::simple,
"ffffff88", { "800000ff" });
Magick::Image img;
img = identicon.generate("55502f40dc8b7c769880b10874abc9d0", 200);
img.write("identicon.png");
}
```
## Install
<!-- ### Gentoo
### Gentoo
Gentoo ebuilds are available via my
[repository](https://schlomp.space/tastytea/overlay). -->
[repository](https://schlomp.space/tastytea/overlay).
### Automatically generated packages
Binary packages are generated automatically for each
[release](https://schlomp.space/tastytea/libravatarserv/releases) in the
formats:
* deb
* rpm
* tar.gz
They are generated on Debian Stretch 64 bit and signed with my
[automatic signing key](https://tastytea.de/tastytea_autosign.asc).
### From source
@ -25,11 +58,10 @@ Gentoo ebuilds are available via my
* C++ compiler (tested: [gcc](https://gcc.gnu.org/) 5/6/7/8,
[clang](https://llvm.org/) 5/6)
* [cmake](https://cmake.org/) (at least 3.2)
* [crypto++](https://cryptopp.com) (tested: 7.0 / 5.6)
* [imagemagick](https://www.imagemagick.org/) (tested: 7.0 / 6.7)
On a Debian system, install the packages: `build-essential cmake libcrypto++-dev
libmagick++-dev`.
On a Debian system, install the packages:
`build-essential cmake libmagick++-dev`.
#### Compile
@ -44,6 +76,11 @@ make install
##### cmake options
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build
* One of:
* `-DWITH_DEB=YES` to generate a deb-package
* `-DWITH_RPM=YES` to generate an rpm-package
To generate a binary package, execute `make package`
## Contributing

View File

@ -5,6 +5,7 @@
#include <iostream>
#include <string>
#include "identiconpp.hpp"
#include <Magick++/Image.h>
using std::cout;
using std::endl;
@ -12,15 +13,16 @@ using std::string;
int main(int argc, char *argv[])
{
string algorithm = "simple";
string digest =
"973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b";
Magick::Image img;
if (argc > 1)
{
algorithm = argv[1];
digest = argv[1];
}
if (algorithm == "simple")
{
cout << "You selected the \"simple\" algorithm.\n";
Identiconpp identicon(13, 10, Identiconpp::identicon_type::simple,
"ffffff88",
{
@ -31,20 +33,11 @@ int main(int argc, char *argv[])
"00ffffff",
"0000ffff"
});
Magick::Image img;
img = identicon.generate("55502f40dc8b7c769880b10874abc9d0");
img.write("identicon_example_simple1.png");
img = identicon.generate
(
"973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b",
500
);
img.write("identicon_example_simple2.png");
img = identicon.generate(digest, 500);
img.write("identicon_example_simple.png");
}
else if (algorithm == "libravatar")
{
cout << "You selected the \"libravatar\" algorithm.\n";
Identiconpp identicon(10, 10, Identiconpp::identicon_type::libravatar,
"ffffffff",
{
@ -55,15 +48,9 @@ int main(int argc, char *argv[])
"00ffffff",
"0000ffff"
});
Magick::Image img;
img = identicon.generate("55502f40dc8b7c769880b10874abc9d0");
img = identicon.generate(digest, 500);
img.write("identicon_example_libravatar.png");
}
else
{
cout << "The algorithm \"" << algorithm << "\" is not known.\n";
return 1;
}
return 0;
}

45
packages.CMakeLists.txt Normal file
View File

@ -0,0 +1,45 @@
# Packages
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${${CMAKE_PROJECT_NAME}_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${${CMAKE_PROJECT_NAME}_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${${CMAKE_PROJECT_NAME}_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${${CMAKE_PROJECT_NAME}_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library to generate identicons. Written in C++.")
set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git"
"/.gitignore"
"/build/"
"/doc/"
"\\\\.sublime-"
"/.drone.yml")
execute_process(COMMAND uname -m
OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_ARCHITECTURE}")
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
if (WITH_DEB)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://schlomp.space/tastytea/${CMAKE_PROJECT_NAME}")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
endif()
if (WITH_RPM)
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_LICENSE "GPL-3")
set(CPACK_RPM_PACKAGE_URL "https://schlomp.space/tastytea/${CMAKE_PROJECT_NAME}")
set(CPACK_RPM_PACKAGE_REQUIRES "libMagick++, libxdg-basedir >= 1.2.0")
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}")
endif()
include(CPack)