From 8e85a81b468acae538fe8102edc811030ba381ce Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 27 Jun 2015 18:36:03 +0100 Subject: make buildbot script arch agnostic, add overlays && buildsystem on the fly --- buildbot | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 137 insertions(+), 31 deletions(-) diff --git a/buildbot b/buildbot index acec382..ebddc6e 100755 --- a/buildbot +++ b/buildbot @@ -3,34 +3,85 @@ # Script to build Kogaion Linux packages in a clean squashfs + overlayfs chroot # Using predefined targets : kernel.target, libs.target, x11.target, sound.target, artwork.target etc # Targets are passed as arguments, and will remain private...for now (not all of them are stable yet) -# Author : V3n3RiX @ RogentOS -# Deps : squashfs + overlayfs kernel support -# Todo : add squashfs portage tree && overlays sync && build.git sync && profile setup -# Todo : auto push built packages to repos (maybe, really needed?!?) +# Author : V3n3RiX @ RogentOS +# Dependencies : squashfs + overlayfs kernel support -export local sqfsroot="kogaiondevelx64.squashfs" -export local sqfsroothash="fb2afc5f3b387412a0954f242df54927" + +# env mount variables export local rodir="rodir" export local rwdir="rwdir" export local overlaydir="overlaydir" -export local envuser="root" -export local envtargets="$@" -export local envbuildcmd="emerge -av "$envtargets"" +# env user variable +export local envkogaionuser="root" -envintegrity() { - # check if our squashfs chroot somehow got corrupted, abort if so - while : true ; do - if [[ "$(md5sum "$sqfsroot" | awk {'print $1'})" = "$sqfsroothash" ]]; then - break +# env target variable (can be a single package, multiple packages, or a target file passed as parameter) +export local envkogaiontarget="$@" +export local envkogaionbuildtarget="emerge -av "$envkogaiontarget"" + +# env buildsystem variables +export local envkogaionportageconfig="ln -sf /opt/build/conf/intel/portage /etc/portage" +export local envkogaionbuildgit="cd /opt && git clone https://github.com/Rogentos/build.git" +export local envkogaionoverlay="layman -f -a kogaion -o https://raw.github.com/Rogentos/kogaion/master/overlay.xml" +export local envkogaiondesktopoverlay="layman -f -a kogaion-desktop -o https://raw.github.com/Rogentos/kogaion-desktop/master/overlay.xml" + + +envkogaionsquashfsroot () { + # our bare metal buildserver is x86_64 but we want to build 32bit packages as well + # run this script with linux32 to fool it we run i686 and to build 32bit packages + if [[ "$(uname -m)" = "x86_64" ]] ; then + if [[ -f "kogaiondevelx64.squashfs" ]] ; then + echo "Good, x86_64 squashed chroot FOUND ... verifying checksum" + echo "" + sleep 1 + export local sqfsroot="kogaiondevelx64.squashfs" + export local sqfsroothash="812028d126ee5774845942b1f9e41dbf" # if YOU changed squashed chroot on purpose, modify this + else + echo "Ooops, x86_64 squashed chroot NOT FOUND ... aborting" + exit 1 + fi + elif [[ "$(uname -m)" = "i686" ]] ; then + if [[ -f "kogaiondevelx86.squashfs" ]] ; then + echo "Good, i686 squashed chroot FOUND ... verifying checksum" + echo "" + sleep 1 + export local sqfsroot="kogaiondevelx86.squashfs" + export local sqfsroothash="insert checksum in here" # if YOU changed squashed chroot on purpose, modify this else + echo "Ooops, i686 squashed chroot NOT FOUND ... aborting" exit 1 fi + fi +} + +envkogaionsquashfsintegrity() { + # verify squashfs root integrity, abort if not correct + while : true ; do + if [[ "$(uname -m)" = "x86_64" ]] ; then + if [[ "$(md5sum "$sqfsroot" | awk {'print $1'})" = "$sqfsroothash" ]] ; then + echo "Good, x86_64 squashed chroot checksum PASSED ... starting environment" + echo "" + sleep 1 + break + else + echo "Ooops, x86_64 squashed chroot checksum FAILED ... aborting" + exit 1 + fi + elif [[ "$(uname -m)" = "i686" ]] ; then + if [[ "$(md5sum "$sqfsroot" | awk {'print $1'})" = "$sqfsroothash" ]] ; then + echo "Good, i686 squashed chroot checksum PASSED ... starting environment" + echo "" + sleep 1 + break + else + echo "Ooops, i686 squashed chroot checksum FAILED ... aborting" + fi + fi done } -envstart () { - # mount ro squashfs + add rw overlayfs layer to enable clean package building +envkogaionstart () { + # mount ro squashfs chroot + add rw overlayfs layer to enable clean package building mount -t squashfs "$sqfsroot" "$rodir" mount -t overlayfs -o lowerdir="$rodir",upperdir="$rwdir" overlayfs "$overlaydir" mount -o bind /proc "$overlaydir"/proc @@ -41,7 +92,7 @@ envstart () { mount -o bind /tmp "$overlaydir"/tmp } -envstop () { +envkogaionstop () { # umount squashfs + overlayfs chroot umount -l "$overlaydir"/proc umount -l "$overlaydir"/sys @@ -53,12 +104,22 @@ envstop () { umount -l "$rodir" } -envbuild () { +envkogaionbuild () { # build packages in squashfs + overlayfs chroot - chroot "$overlaydir" su - "$envuser" -c "$envbuildcmd" + if [[ "$(uname -m)" = "x86_64" ]] ; then + echo "" + echo "Environment is UP && RUNNING ... building targets" + sleep 1 + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionbuildtarget" + elif [[ "$(uname -m)" = "i686" ]] ; then + echo "" + echo "Environment is UP && RUNNING ... building targets" + sleep 1 + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionbuildtarget" + fi } -envchroot() { +envkogaionchroot() { # enter squashfs + overlayfs chroot to push packages, or debug build errors echo -e "" echo -e "#################################################################" @@ -75,22 +136,65 @@ envchroot() { echo -e "#################################################################" echo -e "" echo -e "" - chroot "$overlaydir" su - "$envuser" + if [[ "$(uname -m)" = "x86_64" ]] ; then + chroot "$overlaydir" su - "$envkogaionuser" + elif [[ "$(uname -m)" = "i686" ]] ; then + linux32 chroot "$overlaydir" su - "$envkogaionuser" + fi +} + +envkogaionbuildsystem() { + # since squashed chroot is barebones, we need to set it up + # add our overlays && set up our buildsystem + if [[ "$(uname -m)" = "x86_64" ]] ; then + export local envkogaionmakeconf="ln -sf /opt/build/conf/intel/portage/make.conf.amd64 /etc/portage/make.conf" + export local envkogaionprofile="eselect profile set 1" + echo "Adding Kogaion Linux Main Overlay" + sleep 1 + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionoverlay" + echo "Adding Kogaion Linux Desktop Overlay" + sleep 1 + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaiondesktopoverlay" + echo "Adding Kogaion Linux X86_64 Buildsystem && Setting up Portage && Setting up make.conf" + echo "" + sleep 1 + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionbuildgit" + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionportageconfig" + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionmakeconf" + chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionprofile" + elif [[ "$(uname -m)" = "i686" ]] ; then + export local envkogaionmakeconf="ln -sf /opt/build/conf/intel/portage/make.conf.x86 /etc/portage/make.conf" + export local envkogaionprofile="eselect profile set 1" + echo "Adding Kogaion Linux Main Overlay" + sleep 1 + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionoverlay" + echo "Adding Kogaion Linux Desktop Overlay" + sleep 1 + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaiondesktopoverlay" + echo "Adding Kogaion Linux i686 Buildsystem && Setting up Portage && Setting up make.conf" + echo "" + sleep 1 + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionbuildgit" + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionportageconfig" + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionmakeconf" + linux32 chroot "$overlaydir" su - "$envkogaionuser" -c "$envkogaionprofile" + fi + } -envprepare () { - # first let's check our environment for sanity +envkogaionprepare () { + # check our environment for sanity # if safe, trigger start && break the loop to build packages # else trigger stop && cleanup && check again while : true ; do - if [[ ! -d "$rodir" && ! -d "$rwdir" && ! -d "$overlaydir" ]]; then + if [[ ! -d "$rodir" && ! -d "$rwdir" && ! -d "$overlaydir" ]] ; then for i in "$rodir" "$rwdir" "$overlaydir" ; do mkdir "$i" done - envstart + envkogaionstart break - elif [[ -d "$overlaydir" && -f "$overlaydir/usr/bin/emerge" ]] ; then - envstop + elif [[ -d "$rodir" && -d "$rwdir" && -d "$overlaydir" ]] ; then + envkogaionstop for i in "$rodir" "$rwdir" "$overlaydir" ; do rm -rf "$i" done @@ -100,10 +204,12 @@ envprepare () { } main () { - envintegrity - envprepare - envbuild - envchroot + envkogaionsquashfsroot + envkogaionsquashfsintegrity + envkogaionprepare + envkogaionbuildsystem + envkogaionbuild + envkogaionchroot } main -- cgit v1.2.3