The algorithm of actions for the local assembly of the component
Actions
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
Create new vm and update:
Create new vm in vmware/virtualbox/kvm
Create new default zone
To automate the creation of a zone, you can use this script in Jenkins:
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} clone default
sleep 30
sudo zoneadm -z ${TYPE_ZONE} boot
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
#!/bin/bash
#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.
sudo reprepro -b /<path>/repo/ -C main includedeb du2-prebuild /<path>/repo/pkg/*.deb
sudo reprepro -Vb /<path>/repo/ export du2-prebuild
Sample repository configuration
Create new zone for build component
Preparing the zone for component assembly
collect src for local repo
Build component
These variables are registered in jenkins:
{WORKSPACE}
{COMPONENT}
{JOBS}
After assembling the components, you can check it for installation in a separate new zone.