...
Create new vm and update
Create new default zone
Test create default zone
Create zone for get depends and get depends
Create new zone for create local repository
Create new zone for build component
Create new zone for test instalation component
...
Code Block |
---|
echo -n ' create -b set zonepath=/zones/'${TYPE_ZONE}' set brand=dpkg set autoboot=false set ip-type=exclusive add fs set dir="/export/home/admin" set special="/export/home/admin" set type="lofs" end add fs set dir="/export/builds" set special="/export/builds" set type="lofs" end add fs set dir="/data/repo" set special="/data/repo" set type="lofs" end add net set physical="vnic1" set global-nic="stub2" add property (name=ip,value='${IP}') add property (name=netmask,value="255.255.255.0") add property (name=gateway,value="192.168.0.254") add property (name=primary,value="true") end add attr set name="resolvers" set type="string" set value="8.8.8.8" end verify commit exit' > ${HOME}/${TYPE_ZONE}.cmd sudo zonecfg -z ${TYPE_ZONE} -f ${HOME}/${TYPE_ZONE}.cmd sudo zoneadm -z ${TYPE_ZONE} install -u -a /var/tmp/default_2_0_2_93.zfs sleep 30 sudo zoneadm -z ${TYPE_ZONE} boot |
After creating the zone, you can run a script to get dependencies for building components.Create zone for get depends and get depends
For the script to work, you must have two lists:
list_component
list_components is list of componentslist_pkg_sec
list_pkg_sec for building components
Code Block |
---|
#!/bin/bash # by Vasiliy Feoktistov #This script creates a dependency file and loads them. #The first part of the script creates a file with a list of dependencies, the second part loads them. #File create for save temporary values >list_one >list_two >pkg_dep >tmp0 >tmp1 >tmp # function get_depends() { ## This function get depends for build component [ -z "$(grep -f pkg_dep <<< $1)" ] && apt-get install -s $1 2>/dev/null | grep Inst | awk '{print $2}'| sort -u && echo $pkg >> pkg_dep } # # function all_dep() { ##This recursion function for get recursion depends for build conmponents for pkg in $@; do all_dep $(get_depends $pkg) done } ## Loop for get depends for build components while read component; do apt-get --dry-run build-dep $component 2>/dev/null | grep Inst | awk '{print $2}' >> list_one done < list_component while read pkg; do apt-get install -s $pkg 2>/dev/null | grep Inst | awk '{print $2}' >> list_two done < list_pkg_sec cat list_one >> tmp0 cat list_two >> tmp0 cat list_component >> tmp0 cat list_pkg_sec >> tmp0 cat tmp0 | sort -u >> tmp1 ## Loop for get depends, use function 'all_dep' while read pkg; do all_dep $pkg >/dev/null done < tmp1 cat pkg_dep >> tmp1 cat tmp1 | sort -u >> tmp while read pkg; do sudo apt-get download $pkg done < tmp |
Create new zone for create local repository
Use this command for add *.deb pkg in repo.
Code Block |
---|
sudo reprepro -b /<path>/repo/ -C main includedeb du2-prebuild /<path>/repo/pkg/*.deb
sudo reprepro -Vb /<path>/repo/ export du2-prebuild |
Create new zone for build component
Preparing the zone for component assembly
Code Block |
---|
# by Denis Kozadaev sudo -E apt-get clean sudo -E apt-get autoclean APTLIST="/tmp/apt_sources.list" APTLISTETC="/etc/apt/sources.list" echo "" > $APTLIST echo "deb [trusted=yes] http://192.168.0.4/dilos du2-prebuild main contrib non-free" >> $APTLIST #echo "deb http://192.168.0.100/dilos dg2-unstable main contrib non-free" >> $APTLIST #echo "deb http://apt2.dilos.org/dilos dg2-unstable main contrib non-free" >> $APTLIST #echo "deb http://apt2.dilos.org/dilos du2-unstable main contrib non-free" >> $APTLIST #echo "deb http://apt2.dilos.org/dilos dilos2-unstable main contrib non-free" >> $APTLIST echo "deb-src http://apt2.dilos.org/dilos du2-unstable main contrib non-free" 2>/dev/null >> $APTLIST #echo "deb-src http://apt2.dilos.org/dilos dilos-testing main contrib non-free" 2>/dev/null >> $APTLIST sudo mv $APTLIST $APTLISTETC sudo apt-get update test -f /var/lib/dpkg/lock && sudo rm -f /var/lib/dpkg/lock test -f /var/cache/apt/archives/lock && sudo sudo rm -f /var/cache/apt/archives/lock sudo dpkg --configure -a sudo -E rm -rf ${WORKSPACE} && mkdir -p ${WORKSPACE} test -f /usr/bin/gecho || sudo -E ln -s echo /usr/bin/gecho test -f /usr/bin/gfind || sudo -E ln -s find /usr/bin/gfind sudo apt-get upgrade -y sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y -f sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y git openssh-server oracle-jdk |
Build component
These variables are registered in jenkins:
{WORKSPACE}
{COMPONENT}
{JOBS}
Code Block |
---|
#!/bin/bash
# by Denis Kozadaev
umask 022
#export CCACHE_DIR="${BUILD_RESULT}/.ccache"
#export CCACHE_SIZE="2G"
export CCACHE_DISABLE="true"
set -x
test -f /usr/bin/ild || sudo -E /usr/bin/cp /usr/bin/ld /usr/bin/ild
echo '====='
env
echo '====='
test -L /etc/dpkg/origins/default || sudo ln -fs dilos /etc/dpkg/origins/dilos
test -f /usr/bin/gmake || sudo ln -fs make /usr/bin/gmake
#test -f /usr/bin/ar || ln -s gar /usr/bin/ar
#test -f /usr/bin/nm || ln -s gnm /usr/bin/nm
echo "${COMPONENT}"
#export WS_TOP=${WORKSPACE}
cd /export/home/admin/ && git clone https://bitbucket.org/dilos/du2.git
test -d ${WORKSPACE}/components/${COMPONENT} || exit 1
export DEB_BUILD_OPTIONS="parallel= 2"
sudo -E apt-get update
#sudo apt-get install -y libssl1.0.2/du-unstable openssl/du-unstable tar/du-unstable --allow-downgrades
#sudo apt-get install -y libssl1.0.2/du-unstable openssl/du-unstable tar/du-unstable --allow-downgrades
#sudo apt-get install -y libbz2-1./du2-unstable --allow-downgrades
sudo apt-get install -y acl iputils-ping kbd ksh scheduler system-data-console-fonts traceroute gmake build-essential
#sudo apt-get install -y acl iputils-ping kbd ksh scheduler system-data-console-fonts traceroute gmake build-essential
#sudo apt-get install -y libicu-dev/du-unstable libicu57/du-unstable icu-devtools/du-unstable --allow-downgrades
DEBIAN_FRONTEND=noninteractive sudo -E apt-get install -f -y
DEBIAN_FRONTEND=noninteractive sudo -E apt-get upgrade -y
if ! getent group shadow | grep -q '^shadow:[^:]*:42'
then
sudo -E groupadd -g 42 shadow
fi
test -L /usr/lib/jvm/default-java || sudo -E /usr/bin/ln -fs oracle-default-jdk /usr/lib/jvm/default-java
sudo -E apt-get install -y libx11-6 libxi6 libxtst6
sudo -E /usr/bin/ln -fs libX11.so.6 /usr/lib/64/libX11.so.4
sudo -E /usr/bin/ln -fs libXi.so.6 /usr/lib/64/libXi.so.5
sudo -E /usr/bin/ln -fs libXtst.so.6 /usr/lib/64/libXtst.so.1
cd ${WORKSPACE}/components
#yes Y |sudo -E gmake setup
cd "${WORKSPACE}/components/${COMPONENT}"
#sudo -E gmake debclobber
#if (( $? > 0 )); then
#exit 1
#fi
#export LD_DEBUG=files,libs
sudo -E mkdir -p /data/repo/${COMPONENT}
BUILD_RESULT=/data/repo/${COMPONENT}
export COMPONENT_RESULT=`echo ${BLD_COMPONENT} | sed -e 's;/;-;'`
sudo -E /usr/bin/rm -rf ${BUILD_RESULT}/du/${COMPONENT_RESULT}
mkdir -p ${BUILD_RESULT}/du/${COMPONENT_RESULT} 2>/dev/null
#export SHELLOPTS=
sudo -E gmake JOBS=${JOBS} WS_DEBS=${BUILD_RESULT}/du/${COMPONENT_RESULT} deb
#fakeroot gmake JOBS=${JOBS} WS_DEBS=${BUILD_RESULT}/du/${COMPONENT_RESULT} deb
#| tee ${WORKSPACE}/log.${COMPONENT}.txt
RES=$?
sudo -E gmake debclobber
sudo -E apt-get install -y oracle-jdk
if (( $RES > 0 )); then
exit 1
fi |
After assembling the components, you can check it for installation in a separate new zone.