Skip to content
Snippets Groups Projects
Commit 1e01ac84 authored by alexandr.kravchenko's avatar alexandr.kravchenko
Browse files

Moved prod_build to separate submodule.

parent 620fda47
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 479 deletions
PKG_DEPS="cmake libjson-c-dev libsqlite3-dev libmemcached-dev libev-dev libmagic-dev libcurl4-gnutls-dev libldb-dev libtalloc-dev libtevent-dev traceroute libpython3-dev"
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
#!/bin/bash -e
. /usr/share/debconf/confmodule
case "$1" in
reconfigure|configure)
db_input critical cellframe-node/auto_online || true
db_go || true
db_input critical cellframe-node/debug_mode || true
db_go || true
db_input critical cellframe-node/server_enabled || true
db_go || true
db_input critical cellframe-node/server_addr || true
db_go || true
db_input critical cellframe-node/server_port || true
db_go || true
db_input critical cellframe-node/core_t_enabled || true
db_go || true
db_input critical cellframe-node/core_t_node_type || true
db_go || true
db_input critical cellframe-node/kelvin_testnet_enabled || true
db_go || true
db_input critical cellframe-node/kelvin_testnet_node_type || true
db_go || true
;;
*)
echo "config called with unknown argument \`$1'" >&2
exit 1
;;
esac
#!/bin/bash -e
. /usr/share/debconf/confmodule
DAP_CHAINS_NAME="cellframe"
DAP_APP_NAME="$DAP_CHAINS_NAME-node"
DAP_PREFIX="/opt/$DAP_APP_NAME"
DAP_CFG_TPL="$DAP_PREFIX/share/configs/$DAP_APP_NAME.cfg.tpl"
# Store write config to new if present smth
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
# Init node config
if [ -e "$DAP_CFG" ]; then
DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg.dpkg-new"
else
DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg"
fi
cat $DAP_CFG_TPL > $DAP_CFG || true
db_get cellframe-node/debug_mode || true
sed -i "s/{DEBUG_MODE}/$RET/" $DAP_CFG || true
db_get cellframe-node/auto_online || true
sed -i "s/{AUTO_ONLINE}/$RET/" $DAP_CFG || true
db_get cellframe-node/server_enabled || true
sed -i "s/{SERVER_ENABLED}/$RET/" $DAP_CFG || true
db_get cellframe-node/server_port || true
sed -i "s/{SERVER_PORT}/$RET/" $DAP_CFG || true
db_get cellframe-node/server_addr || true
sed -i "s/{SERVER_ADDR}/$RET/" $DAP_CFG || true
# Init core testnet
NET_NAME="core-t"
db_get cellframe-node/core_t_enabled || true
if [ "$RET"=="true" ]; then
DAP_CFG_NET="$DAP_PREFIX/etc/network/$NET_NAME.cfg"
DAP_CFG_NET_TPL="$DAP_PREFIX/share/configs/network/$NET_NAME.cfg.tpl"
DAP_NET_CFG=""
if [ -e "$DAP_CFG_NET" ]; then
DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg.dpkg-new"
else
DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg"
fi
cat $DAP_CFG_NET_TPL > $DAP_NET_CFG || true
db_get cellframe-node/core_t_node_type || true
NODE_TYPE=$RET
sed -i "s/{NODE_TYPE}/$NODE_TYPE/" $DAP_NET_CFG || true
echo "[*] Enabled core testnet"
fi
# Init kelvin-testnet
NET_NAME="kelvin-testnet"
db_get cellframe-node/kelvin_testnet_enabled || true
if [ "$RET"=="true" ]; then
DAP_CFG_NET="$DAP_PREFIX/etc/network/$NET_NAME.cfg"
DAP_CFG_NET_TPL="$DAP_PREFIX/share/configs/network/$NET_NAME.cfg.tpl"
DAP_NET_CFG=""
if [ -e "$DAP_CFG_NET" ]; then
DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg.dpkg-new"
else
DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg"
fi
cat $DAP_CFG_NET_TPL > $DAP_NET_CFG || true
db_get cellframe-node/kelvin_testnet_node_type || true
NODE_TYPE=$RET
sed -i "s/{NODE_TYPE}/$NODE_TYPE/" $DAP_NET_CFG || true
echo "[*] Enabled kelvin testnet"
fi
mkdir -p $DAP_PREFIX/var/log || true
mkdir -p $DAP_PREFIX/var/plugins || true
cat /etc/passwd| grep cellframe-node || adduser --system --no-create-home --group --home /opt/cellframe-node cellframe-node || true
echo "[*] Check /etc/systemd/system/$DAP_APP_NAME.service file..."
if [ -L /etc/systemd/system/$DAP_APP_NAME.service ]; then
echo "[*] Restarting $DAP_APP_NAME to implement changes"
systemctl --system stop $DAP_APP_NAME >> /dev/null|| true
echo "[*] Stopped $DAP_APP_NAME"
systemctl daemon-reload || true
systemctl --system start $DAP_APP_NAME || true
echo "[*] Started $DAP_APP_NAME"
else
echo "[!] Installing $DAP_APP_NAME as systemd service (haven't found /etc/systemd/system/$DAP_APP_NAME.service)"
ln -sf $DAP_PREFIX/share/$DAP_APP_NAME.service /etc/systemd/system/$DAP_APP_NAME.service || true
systemctl --system enable $DAP_PREFIX/share/$DAP_APP_NAME.service || true
# systemctl --system start $DAP_APP_NAME
echo "[ ] Execute 'systemctl start $DAP_APP_NAME' to start $DAP_APP_NAME service"
#USERMAN=`users | awk '{print $1}'`
adduser --system --no-create-home --group --home /opt/cellframe-node cellframe-node || true
#usermod -aG $DAP_CHAINS_NAME `users | awk '{print $1}'`
for username in $(cat /etc/passwd | grep "/home" | cut -d ':' -f1); do
usermod -aG cellframe-node $username || true
done
mkdir -p $DAP_PREFIX/var/{run,lib/ca,lib/wallet,lib/global_db,var/plugins} || true
touch $DAP_PREFIX/var/run/cellframe-node.pid || true
#chown -R $USERMAN:$USERMAN $DAP_PREFIX
for filename in $(find $DAP_PREFIX); do
if [ -d $filename ]; then
chmod 0775 $filename
else
chmod 0664 $filename
fi
done
chmod 0774 $DAP_PREFIX/bin/*
chmod 0777 $DAP_PREFIX/bin/$DAP_APP_NAME-cli
service cellframe-node start || true
echo "[!] Done"
fi
#! /bin/bash -e
if [ "$1" == "purge" ] && [ -e /usr/share/debconf/confmodule ] ; then
. /usr/share/debconf/confmodule
db_purge
fi
GROUP_RM="cellframe-node"
systemctl stop cellframe-node || true
systemctl disable cellframe-node || true
#for username in `cat /etc/passwd | grep "/home" | cut -d ':' -f1`; do
# gpasswd -d $username $GROUP_RM || true
#done
#rm -r /opt/cellframe-node || true
#groupdel cellframe-node || true
#userdel cellframe-node || true
#!/usr/bin/make -f
override_dh_fixperms:
dh_fixperms -X/opt/cellframe-node
chmod 777 /opt/cellframe-node/bin/cellframe-node-cli
override_dh_auto_install:
dh_auto_install -- prefix=/opt/cellframe-node
%:
# dh $@ --with=systemd
dh $@
Template: cellframe-node/auto_online
Default: false
Choices: true, false
Type: select
Description: Auto online
Bring up links automaticly and go to the ONLINE network state
Template: cellframe-node/debug_mode
Default: false
Choices: true, false
Type: select
Description: Debug mode
Debug mode for logs
Template: cellframe-node/server_enabled
Default: false
Choices: true, false
Type: select
Description: Accept connections
Accept connections
Template: cellframe-node/server_port
Default: 8079
Type: string
Description: Server port
Server port to listen on, recomended 8079
Template: cellframe-node/server_addr
Default: 0.0.0.0
Type: string
Description: Server address
Server address to listen on
Template: cellframe-node/core_t_enabled
Default: false
Choices: true, false
Type: select
Description: Core-T (Testnet): Enable network
Core Testnet: Enable network auto load on start
Template: cellframe-node/core_t_node_type
Type: select
Default: full
Choices: full, light, master, archive, root
Description: Core Testnet: Node role
Select node role:.
Light - syncronize only local wallets
full - sync all its cell
master - allow to store values in chains and take comission, sync all shards that will need to be synced
archive - Sync all the network
root - Special predefined root nodes, usualy produces zerochain and act like archive as well
Template: cellframe-node/kelvin_testnet_enabled
Default: true
Choices: true, false
Type: select
Description: Kelvin Testnet: Enable network
Kelvin Testnet: Enable network auto load on start
Template: cellframe-node/kelvin_testnet_node_type
Type: select
Default: full
Choices: full, light, master, archive, root
Description: Kelvin Testnet: Node role
Select node role:.
Light - syncronize only local wallets
full - sync all its cell
master - allow to store values in chains and take comission, sync all shards that will need to be synced
archive - Sync all the network
root - Special predefined root nodes, usualy produces zerochain and act like archive as well
#!/bin/bash
WORKDIR="resources/cellframe/cellframe-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
#!/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
#!/bin/bash
[ -d build ] && rm -r build
#[ -d packages ] && rm -r packages
exit 0
#!/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="$Codename"
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 zcf $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
#!/bin/bash
echo "Deploying to $PACKAGE_PATH"
echo $wd
CELLFRAME_REPO_CREDS="admin@debian.pub.demlabs.net"
CELLFRAME_REPO_KEY="~/.ssh/demlabs_publish"
CELLFRAME_REPO_PATH="~/web/debian.pub.demlabs.net/public_html"
CELLFRAME_FILESERVER_CREDS="admin@pub.cellframe.net"
CELLFRAME_FILESERVER_PATH="~/web/pub.cellframe.net/public_html/linux"
pwd
cd packages
PKGFILES=$(ls . | grep .deb)
MOD=$(echo $MOD | sed 's/-\?static-\?//') && [ ! $MOD = "" ] && MOD="-$MOD"
#cd ..
[[ -v CI_COMMIT_REF_NAME ]] && [[ $CI_COMMIT_REF_NAME != "master" ]] && SUBDIR="${CI_COMMIT_REF_NAME}" || SUBDIR=""
#echo "We have $DISTR_CODENAME there"
#echo "On path $REPO_DIR_SRC we have debian files."
[[ $CI_COMMIT_REF_NAME == "master" ]] && scp -i $CELLFRAME_REPO_KEY ../prod_build/linux/debian/scripts/publish_remote/reprepro.sh "$CELLFRAME_REPO_CREDS:~/tmp/"
for pkgfile in $PKGFILES; do
pkgname=$(echo $pkgfile | sed 's/.deb$//')
pkgname_public=$(echo $pkgname | cut -d '-' -f1-4,7-) #cutting away Debian-9.12
pkgname_weblink="$(echo $pkgname | cut -d '-' -f2,8 )-latest" #leaving only necessary entries
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)
cp -r ../prod_build/general/essentials/weblink-latest ../prod_build/general/essentials/$pkgname_weblink
sed -i "/document/s/cellframe.*deb/$pkgname_public$MOD.deb/" ../prod_build/general/essentials/$pkgname_weblink/index.php
if [[ $(echo $CI_COMMIT_REF_NAME | grep "master\|^release") != "" ]]; then
echo "REF_NAME is $CI_COMMIT_REF_NAME"
ssh -i $CELLFRAME_REPO_KEY "$CELLFRAME_FILESERVER_CREDS" "mkdir -p $CELLFRAME_FILESERVER_PATH/$SUBDIR"
scp -i $CELLFRAME_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$CELLFRAME_FILESERVER_CREDS:$CELLFRAME_FILESERVER_PATH/$SUBDIR/$pkgname_public$MOD.deb"
scp -r -i $CELLFRAME_REPO_KEY ../prod_build/general/essentials/$pkgname_weblink "$CELLFRAME_FILESERVER_CREDS:$CELLFRAME_FILESERVER_PATH/$SUBDIR/"
if [[ $CI_COMMIT_REF_NAME == "master" ]]; then
scp -i $CELLFRAME_REPO_KEY $wd/$PACKAGE_PATH/$pkgname$MOD.deb "$CELLFRAME_REPO_CREDS:~/aptly/repo_update/$pkgname_public$MOD.deb"
ssh -i $CELLFRAME_REPO_KEY "$CELLFRAME_REPO_CREDS" -- "~/aptly/repo_update.sh"
fi
# ssh -i $CELLFRAME_REPO_KEY "$CELLFRAME_FILESERVER_CREDS" "ln -sf $CELLFRAME_FILESERVER_PATH/$pkgname$MOD.deb $CELLFRAME_FILESERVER_PATH/$pkgname$MOD-latest.deb"
fi
rm -r ../prod_build/general/essentials/$pkgname_weblink
done
[[ $CI_COMMIT_REF_NAME == "master" ]] && ssh -i $CELLFRAME_REPO_KEY "$CELLFRAME_REPO_CREDS" "rm -v ~/tmp/reprepro.sh"
# export -n "UPDVER"
cd ..
exit 0
#symlink name-actual to the latest version.
#build/deb/versions - for all files
#build/deb/${PROJECT}-latest - for symlinks.
#!/bin/bash
echo "stub for installation testing"
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment