From f646904d4098b87193f4f59b16aa45642e3fa786 Mon Sep 17 00:00:00 2001 From: "alexandr.kravchenko" <alexander.kravchenko@demlabs.net> Date: Sun, 12 Apr 2020 10:07:57 +0000 Subject: [PATCH] Support 3325 --- .gitlab-ci.yml | 13 ++ CMakeLists.txt | 7 +- debian | 1 + prod_build/android/conf/environment | 7 + prod_build/android/conf/project_props | 3 + prod_build/android/conf/publish | 2 + prod_build/android/conf/version_info | 3 + prod_build/android/scripts/compile.sh | 0 prod_build/android/scripts/deploy.sh | 0 prod_build/android/scripts/pack.sh | 0 prod_build/android/scripts/pre-build.sh | 0 prod_build/android/scripts/test.sh | 0 prod_build/general/chroot_wrap.sh | 52 +++++++ prod_build/general/conf/status | 1 + prod_build/general/conf/version_info | 3 + prod_build/general/pre-build.sh | 42 ++++++ prod_build/ios/scripts/compile.sh | 0 prod_build/ios/scripts/deploy.sh | 0 prod_build/ios/scripts/pack.sh | 0 prod_build/ios/scripts/pre-build.sh | 0 prod_build/ios/scripts/test.sh | 0 prod_build/linux/debian/conf/dependencies | 1 + prod_build/linux/debian/conf/publish | 8 ++ .../linux/debian/essentials}/config | 0 .../linux/debian/essentials}/postinst | 0 .../linux/debian/essentials}/postrm | 0 .../linux/debian/essentials}/rules | 0 .../linux/debian/essentials}/templates | 0 prod_build/linux/debian/scripts/build.sh | 11 ++ .../linux/debian/scripts/chroot/post-build.sh | 0 .../linux/debian/scripts/chroot/pre-build.sh | 45 ++++++ prod_build/linux/debian/scripts/cleanup.sh | 5 + .../linux/debian/scripts/compile_and_pack.sh | 76 ++++++++++ prod_build/linux/debian/scripts/deploy.sh | 42 ++++++ .../linux/debian/scripts/install_test.sh | 3 + prod_build/linux/debian/scripts/pack.sh | 0 prod_build/linux/debian/scripts/post-build.sh | 8 ++ prod_build/linux/debian/scripts/pre-build.sh | 133 ++++++++++++++++++ .../debian/scripts/publish_remote/reprepro.sh | 16 +++ prod_build/linux/debian/scripts/test.sh | 4 + prod_build/linux/ubuntu/conf/dependencies | 1 + prod_build/linux/ubuntu/conf/publish | 8 ++ prod_build/linux/ubuntu/essentials | 1 + prod_build/linux/ubuntu/scripts/build.sh | 1 + prod_build/linux/ubuntu/scripts/chroot | 1 + prod_build/linux/ubuntu/scripts/cleanup.sh | 1 + .../linux/ubuntu/scripts/compile_and_pack.sh | 1 + prod_build/linux/ubuntu/scripts/deploy.sh | 1 + .../linux/ubuntu/scripts/install_test.sh | 1 + prod_build/linux/ubuntu/scripts/pack.sh | 1 + prod_build/linux/ubuntu/scripts/post-build.sh | 1 + prod_build/linux/ubuntu/scripts/pre-build.sh | 132 +++++++++++++++++ prod_build/linux/ubuntu/scripts/test.sh | 1 + prod_build/mac/scripts/compile.sh | 0 prod_build/mac/scripts/deploy.sh | 0 prod_build/mac/scripts/pack.sh | 0 prod_build/mac/scripts/pre-build.sh | 0 prod_build/mac/scripts/test.sh | 0 prod_build/windows/scripts/compile.sh | 0 prod_build/windows/scripts/deploy.sh | 0 prod_build/windows/scripts/pack.sh | 0 prod_build/windows/scripts/pre-build.sh | 0 prod_build/windows/scripts/test.sh | 0 scripts/.gitkeep | 0 64 files changed, 636 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml create mode 120000 debian create mode 100644 prod_build/android/conf/environment create mode 100644 prod_build/android/conf/project_props create mode 100644 prod_build/android/conf/publish create mode 100644 prod_build/android/conf/version_info create mode 100755 prod_build/android/scripts/compile.sh create mode 100755 prod_build/android/scripts/deploy.sh create mode 100755 prod_build/android/scripts/pack.sh create mode 100755 prod_build/android/scripts/pre-build.sh create mode 100755 prod_build/android/scripts/test.sh create mode 100755 prod_build/general/chroot_wrap.sh create mode 100644 prod_build/general/conf/status create mode 100644 prod_build/general/conf/version_info create mode 100755 prod_build/general/pre-build.sh create mode 100755 prod_build/ios/scripts/compile.sh create mode 100755 prod_build/ios/scripts/deploy.sh create mode 100755 prod_build/ios/scripts/pack.sh create mode 100755 prod_build/ios/scripts/pre-build.sh create mode 100755 prod_build/ios/scripts/test.sh create mode 100644 prod_build/linux/debian/conf/dependencies create mode 100644 prod_build/linux/debian/conf/publish rename {debian => prod_build/linux/debian/essentials}/config (100%) rename {debian => prod_build/linux/debian/essentials}/postinst (100%) rename {debian => prod_build/linux/debian/essentials}/postrm (100%) rename {debian => prod_build/linux/debian/essentials}/rules (100%) rename {debian => prod_build/linux/debian/essentials}/templates (100%) create mode 100755 prod_build/linux/debian/scripts/build.sh create mode 100755 prod_build/linux/debian/scripts/chroot/post-build.sh create mode 100755 prod_build/linux/debian/scripts/chroot/pre-build.sh create mode 100755 prod_build/linux/debian/scripts/cleanup.sh create mode 100755 prod_build/linux/debian/scripts/compile_and_pack.sh create mode 100755 prod_build/linux/debian/scripts/deploy.sh create mode 100755 prod_build/linux/debian/scripts/install_test.sh create mode 100755 prod_build/linux/debian/scripts/pack.sh create mode 100755 prod_build/linux/debian/scripts/post-build.sh create mode 100755 prod_build/linux/debian/scripts/pre-build.sh create mode 100644 prod_build/linux/debian/scripts/publish_remote/reprepro.sh create mode 100755 prod_build/linux/debian/scripts/test.sh create mode 100644 prod_build/linux/ubuntu/conf/dependencies create mode 100644 prod_build/linux/ubuntu/conf/publish create mode 120000 prod_build/linux/ubuntu/essentials create mode 120000 prod_build/linux/ubuntu/scripts/build.sh create mode 120000 prod_build/linux/ubuntu/scripts/chroot create mode 120000 prod_build/linux/ubuntu/scripts/cleanup.sh create mode 120000 prod_build/linux/ubuntu/scripts/compile_and_pack.sh create mode 120000 prod_build/linux/ubuntu/scripts/deploy.sh create mode 120000 prod_build/linux/ubuntu/scripts/install_test.sh create mode 120000 prod_build/linux/ubuntu/scripts/pack.sh create mode 120000 prod_build/linux/ubuntu/scripts/post-build.sh create mode 100755 prod_build/linux/ubuntu/scripts/pre-build.sh create mode 120000 prod_build/linux/ubuntu/scripts/test.sh create mode 100755 prod_build/mac/scripts/compile.sh create mode 100755 prod_build/mac/scripts/deploy.sh create mode 100755 prod_build/mac/scripts/pack.sh create mode 100755 prod_build/mac/scripts/pre-build.sh create mode 100755 prod_build/mac/scripts/test.sh create mode 100755 prod_build/windows/scripts/compile.sh create mode 100755 prod_build/windows/scripts/deploy.sh create mode 100755 prod_build/windows/scripts/pack.sh create mode 100755 prod_build/windows/scripts/pre-build.sh create mode 100755 prod_build/windows/scripts/test.sh create mode 100644 scripts/.gitkeep diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e1757db --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,13 @@ +stages: + - prepare + - build + - test + +variables: + GIT_SUBMODULE_STRATEGY: normal + +dapcash-node-schedule: + stage: build + tags: + - dapcash-node + script: ~/production/integration/gitlab-CI/build_all_handler.sh dapcash-node diff --git a/CMakeLists.txt b/CMakeLists.txt index e88b090..0fac5ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,12 @@ if (LINUX) SET( CPACK_PACKAGE_VERSION_MINOR 1) SET( CPACK_PACKAGE_VERSION_PATCH 8) - SET( CPACK_SYSTEM_NAME "debian-${DEBIAN_OS_NAME}-amd64") + SET( CPACK_SYSTEM_TYPE "Debian") + SET( CPACK_SYSTEM_VERSION "9.11") + SET( CPACK_SYSTEM_ARCH "amd64") + SET( CPACK_SYSTEM_CODENAME "stretch") + + SET( CPACK_SYSTEM_NAME "${CPACK_SYSTEM_TYPE}-${CPACK_SYSTEM_CODENAME}-${CPACK_SYSTEM_ARCH}") SET( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}") SET( CPACK_DEBIAN_PACKAGE_MAINTAINER "Dmitriy Gerasimov <naeper@demlabs.net>" ) SET( CPACK_DEBIAN_PACKAGE_DESCRIPTION_SUMMARY "DapCash Node software https://dapcash.org" ) diff --git a/debian b/debian new file mode 120000 index 0000000..5992d38 --- /dev/null +++ b/debian @@ -0,0 +1 @@ +prod_build/linux/debian/essentials/ \ No newline at end of file diff --git a/prod_build/android/conf/environment b/prod_build/android/conf/environment new file mode 100644 index 0000000..5099a4a --- /dev/null +++ b/prod_build/android/conf/environment @@ -0,0 +1,7 @@ +ANDROID_NDK_HOME="/opt/android-ndk-r16b" +SDKROOT="/opt/android-sdk/bin" +NDKHOST="linux-x86_64" +JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" +ANDRQT_HOME="/usr/lib/crossdev" +HOST_DISTR_VERSIONS="stretch" +HOST_ARCH_VERSIONS="amd64" diff --git a/prod_build/android/conf/project_props b/prod_build/android/conf/project_props new file mode 100644 index 0000000..d1d7d50 --- /dev/null +++ b/prod_build/android/conf/project_props @@ -0,0 +1,3 @@ +RES_PATH=SapNetGui/resources/UltraPad/platforms/android +WORK_PATH=../sapnet-client-build +BRAND=UltraPad diff --git a/prod_build/android/conf/publish b/prod_build/android/conf/publish new file mode 100644 index 0000000..896aa10 --- /dev/null +++ b/prod_build/android/conf/publish @@ -0,0 +1,2 @@ +ARCH_VERSIONS="arm64-v8a armv7 x86 x86_64 arm" +PACKAGE_PATH=builds/apk/ diff --git a/prod_build/android/conf/version_info b/prod_build/android/conf/version_info new file mode 100644 index 0000000..288cd5c --- /dev/null +++ b/prod_build/android/conf/version_info @@ -0,0 +1,3 @@ +VERSION_FILE=config.pri +VERSION_ENTRIES="VER_MAJ VER_MIN VER_PAT VER_CODE" +VERSION_FORMAT="VER_MAJ.VER_MIN-VER_PAT" diff --git a/prod_build/android/scripts/compile.sh b/prod_build/android/scripts/compile.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/android/scripts/deploy.sh b/prod_build/android/scripts/deploy.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/android/scripts/pack.sh b/prod_build/android/scripts/pack.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/android/scripts/pre-build.sh b/prod_build/android/scripts/pre-build.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/android/scripts/test.sh b/prod_build/android/scripts/test.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/general/chroot_wrap.sh b/prod_build/general/chroot_wrap.sh new file mode 100755 index 0000000..206375b --- /dev/null +++ b/prod_build/general/chroot_wrap.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +PLATFORM_CANDIDATES=$2 +CHROOT_PREFIX="builder" +CHROOTS_PATH=$1 +PLATFORMS="" +PKG_FORMAT=$3 +SRC_PATH=$4 +JOB=$5 + +cd $SRC_PATH +echo "workdir is $(pwd)" +. prod_build/general/pre-build.sh +export_variables "./prod_build/general/conf/*" + +IFS=' ' +echo "$PLATFORM_CANDIDATES" +echo $IMPLEMENTED +for platform in $PLATFORM_CANDIDATES; do + [[ $(echo $IMPLEMENTED | grep $platform) != "" ]] && PLATFORMS="$PLATFORMS$platform " || echo "Platform $platform is not implemented in this project yet. Sorry" +done +echo "Platforms are $PLATFORMS" + +for platform in $PLATFORMS; do + echo "Working with $platform now" + export_variables "./prod_build/$platform/conf/*" + IFS=' ' + PKG_TYPE=$(echo $PKG_FORMAT | cut -d ' ' -f1) + #Check if chroots are present + echo $HOST_DISTR_VERSIONS + echo $HOST_ARCH_VERSIONS + [ -e prod_build/$platform/scripts/pre-build.sh ] && prod_build/$platform/scripts/pre-build.sh $CHROOT_PREFIX || exit $? #For actions before build not in chroot and in chroot (version update, install missing dependencies(under schroot)) + for distr in $HOST_DISTR_VERSIONS; do + for arch in $HOST_ARCH_VERSIONS; do + if [ -e $CHROOTS_PATH/$CHROOT_PREFIX-$distr-$arch ]; then + schroot -c $CHROOT_PREFIX-$distr-$arch -- launcher.sh prod_build/$platform/scripts/$JOB.sh $PKG_TYPE || { errcode=$? && unexport_variables "./prod_build/$platform/conf/*"; exit $errcode; } +# echo "schroot stub $PKG_TYPE" + else + echo "chroot $CHROOT_PREFIX-$distr-$arch not found. You should install it first" + fi + done + done + echo "workdir before postinstall is $(pwd)" + [ -e prod_build/$platform/scripts/post-build.sh ] && prod_build/$platform/scripts/post-build.sh errcode=$? #For post-build actions not in chroot (global publish) + PKG_FORMAT=$(echo $PKG_FORMAT | cut -d ' ' -f2-) + unexport_variables "./prod_build/$platform/conf/*" +done +#[ $(mount | grep "/run/schroot/mount") ] && sudo umount -l /run/schroot/mount && sudo rm -r /run/schroot/mount/* #Removing mountpoint odds. + +cd $wd + +exit $errcode diff --git a/prod_build/general/conf/status b/prod_build/general/conf/status new file mode 100644 index 0000000..5082e1d --- /dev/null +++ b/prod_build/general/conf/status @@ -0,0 +1 @@ +IMPLEMENTED="linux/debian linux/ubuntu" diff --git a/prod_build/general/conf/version_info b/prod_build/general/conf/version_info new file mode 100644 index 0000000..d33ee15 --- /dev/null +++ b/prod_build/general/conf/version_info @@ -0,0 +1,3 @@ +VERSION_FILE=CMakeLists.txt +VERSION_ENTRIES="CPACK_PACKAGE_VERSION_MAJOR CPACK_PACKAGE_VERSION_MINOR CPACK_PACKAGE_VERSION_PATCH" +VERSION_FORMAT="CPACK_PACKAGE_VERSION_MAJOR.CPACK_PACKAGE_VERSION_MINOR-CPACK_PACKAGE_VERSION_PATCH" diff --git a/prod_build/general/pre-build.sh b/prod_build/general/pre-build.sh new file mode 100755 index 0000000..b37204e --- /dev/null +++ b/prod_build/general/pre-build.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +extract_version_number() { + +IFS=" " +local VERSION_STRING=$VERSION_FORMAT +for entry in $VERSION_ENTRIES; do + VERSION_STRING=$(echo $VERSION_STRING | sed "s/$entry/$( cat $VERSION_FILE | grep $entry | grep [0-9] | rev | cut -d ' ' -f1 | cut -d ")" -f2 | rev )/") #Replacing templates with numbers +done +echo -e "$VERSION_STRING" + +} + +extract_gitlog_text() { + +borders=$( git log | grep -n 'commit\|Date' | head -n 3 | tail -n 2 | cut -d ':' -f1) +upb=$(echo $borders | cut -d $'\n' -f1) +dwnb=$(echo $borders | cut -d $'\n' -f2) +text=$(git log | head -n $( expr $dwnb - 2 ) | tail -n $( expr $dwnb - $upb - 3 ) ) +echo $text + +} + +export_variables() { + +IFS=$'\n' +for variable in $(cat $1); do + echo "$variable" + export $(echo "$variable" | sed 's/\"//g') +done + +} + +unexport_variables() { + +IFS=$'\n' +for variable in $(cat $1); do + echo "$variable" + export -n $(echo $variable | cut -d '=' -f1) +done + +} diff --git a/prod_build/ios/scripts/compile.sh b/prod_build/ios/scripts/compile.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/ios/scripts/deploy.sh b/prod_build/ios/scripts/deploy.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/ios/scripts/pack.sh b/prod_build/ios/scripts/pack.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/ios/scripts/pre-build.sh b/prod_build/ios/scripts/pre-build.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/ios/scripts/test.sh b/prod_build/ios/scripts/test.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/linux/debian/conf/dependencies b/prod_build/linux/debian/conf/dependencies new file mode 100644 index 0000000..dc39e29 --- /dev/null +++ b/prod_build/linux/debian/conf/dependencies @@ -0,0 +1 @@ +PKG_DEPS="libjson-c-dev libsqlite3-dev libmemcached-dev libev-dev libmagic-dev libcurl4-gnutls-dev libldb-dev libtalloc-dev libtevent-dev" diff --git a/prod_build/linux/debian/conf/publish b/prod_build/linux/debian/conf/publish new file mode 100644 index 0000000..93c64d6 --- /dev/null +++ b/prod_build/linux/debian/conf/publish @@ -0,0 +1,8 @@ +HOST_DISTR_VERSIONS="stretch buster" +HOST_ARCH_VERSIONS="amd64" +PACKAGE_PATH=builds/deb/ +REPO_DIR_SRC=/var/tmp/repository +DISTR_CODENAME="stretch buster" +REPO_ADDR=debian.pub.demlabs.net +REPO_DIR=/var/www/html/debian.pub.demlabs.net +DISTR_COMPONENT=main diff --git a/debian/config b/prod_build/linux/debian/essentials/config similarity index 100% rename from debian/config rename to prod_build/linux/debian/essentials/config diff --git a/debian/postinst b/prod_build/linux/debian/essentials/postinst similarity index 100% rename from debian/postinst rename to prod_build/linux/debian/essentials/postinst diff --git a/debian/postrm b/prod_build/linux/debian/essentials/postrm similarity index 100% rename from debian/postrm rename to prod_build/linux/debian/essentials/postrm diff --git a/debian/rules b/prod_build/linux/debian/essentials/rules similarity index 100% rename from debian/rules rename to prod_build/linux/debian/essentials/rules diff --git a/debian/templates b/prod_build/linux/debian/essentials/templates similarity index 100% rename from debian/templates rename to prod_build/linux/debian/essentials/templates diff --git a/prod_build/linux/debian/scripts/build.sh b/prod_build/linux/debian/scripts/build.sh new file mode 100755 index 0000000..6a156b3 --- /dev/null +++ b/prod_build/linux/debian/scripts/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +WORKDIR="resources/dapcash/dapcash-node" +SCRIPTDIR="prod_build/linux/debian/scripts" + +#cd $WORKDIR + $SCRIPTDIR/compile_and_pack.sh || exit 2 && \ + $SCRIPTDIR/test.sh || exit 3 && \ + $SCRIPTDIR/install_test.sh || exit 4 && \ + $SCRIPTDIR/cleanup.sh || exit 5 +#cd $wd diff --git a/prod_build/linux/debian/scripts/chroot/post-build.sh b/prod_build/linux/debian/scripts/chroot/post-build.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/linux/debian/scripts/chroot/pre-build.sh b/prod_build/linux/debian/scripts/chroot/pre-build.sh new file mode 100755 index 0000000..304315a --- /dev/null +++ b/prod_build/linux/debian/scripts/chroot/pre-build.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +check_packages() { + + IFS=" " + local PKG_DEPPIES=$(echo $PKG_DEPS | sed 's/\"//g') + for element in "$PKG_DEPPIES"; do + echo "[DEBUGGA] Checking if $element is installed" + if ! dpkg-query -s $element; then + echo "[WRN] Package $element is not installed. Starting installation" + return 1 + fi + done + return 0 + +} + +install_dependencies() { + + echo "Checking out the dependencies" + if check_packages >> /dev/null; then + echo "[INF] All required packages are installed" + else + echo "" + local PKG_DEPPIES=$(echo $PKG_DEPS | sed 's/\"//g') + echo "[DEBUGGA] Attempting to install $PKG_DEPPIES" + if sudo apt-get install $PKG_DEPPIES -y ; then + echo "" + echo "[INF] Packages were installed successfully" + else + echo "[ERR] can\'t install required packages. Please, check your package manager" + echo "Aborting" + exit 1 + fi + fi + return 0 + +} +PKG_DEPS=$1 +install_dependencies +exit 0 +#for variable in $(cat ./prod_build/general/conf/brands | sed 's/\"//g'); do +# echo $variable +# export "$variable" +#done diff --git a/prod_build/linux/debian/scripts/cleanup.sh b/prod_build/linux/debian/scripts/cleanup.sh new file mode 100755 index 0000000..61180be --- /dev/null +++ b/prod_build/linux/debian/scripts/cleanup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +[ -d build ] && rm -r build +#[ -d packages ] && rm -r packages +exit 0 diff --git a/prod_build/linux/debian/scripts/compile_and_pack.sh b/prod_build/linux/debian/scripts/compile_and_pack.sh new file mode 100755 index 0000000..cf83bb7 --- /dev/null +++ b/prod_build/linux/debian/scripts/compile_and_pack.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +#if [ "$1" == "--static" ]; then +# export $QT_SELECT="qtstatic" #For static builds we'll have a special qt instance, which should be installed manually for now, unfortunately. +#fi + +# error_explainer() { + +# case "$1" in +# "1" ) echo "Error in pre-config happened. Please, review logs";; +# "2" ) echo "Error in compilation happened. Please, review logs";; +# * ) echo "Unandled error $1 happened. Please, review logs";; +# esac +# exit $1 + +# } + + +substitute_pkgname_postfix() { + + #CODENAME=$(lsb_release -a | grep Codename | cut -f2) + #VERSION=$(lsb_release -a | grep Version | cut -f2) + #DISTRO_TYPE=$(lsb_release -a | grep Distributor | cut -f2) + for variable in $(lsb_release -a 2>/dev/null | sed 's/\t//g' | sed 's/ //g' | sed 's/\:/\=/g'); do + echo "variable is $variable" + export $variable + done + sed -i "/ CPACK_SYSTEM_TYPE/s/\".*\"/\"$DistributorID\"/" CMakeLists.txt + sed -i "/ CPACK_SYSTEM_VERSION/s/\".*\"/\"$Release\"/" CMakeLists.txt + sed -i "/ CPACK_SYSTEM_CODENAME/s/\".*\"/\"$Codename\"/" CMakeLists.txt +# sed -i "/ CPACK_SYSTEM_ARCH/s/\".*\"/\"$Codename\"/" CMakeLists.txt No need to replace anything while we're on amd64 arch only. + export -n "DistributorID" + export -n "Release" + export -n "Codename" + export -n "Description" +} + +repack() { + +DEBNAME=$1 +DISTR_CODENAME=$2 +echo "Renaming controlde on $DEBNAME" +mkdir tmp && cd tmp + +#ПроÑматриваем архив и ищем Ñтроку Ñ control.tar +#Результат заноÑим в переменную +CONTROL=$(ar t ../${DEBNAME} | grep control.tar) + +ar x ../$DEBNAME $CONTROL +tar xf $CONTROL +VERSION=$(cat control | grep Version | cut -d ':' -f2) +echo "Version is $VERSION" +sed -i "s/$VERSION/${VERSION}-${DISTR_CODENAME}/" control +rm $CONTROL && tar cf $CONTROL * +ar r ../$DEBNAME $CONTROL +cd .. +rm -rf tmp + +} + +pwd +error=0 +mkdir -p packages +substitute_pkgname_postfix && mkdir -p build && cd build && cmake ../ && make -j$(nproc) && cpack && repack *.deb && mv -v *.deb ../packages/ && cd .. && rm -r build || error=$? +exit $error + +### touch /etc/apt/sources.list.d/demlabs.list deb https://debian.pub.demlabs.net/ bionic main universe multiverse + +### wget https://debian.pub.demlabs.net/debian.pub.demlabs.net.gpg +### apt-key add demlabskey.asc + +### apt-get update +### apt-get install cellframe-node + + + diff --git a/prod_build/linux/debian/scripts/deploy.sh b/prod_build/linux/debian/scripts/deploy.sh new file mode 100755 index 0000000..c4dc436 --- /dev/null +++ b/prod_build/linux/debian/scripts/deploy.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +echo "Deploying to $PACKAGE_PATH" +echo $wd + +DAPCASH_REPO_CREDS="admin@debian.pub.demlabs.net" +DAPCASH_REPO_KEY="~/.ssh/demlabs_publish" +DAPCASH_REPO_PATH="~/web/debian.pub.demlabs.net/public_html" +DAPCASH_FILESERVER_CREDS="admin@pub.dapcash.org" +DAPCASH_FILESERVER_PATH="~/web/pub.dapcash.org/public_html/linux" +pwd + +cd packages +PKGFILES=$(ls . | grep .deb) +#cd .. + +#echo "We have $DISTR_CODENAME there" +#echo "On path $REPO_DIR_SRC we have debian files." +[[ $ONBUILDSERVER == 0 ]] && scp -i $DAPCASH_REPO_KEY ../prod_build/linux/debian/scripts/publish_remote/reprepro.sh "$DAPCASH_REPO_CREDS:~/tmp/" +for pkgfile in $PKGFILES; do + pkgname=$(echo $pkgfile | sed 's/.deb$//') + mv $pkgfile $wd/$PACKAGE_PATH/$pkgname$MOD.deb || { echo "[ERR] Something went wrong in publishing the package. Now aborting."; exit -4; } + CODENAME=$(echo $pkgname | rev | cut -d '-' -f1 | rev) + if [[ $ONBUILDSERVER == 0 ]]; then + #REPREPRO and file_cellframe_services + scp -i $DAPCASH_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$DAPCASH_REPO_CREDS:~/tmp/apt/" + ssh -i $DAPCASH_REPO_KEY "$DAPCASH_REPO_CREDS" "chmod +x ~/tmp/reprepro.sh && ~/tmp/reprepro.sh main $CODENAME ~/tmp/apt/$pkgname$MOD.deb $DAPCASH_REPO_PATH" + scp -i $DAPCASH_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$DAPCASH_FILESERVER_CREDS:$DAPCASH_FILESERVER_PATH/" + ssh -i $DAPCASH_REPO_KEY "$DAPCASH_FILESERVER_CREDS" "ln -sf $DAPCASH_FILESERVER_PATH/$pkgname$MOD.deb $DAPCASH_FILESERVER_PATH/$pkgname$MOD-latest.deb" + fi +done +[[ $ONBUILDSERVER == 0 ]] && ssh -i $DAPCASH_REPO_KEY "$DAPCASH_REPO_CREDS" "rm -v ~/tmp/reprepro.sh" + + export -n "UPDVER" +cd .. + + +# ERROR CODE OVERRIDEN! +exit 0 +#symlink name-actual to the latest version. +#build/deb/versions - for all files +#build/deb/${PROJECT}-latest - for symlinks. diff --git a/prod_build/linux/debian/scripts/install_test.sh b/prod_build/linux/debian/scripts/install_test.sh new file mode 100755 index 0000000..21c44cd --- /dev/null +++ b/prod_build/linux/debian/scripts/install_test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "stub for installation testing" diff --git a/prod_build/linux/debian/scripts/pack.sh b/prod_build/linux/debian/scripts/pack.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/linux/debian/scripts/post-build.sh b/prod_build/linux/debian/scripts/post-build.sh new file mode 100755 index 0000000..c18d6f6 --- /dev/null +++ b/prod_build/linux/debian/scripts/post-build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +#echo "Stub for post-build actions" +echo "Entering post-build deployment and cleanup" +SCRIPTDIR="prod_build/linux/debian/scripts" + +$SCRIPTDIR/deploy.sh || exit 10 && \ +$SCRIPTDIR/cleanup.sh || exit 11 diff --git a/prod_build/linux/debian/scripts/pre-build.sh b/prod_build/linux/debian/scripts/pre-build.sh new file mode 100755 index 0000000..f55152f --- /dev/null +++ b/prod_build/linux/debian/scripts/pre-build.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +#export_variables() { + +#IFS=$'\n' +#for variable in $(cat prod_build/linux/debian/conf/*); do +# echo "$variable" +# export $(echo "$variable" | sed 's/\"//g') +#done + +#} + + +#installing required dependencies + +check_packages() { + + IFS=" " + local PKG_DEPPIES=$(echo $PKG_DEPS | sed 's/\"//g') + for element in "$PKG_DEPPIES"; do + echo "[DEBUGGA] Checking if $element is installed" + if ! dpkg-query -s $element; then + echo "[WRN] Package $element is not installed. Starting installation" + return 1 + fi + done + return 0 + +} + +install_dependencies() { + + if check_packages >> /dev/null; then + echo "[INF] All required packages are installed" + else + echo "" + local PKG_DEPPIES=$(echo $PKG_DEPS | sed 's/\"//g') + echo "[DEBUGGA] Attempting to install $PKG_DEPPIES" + if sudo /usr/bin/apt-get install -y $PKG_DEPPIES ; then + echo "" + echo "[INF] Packages were installed successfully" + else + echo "[ERR] can\'t install required packages. Please, check your package manager" + echo "Aborting" + exit 1 + fi + fi + return 0 + +} + +#extract_version_number() { + +#IFS=" " +#for entry in $VERSION_ENTRIES; do +# VERSION_STRING=$(echo $VERSION_STRING | sed "s/$entry/$( cat $VERSION_FILE | grep $entry | sed 's/ //g' | cut -d '=' -f2 )/") #Replacing templates with numbers +#done +#echo -e "project version is $VERSION_STRING" +# +#} + +#extract_gitlog_text() { +# +#borders=$( git log | grep -n 'commit\|Date' | head -n 3 | tail -n 2 | cut -d ':' -f1) +#upb=$(echo $borders | cut -d $'\n' -f1) +#dwnb=$(echo $borders | cut -d $'\n' -f2) +#text=$(git log | head -n $( expr $dwnb - 2 ) | tail -n $( expr $dwnb - $upb - 3 ) ) +#echo $text +# +#} + +#. prod_build/general/install_dependencies +. prod_build/general/pre-build.sh #VERSIONS and git +export_variables "prod_build/general/conf/*" +export_variables "prod_build/linux/debian/conf/*" +VERSION_STRING=$(echo $VERSION_FORMAT | sed "s/\"//g" ) #Removing quotes +VERSION_ENTRIES=$(echo $VERSION_ENTRIES | sed "s/\"//g" ) +extract_version_number +[ -e prod_build/linux/debian/essentials/changelog ] && last_version_string=$(cat prod_build/linux/debian/essentials/changelog | head -n 1 | cut -d '(' -f2 | cut -d ')' -f1) + + +#if [ -z "$last_version_string"]; then +# echo "Changelog won't be modified" +# exit 1; +#fi + +### ideally, we need to ask whether changelog needs to be updated or not +### is it correct? And if not, we just need to exit from this conditional construction +### not quite. See, there is always a changelog in git. (git log). We need to maintain debian/changelog on projects not built with cmake, +### cause information from this changelog (version) is used to write package metadata. And we had messed up for a long time because of desyncing. +### This is a solution. We modify the changelog only if there are updates and not on build servers. And of course if it's not cmake-based build project. +### let's keep those comments here for a while + +if [[ $ONBUILDSERVER == 0 ]]; then + echo "[WRN] on build platform. Version won't be changed" # okay, so this echo wont be outputted as the condition is not true + +elif [ ! -e debian/changelog ]; then ### I guess this what's supposed to be added in order to solve the issue with the changelog?+ + echo "[INF] Debian changelog does not exist. Nothing to be done there." #I supposed it should look somehow like that. +#makes sense +elif [ "$last_version_string" == "$VERSION_STRING" ]; then + echo "[INF] Version $last_version_string is equal to $VERSION_STRING. Nothing to change" +else + echo "[INF] editing the changelog" + text=$(extract_gitlog_text) + IFS=$'\n' + for textline in $text; do + dch -v $VERSION_STRING $textline + done + branch=$(git branch | grep "*" | cut -c 3- ) + case branch in + "master" ) branch="stable";; + "develop" ) branch="testing";; + esac + dch -r --distribution "$branch" --force-distribution ignored + controlfile_version=$(cat prod_build/linux/debian/essentials/control | grep "Standards" | cut -d ' ' -f2) #Add to control info. + sed -i "s/$controlfile_version/$VERSION_STRING/" prod_build/linux/debian/essentials/control + export UPDVER=1 +fi + +IFS=" " +CHROOT_PREFIX=$1 + +errcode=0 +for distr in $HOST_DISTR_VERSIONS; do #we need to install required dependencies under schroot. + for arch in $HOST_ARCH_VERSIONS; do + echo "$CHROOT_PREFIX-$distr-$arch" + schroot -c $CHROOT_PREFIX-$distr-$arch -- prod_build/linux/debian/scripts/chroot/pre-build.sh "$PKG_DEPS" || errcode=$? + [[ $errcode != 0 ]] && echo "Problems with $CHROOT_PREFIX-$distr-$arch occured. You had installed it, right?" + done +done +exit 0 + +## Maybe we do have the version required? Then we don't need to build it again. CHECK IT THERE! diff --git a/prod_build/linux/debian/scripts/publish_remote/reprepro.sh b/prod_build/linux/debian/scripts/publish_remote/reprepro.sh new file mode 100644 index 0000000..f88300c --- /dev/null +++ b/prod_build/linux/debian/scripts/publish_remote/reprepro.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -x +DISTR_COMPONENT=$1 +DISTR_CODENAME=$2 +PKGNAME=$3 +PATH=$4 + +workdir=$(pwd) +error=0 +cd $PATH + +/usr/bin/reprepro -C "$DISTR_COMPONENT" --ask-passphrase includedeb "$DISTR_CODENAME" "$PKGNAME" && /usr/bin/reprepro export "$DISTR_CODENAME" || error=$? +cd $workdir +exit $error +set +x diff --git a/prod_build/linux/debian/scripts/test.sh b/prod_build/linux/debian/scripts/test.sh new file mode 100755 index 0000000..2b1c7f0 --- /dev/null +++ b/prod_build/linux/debian/scripts/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Stub for functionality testing" + diff --git a/prod_build/linux/ubuntu/conf/dependencies b/prod_build/linux/ubuntu/conf/dependencies new file mode 100644 index 0000000..7282350 --- /dev/null +++ b/prod_build/linux/ubuntu/conf/dependencies @@ -0,0 +1 @@ +PKG_DEPS="cmake libjson-c-dev libsqlite3-dev libmemcached-dev libev-dev libmagic-dev libcurl4-gnutls-dev libldb-dev libtalloc-dev libtevent-dev traceroute" diff --git a/prod_build/linux/ubuntu/conf/publish b/prod_build/linux/ubuntu/conf/publish new file mode 100644 index 0000000..6e09e69 --- /dev/null +++ b/prod_build/linux/ubuntu/conf/publish @@ -0,0 +1,8 @@ +HOST_DISTR_VERSIONS="bionic" +HOST_ARCH_VERSIONS="amd64" +PACKAGE_PATH=builds/deb/ +REPO_DIR_SRC=/var/tmp/repository +DISTR_CODENAME="bionic" +REPO_ADDR=debian.pub.demlabs.net +REPO_DIR=/var/www/html/debian.pub.demlabs.net +DISTR_COMPONENT=main diff --git a/prod_build/linux/ubuntu/essentials b/prod_build/linux/ubuntu/essentials new file mode 120000 index 0000000..ff903c9 --- /dev/null +++ b/prod_build/linux/ubuntu/essentials @@ -0,0 +1 @@ +../debian/essentials \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/build.sh b/prod_build/linux/ubuntu/scripts/build.sh new file mode 120000 index 0000000..53fcd46 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/build.sh @@ -0,0 +1 @@ +../../debian/scripts/build.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/chroot b/prod_build/linux/ubuntu/scripts/chroot new file mode 120000 index 0000000..688a8bf --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/chroot @@ -0,0 +1 @@ +../../debian/scripts/chroot \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/cleanup.sh b/prod_build/linux/ubuntu/scripts/cleanup.sh new file mode 120000 index 0000000..93a84bf --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/cleanup.sh @@ -0,0 +1 @@ +../../debian/scripts/cleanup.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/compile_and_pack.sh b/prod_build/linux/ubuntu/scripts/compile_and_pack.sh new file mode 120000 index 0000000..ef456c3 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/compile_and_pack.sh @@ -0,0 +1 @@ +../../debian/scripts/compile_and_pack.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/deploy.sh b/prod_build/linux/ubuntu/scripts/deploy.sh new file mode 120000 index 0000000..bbb85a1 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/deploy.sh @@ -0,0 +1 @@ +../../debian/scripts/deploy.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/install_test.sh b/prod_build/linux/ubuntu/scripts/install_test.sh new file mode 120000 index 0000000..7018847 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/install_test.sh @@ -0,0 +1 @@ +../../debian/scripts/install_test.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/pack.sh b/prod_build/linux/ubuntu/scripts/pack.sh new file mode 120000 index 0000000..92454e5 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/pack.sh @@ -0,0 +1 @@ +../../debian/scripts/pack.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/post-build.sh b/prod_build/linux/ubuntu/scripts/post-build.sh new file mode 120000 index 0000000..bd51497 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/post-build.sh @@ -0,0 +1 @@ +../../debian/scripts/post-build.sh \ No newline at end of file diff --git a/prod_build/linux/ubuntu/scripts/pre-build.sh b/prod_build/linux/ubuntu/scripts/pre-build.sh new file mode 100755 index 0000000..583f3c9 --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/pre-build.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +#export_variables() { + +#IFS=$'\n' +#for variable in $(cat prod_build/linux/ubuntu/conf/*); do +# echo "$variable" +# export $(echo "$variable" | sed 's/\"//g') +#done + +#} + + +#installing required dependencies + +check_packages() { + + IFS=" " + local PKG_DEPPIES=$(echo $PKG_DEPS | sed 's/\"//g') + for element in "$PKG_DEPPIES"; do + echo "[DEBUGGA] Checking if $element is installed" + if ! dpkg-query -s $element; then + echo "[WRN] Package $element is not installed. Starting installation" + return 1 + fi + done + return 0 + +} + +install_dependencies() { + + if check_packages >> /dev/null; then + echo "[INF] All required packages are installed" + else + echo "" + local PKG_DEPPIES=$(echo $PKG_DEPS | sed 's/\"//g') + echo "[DEBUGGA] Attempting to install $PKG_DEPPIES" + if sudo /usr/bin/apt-get install -y $PKG_DEPPIES ; then + echo "" + echo "[INF] Packages were installed successfully" + else + echo "[ERR] can\'t install required packages. Please, check your package manager" + echo "Aborting" + exit 1 + fi + fi + return 0 + +} + +#extract_version_number() { + +#IFS=" " +#for entry in $VERSION_ENTRIES; do +# VERSION_STRING=$(echo $VERSION_STRING | sed "s/$entry/$( cat $VERSION_FILE | grep $entry | sed 's/ //g' | cut -d '=' -f2 )/") #Replacing templates with numbers +#done +#echo -e "project version is $VERSION_STRING" +# +#} + +#extract_gitlog_text() { +# +#borders=$( git log | grep -n 'commit\|Date' | head -n 3 | tail -n 2 | cut -d ':' -f1) +#upb=$(echo $borders | cut -d $'\n' -f1) +#dwnb=$(echo $borders | cut -d $'\n' -f2) +#text=$(git log | head -n $( expr $dwnb - 2 ) | tail -n $( expr $dwnb - $upb - 3 ) ) +#echo $text +# +#} + +#. prod_build/general/install_dependencies +. prod_build/general/pre-build.sh #VERSIONS and git +export_variables "prod_build/general/conf/*" +export_variables "prod_build/linux/ubuntu/conf/*" + +VERSION_STRING=$(echo $VERSION_FORMAT | sed "s/\"//g" ) #Removing quotes +VERSION_ENTRIES=$(echo $VERSION_ENTRIES | sed "s/\"//g" ) +extract_version_number +[ -e prod_build/linux/ubuntu/essentials/changelog ] && last_version_string=$(cat prod_build/linux/ubuntu/essentials/changelog | head -n 1 | cut -d '(' -f2 | cut -d ')' -f1) + + + +#if [ -z "$last_version_string"]; then +# echo "Changelog won't be modified" +# exit 1; +#fi + +### ideally, we need to ask whether changelog needs to be updated or not +### is it correct? And if not, we just need to exit from this conditional construction +### not quite. See, there is always a changelog in git. (git log). We need to maintain ubuntu/changelog on projects not built with cmake, +### cause information from this changelog (version) is used to write package metadata. And we had messed up for a long time because of desyncing. +### This is a solution. We modify the changelog only if there are updates and not on build servers. And of course if it's not cmake-based build project. +### let's keep those comments here for a while +if [ $ONBUILDSERVER == 0 ]; then + echo "[WRN] on build platform. Version won't be changed" # okay, so this echo wont be outputted as the condition is not true + +elif [ ! -e ubuntu/changelog ]; then ### I guess this what's supposed to be added in order to solve the issue with the changelog?+ + echo "[INF] Ubuntu changelog does not exist. Nothing to be done there." #I supposed it should look somehow like that. +#makes sense +elif [ "$last_version_string" == "$VERSION_STRING" ]; then + echo "[INF] Version $last_version_string is equal to $VERSION_STRING. Nothing to change" +else + echo "[INF] editing the changelog" + text=$(extract_gitlog_text) + IFS=$'\n' + for textline in $text; do + dch -v $VERSION_STRING $textline + done + branch=$(git branch | grep "*" | cut -c 3- ) + case branch in + "master" ) branch="stable";; + "develop" ) branch="testing";; + esac + dch -r --distribution "$branch" --force-distribution ignored + controlfile_version=$(cat prod_build/linux/ubuntu/essentials/control | grep "Standards" | cut -d ' ' -f2) #Add to control info. + sed -i "s/$controlfile_version/$VERSION_STRING/" prod_build/linux/ubuntu/essentials/control + export UPDVER=1 +fi + +IFS=" " +CHROOT_PREFIX=$1 +for distr in $HOST_DISTR_VERSIONS; do #we need to install required dependencies under schroot. + for arch in $HOST_ARCH_VERSIONS; do + echo "$CHROOT_PREFIX-$distr-$arch" + schroot -c $CHROOT_PREFIX-$distr-$arch -- prod_build/linux/ubuntu/scripts/chroot/pre-build.sh "$PKG_DEPS" || errcode=$? + [[ $errcode != 0 ]] && echo "Problems with $CHROOT_PREFIX-$distr-$arch occured. You had installed it, right?" + done +done +exit 0 + +## Maybe we do have the version required? Then we don't need to build it again. CHECK IT THERE! diff --git a/prod_build/linux/ubuntu/scripts/test.sh b/prod_build/linux/ubuntu/scripts/test.sh new file mode 120000 index 0000000..ebcc2fa --- /dev/null +++ b/prod_build/linux/ubuntu/scripts/test.sh @@ -0,0 +1 @@ +../../debian/scripts/test.sh \ No newline at end of file diff --git a/prod_build/mac/scripts/compile.sh b/prod_build/mac/scripts/compile.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/mac/scripts/deploy.sh b/prod_build/mac/scripts/deploy.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/mac/scripts/pack.sh b/prod_build/mac/scripts/pack.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/mac/scripts/pre-build.sh b/prod_build/mac/scripts/pre-build.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/mac/scripts/test.sh b/prod_build/mac/scripts/test.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/windows/scripts/compile.sh b/prod_build/windows/scripts/compile.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/windows/scripts/deploy.sh b/prod_build/windows/scripts/deploy.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/windows/scripts/pack.sh b/prod_build/windows/scripts/pack.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/windows/scripts/pre-build.sh b/prod_build/windows/scripts/pre-build.sh new file mode 100755 index 0000000..e69de29 diff --git a/prod_build/windows/scripts/test.sh b/prod_build/windows/scripts/test.sh new file mode 100755 index 0000000..e69de29 diff --git a/scripts/.gitkeep b/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 -- GitLab