1#!/bin/bash 2 3set -e 4 5if [ ! -e "/openxpki/.git" ]; then 6 echo "Please mount a full checkout including the .git directory to /openxpki"; 7 exit 1; 8fi 9 10makerepo() { 11 12 if [ -z "$SOURCE" ]; then 13 SOURCE="deb http://packages.openxpki.org/v3/debian/ buster release" 14 fi 15 16 if [ -e "/signkey" ]; then 17 gpg --import --batch /signkey 18 else 19 echo "No signing key was found - skipping signature" 20 fi 21 22 CONFDIR="" 23 if [ ! -d "/repository/conf" ]; then 24 CONFDIR="--confdir /tmp/openxpki/build/debian/reprepro" 25 fi 26 find /packages /extra-packages -name "*.deb" | \ 27 xargs -L1 --no-run-if-empty reprepro $CONFDIR --basedir /repository includedeb buster; 28 29 # Add the apt config 30 echo $SOURCE > /repository/openxpki.list 31 gpg --export --armor > /repository/Release.key 32 33} 34 35fetchgit() { 36 37 cd /tmp 38 39 # code repo including git repo with a checkedout branch must be mounted at /openxpki 40 # we clone the currently checked out branch from the mountpoint to /tmp 41 mybranch=$(git -C /openxpki rev-parse --abbrev-ref HEAD) 42 git clone /openxpki --branch "$mybranch" --single-branch 43 cd openxpki 44 45 git submodule init 46 git submodule update --checkout 47 HEAD=`git -C config rev-parse HEAD | cut -c1-6` 48 sed -i -r "s/^commit:.*/commit: $HEAD/" config/config.d/system/version.yaml 49 50 # Now chdir to the debian package dir 51 cd package/debian 52 53} 54 55installdeps() { 56 find /deps -name "*.deb" | \ 57 xargs -L1 --no-run-if-empty dpkg --force-depends -i 58 apt-get install --fix-broken --yes 59} 60 61runtest() { 62 63 export OPENXPKI_TEST_PASSWORD=openxpki 64 cd /tmp 65 rm -rf /etc/openxpki/ 66 dpkg --force-depends -i /packages/*.deb 67 apt-get install --fix-broken --yes 68 69 /etc/init.d/mysql start 70 echo " 71 DROP database if exists openxpki; 72 CREATE database openxpki CHARSET utf8; 73 CREATE USER 'openxpki'@'localhost' IDENTIFIED BY 'openxpki'; 74 CREATE USER 'openxpki_session'@'localhost' IDENTIFIED BY 'mysecret'; 75 GRANT ALL ON openxpki.* TO 'openxpki'@'localhost'; 76 flush privileges;" | mysql -u root 77 78 zcat "/usr/share/doc/libopenxpki-perl/examples/schema-mariadb.sql.gz" | mysql -u root openxpki 79 80 /usr/bin/openxpkictl start 81 82 openssl req -batch -x509 -newkey rsa:2048 -days 300 -nodes -keyout vault.key -out vault.crt -subj "/CN=Vault" 83 openssl req -batch -x509 -newkey rsa:2048 -days 1050 -nodes -keyout signer.key -out signer.crt -subj "/CN=Test CA Signer" 84 mkdir -p /etc/openxpki/local/keys/ 85 openxpkiadm alias --file vault.crt --key vault.key --realm democa --token datasafe 86 openxpkiadm alias --file signer.crt --key signer.key --realm democa --token certsign 87 88 cd /tmp/openxpki/qatest/backend/webui 89 90 prove . 91} 92 93# no target, build openxpki base module 94if [ $# == 1 ] && [ "$1" == "repo" ]; then 95 makerepo 96else 97 test -d /deps && installdeps 98 test -d /tmp/openxpki/ || fetchgit 99 if [ $# == 1 ] && [ "$1" == "test" ]; then 100 runtest 101 exit 0 102 elif [ $# == 0 ]; then 103 make openxpki 104 # should be a list of make targets 105 else 106 for var in "$@"; do 107 make "$var" 108 done 109 fi 110 cp $(find deb -name "*.deb") /packages/ 111fi 112