diff --git a/general/essentials/weblink-latest/.htaccess b/essentials/weblink-latest/.htaccess similarity index 100% rename from general/essentials/weblink-latest/.htaccess rename to essentials/weblink-latest/.htaccess diff --git a/general/essentials/weblink-latest/index.html b/essentials/weblink-latest/index.html similarity index 100% rename from general/essentials/weblink-latest/index.html rename to essentials/weblink-latest/index.html diff --git a/general/build.sh b/general/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..44d14b23e8a38d9b73b089e7f00aecb4d7fcba52 --- /dev/null +++ b/general/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +platform=$1 +echo "workdir is $(pwd)" +. prod_build/general/pre-build.sh +export_variables "./prod_build/general/conf/*" + +[ -e prod_build/$platform/scripts/pre-build.sh ] && prod_build/$platform/scripts/pre-build.sh || exit $? #For actions before build not in chroot and in chroot (version update, install missing dependencies(under schroot)) +prod_build/$platform/scripts/build.sh $PKG_TYPE || { errcode=$? && unexport_variables "./prod_build/$platform/conf/*"; exit $errcode; } +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) +unexport_variables "./prod_build/$platform/conf/*" + +cd $wd + +exit $errcode diff --git a/general/chroot_wrap.sh b/general/chroot_wrap.sh deleted file mode 100755 index c1b8d102b27fe8f04b96453b0ef8e06a4ab7aef5..0000000000000000000000000000000000000000 --- a/general/chroot_wrap.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -PLATFORM_CANDIDATES=$2 -CHROOT_PREFIX="builder" -CHROOTS_PATH=$1 -PLATFORMS="" -PKG_FORMAT=$3 -JOB=$4 - -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 - -if [[ $CI_COMMIT_REF_NAME == "master" ]]; then - ./prod_build/general/update_dashboard.sh -fi - -#[ $(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/general/conf/status b/general/conf/status deleted file mode 100644 index 5082e1d8aae5d8afc0df90903a6ad9e1bddd14a1..0000000000000000000000000000000000000000 --- a/general/conf/status +++ /dev/null @@ -1 +0,0 @@ -IMPLEMENTED="linux/debian linux/ubuntu" diff --git a/general/post-build.sh b/general/post-build.sh new file mode 100755 index 0000000000000000000000000000000000000000..1d7826761769177b5cdac8359c03951e84de8071 --- /dev/null +++ b/general/post-build.sh @@ -0,0 +1,19 @@ +echo "workdir before postinstall is $(pwd)" + +platform=$1 +errstring="" +errcode=0 + +. prod_build/general/pre-build.sh +for conffile in $(find "./prod_build/$platform/conf" | grep conf/ | grep -v .bak); do + export_variables $conffile + echo "export variables from $conffile" +done +export_variables "prod_build/general/conf/*" + +[[ -e prod_build/$platform/scripts/post-build.sh ]] && prod_build/$platform/scripts/post-build.sh $platform || { errcode=$? && errstring="$errstring ${platform}_postbuild errcode $errcode"; } #For post-build actions not in chroot (global publish) +[[ $errstring != "" ]] && echo "$brand done with errors:" && echo "$errstring" >> ~/prod_log && errstring="" && errcode=5 ## General failure error + +unexport_variables $(find "./prod_build/$platform/conf" -maxdepth 1 -type f) + +exit $errcode diff --git a/linux/debian/conf/publish b/linux/debian/conf/publish index b8b3a21d19223b035b6f4aaa1cd7a30819636869..b5df2d70cc6ffdee852445e793eb7c9251b58470 100644 --- a/linux/debian/conf/publish +++ b/linux/debian/conf/publish @@ -1,8 +1,5 @@ -HOST_DISTR_VERSIONS="stretch buster bullseye" -HOST_ARCH_VERSIONS="amd64" -PACKAGE_PATH=builds/deb/ +PACKAGE_PATH=/home/gitlab-runner/production-docker/builds/deb/ REPO_DIR_SRC=/var/tmp/repository -DISTR_CODENAME="stretch buster bullseye" REPO_ADDR=debian.pub.demlabs.net REPO_DIR=/var/www/html/debian.pub.demlabs.net DISTR_COMPONENT=main diff --git a/linux/debian/essentials/postinst b/linux/debian/essentials/postinst index 36deecfe0651184d108c0730b3b247e62c185302..2f0aab909060aa5a0eff63e6113cf02b04948b92 100755 --- a/linux/debian/essentials/postinst +++ b/linux/debian/essentials/postinst @@ -14,7 +14,7 @@ DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg" # Check profile.d symlink -[ -e "/etc/profile.d/$DAP_APP_NAME.sh" ] && ln -sf $DAP_PREFIX/share/profile.d/$DAP_APP_NAME.sh /etc/profile.d/$DAP_APP_NAME.sh +[ -e "/etc/profile.d/$DAP_APP_NAME.sh" ] || ln -sf $DAP_PREFIX/share/profile.d/$DAP_APP_NAME.sh /etc/profile.d/$DAP_APP_NAME.sh # Init node config if [ -e "$DAP_CFG" ]; then diff --git a/linux/debian/scripts/chroot/post-build.sh b/linux/debian/scripts/chroot/post-build.sh deleted file mode 100755 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/linux/debian/scripts/chroot/pre-build.sh b/linux/debian/scripts/chroot/pre-build.sh deleted file mode 100755 index 5129267b2685139c144516dc9d133abf7af5fb37..0000000000000000000000000000000000000000 --- a/linux/debian/scripts/chroot/pre-build.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/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 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/linux/debian/scripts/compile_and_pack.sh b/linux/debian/scripts/compile_and_pack.sh index ad7284f597d7a1289597be1694f55ae988c25997..dc3ac9c17ed6dfb62c8f4e005e8fd83aa73e3d6e 100755 --- a/linux/debian/scripts/compile_and_pack.sh +++ b/linux/debian/scripts/compile_and_pack.sh @@ -1,34 +1,15 @@ #!/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. + sed -i "/ ${CMAKE_PATH}cpack_SYSTEM_TYPE/s/\".*\"/\"$DistributorID\"/" CMakeLists.txt + sed -i "/ ${CMAKE_PATH}cpack_SYSTEM_VERSION/s/\".*\"/\"$Release\"/" CMakeLists.txt + sed -i "/ ${CMAKE_PATH}cpack_SYSTEM_CODENAME/s/\".*\"/\"$Codename\"/" CMakeLists.txt export -n "DistributorID" export -n "Release" export -n "Codename" @@ -62,13 +43,36 @@ 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/ && rm -r * \ -&& cmake -DCMAKE_BUILD_TYPE=Debug ../ && make -j$(nproc) && cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * || error=$? +echo "Build for $ARCH_VERSIONS architectures" +substitute_pkgname_postfix && mkdir -p build && cd build && ${CMAKE_PATH}cmake ../ && make -j$(nproc) && ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * \ +&& ${CMAKE_PATH}cmake -DCMAKE_BUILD_TYPE=Debug ../ && make -j$(nproc) && ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * || error=$? + +echo $error +if [[ $(echo $ARCH_VERSIONS | grep arm64) != "" && $error == 0 ]]; then + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_ARM64 + ${CMAKE_PATH}cmake -DCMAKE_C_COMPILER=$ARM64_C_COMPILER -DCMAKE_CXX_COMPLIER=$ARM64_CXX_COMPILER -DCMAKE_TARGET_ARCH="arm64" .. && make -j$(nproc) && \ + ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * && \ + ${CMAKE_PATH}cmake -DCMAKE_BUILD_TYPE=Debug ../ && make -j$(nproc) && ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * || error=$? + unset LD_LIBRARY_PATH +fi + +if [[ $(echo $ARCH_VERSIONS | grep armhf) != "" && $error == 0 ]]; then + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_ARMHF + ${CMAKE_PATH}cmake -DCMAKE_C_COMPILER=$ARMHF_C_COMPILER -DCMAKE_CXX_COMPLIER=$ARMHF_CXX_COMPILER -DCMAKE_TARGET_ARCH="armhf" .. && make -j$(nproc) && \ + ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * && \ + ${CMAKE_PATH}cmake -DCMAKE_BUILD_TYPE=Debug ../ && make -j$(nproc) && ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * || error=$? + unset LD_LIBRARY_PATH +fi + +if [[ $(echo $BUILD_TYPE | grep PGSQL) != "" && $error == 0 ]]; then + sed -ibak 's/#set(BUILD_WITH_GDB_DRIVER_PGSQL ON)/set(BUILD_WITH_GDB_DRIVER_PGSQL ON)/' ../CMakeLists.txt || error=$? + ${CMAKE_PATH}cmake ../ && make -j$(nproc) && ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * \ + && ${CMAKE_PATH}cmake -DCMAKE_BUILD_TYPE=Debug ../ && make -j$(nproc) && ${CMAKE_PATH}cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * || error=$? +fi + +cd .. && rm -r build +[ -e CMakeLists.txtbak ] && mv -f CMakeLists.txtbak CMakeLists.txt -sed -ibak 's/#set(BUILD_WITH_GDB_DRIVER_PGSQL ON)/set(BUILD_WITH_GDB_DRIVER_PGSQL ON)/' ../CMakeLists.txt || error=$? -cmake ../ && make -j$(nproc) && cpack && repack *.deb && mv -v *.deb ../packages/ && rm -r * \ -&& cmake -DCMAKE_BUILD_TYPE=Debug ../ && make -j$(nproc) && cpack && repack *.deb && mv -v *.deb ../packages/ && cd .. && rm -r build && \ -mv -f CMakeLists.txtbak CMakeLists.txt || error=$? exit $error @@ -77,8 +81,6 @@ exit $error ### 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/linux/debian/scripts/deploy.sh b/linux/debian/scripts/deploy.sh index 3fba115a66a7ce2881c9a9763c501ec1bdd78d4c..ab0bdfd2db2b0c9fe122367d25120738b718423d 100755 --- a/linux/debian/scripts/deploy.sh +++ b/linux/debian/scripts/deploy.sh @@ -35,12 +35,12 @@ for pkgfile in $PKGFILES; do scp -i $CELLFRAME_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$CELLFRAME_FILESERVER_CREDS:$CELLFRAME_FILESERVER_PATH/$SUBDIR/$pkgname_public$MOD.deb" if [[ $(echo $pkgname | grep "pgsql\|dbg") == "" ]]; then scp -r -i $CELLFRAME_REPO_KEY ../prod_build/general/essentials/$pkgname_weblink "$CELLFRAME_FILESERVER_CREDS:$CELLFRAME_FILESERVER_PATH/$SUBDIR/" - fi - if [[ $CI_COMMIT_REF_NAME == "master" ]]; then -set -x - scp -P $REPO_PORT -i $CELLFRAME_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$CELLFRAME_REPO_CREDS:~/aptly/repo_update/$pkgname_public$MOD.deb" - ssh -p $REPO_PORT -i $CELLFRAME_REPO_KEY "$CELLFRAME_REPO_CREDS" -- "~/aptly/repo_update.sh" -set +x + if [[ $CI_COMMIT_REF_NAME == "master" ]]; then + set -x + scp -P $REPO_PORT -i $CELLFRAME_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$CELLFRAME_REPO_CREDS:~/aptly/repo_update/$pkgname_public$MOD.deb" + ssh -p $REPO_PORT -i $CELLFRAME_REPO_KEY "$CELLFRAME_REPO_CREDS" -- "~/aptly/repo_update.sh" + set +x + fi fi # ssh -i $CELLFRAME_REPO_KEY "$CELLFRAME_FILESERVER_CREDS" "ln -sf $CELLFRAME_FILESERVER_PATH/$pkgname$MOD.deb $CELLFRAME_FILESERVER_PATH/$pkgname$MOD-latest.deb" diff --git a/linux/debian/scripts/pre-build.sh b/linux/debian/scripts/pre-build.sh index 975fee3b055f57e67ab8373df8dff4d706373e03..831242dc27ce18465478d6756a58424a31af8f26 100755 --- a/linux/debian/scripts/pre-build.sh +++ b/linux/debian/scripts/pre-build.sh @@ -1,74 +1,5 @@ #!/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/*" @@ -93,7 +24,7 @@ extract_version_number ### 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 +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?+ @@ -119,17 +50,6 @@ else 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/linux/ubuntu/conf/publish b/linux/ubuntu/conf/publish index c0a7bfe66168e95136ef97cb49402c6f8dbbbf0e..b5df2d70cc6ffdee852445e793eb7c9251b58470 100644 --- a/linux/ubuntu/conf/publish +++ b/linux/ubuntu/conf/publish @@ -1,8 +1,5 @@ -HOST_DISTR_VERSIONS="bionic focal hirsute" -HOST_ARCH_VERSIONS="amd64" -PACKAGE_PATH=builds/deb/ +PACKAGE_PATH=/home/gitlab-runner/production-docker/builds/deb/ REPO_DIR_SRC=/var/tmp/repository -DISTR_CODENAME="bionic focal hirsute" REPO_ADDR=debian.pub.demlabs.net REPO_DIR=/var/www/html/debian.pub.demlabs.net DISTR_COMPONENT=main