Set builder to execute in docker
oginstaller/pipeline/head There was a failure building this commit
Details
oginstaller/pipeline/head There was a failure building this commit
Details
parent
bd1c61dff9
commit
8e9e671358
105
builder.sh
105
builder.sh
|
@ -16,38 +16,13 @@ DEBOOT_STRAP_URL=http://mirror.raiolanetworks.com/ubuntu/
|
|||
SUDO_PASSWD=${SUDO_PASSWD:-$(cat $PASSWD_FILE)}
|
||||
|
||||
|
||||
export PASSWD_FILE
|
||||
|
||||
## FUNCIONES
|
||||
function exec_as_sudo () {
|
||||
cat $PASSWD_FILE | sudo -S "$@"
|
||||
}
|
||||
|
||||
function exec_as_sudo_in_chroot () {
|
||||
local CHROOT=$1
|
||||
shift
|
||||
exec_as_sudo chroot $CHROOT "$@"
|
||||
}
|
||||
|
||||
function umount_in_chroot() {
|
||||
local CHROOT=$2
|
||||
local PART=$1
|
||||
if grep $CHROOT$PART /etc/mtab;
|
||||
then
|
||||
echo "Unmounting $PART in chroot $CHROOT"
|
||||
exec_as_sudo_in_chroot $CHROOT umount $PART
|
||||
return $?
|
||||
fi
|
||||
echo "Mount point $PART not found"
|
||||
return 0
|
||||
}
|
||||
|
||||
function umount_in_host() {
|
||||
local PART=$1
|
||||
if findmnt -M $PART
|
||||
then
|
||||
echo "Unmounting $PART"
|
||||
exec_as_sudo umount $PART
|
||||
chroot $CHROOT umount $PART
|
||||
return $?
|
||||
fi
|
||||
echo "Mount point $PART not found"
|
||||
|
@ -58,15 +33,15 @@ function deploy_script_in_chroot() {
|
|||
local CHROOT=$1
|
||||
local SCRIPT=$2
|
||||
local DESTDIR=$3
|
||||
exec_as_sudo mkdir -p $CHROOT/$DESTDIR
|
||||
exec_as_sudo cp $SCRIPT $CHROOT/$DESTDIR
|
||||
exec_as_sudo chmod +x $CHROOT/$DESTDIR/$SCRIPT
|
||||
mkdir -p $CHROOT/$DESTDIR
|
||||
cp $SCRIPT $CHROOT/$DESTDIR
|
||||
chmod +x $CHROOT/$DESTDIR/$SCRIPT
|
||||
}
|
||||
|
||||
function deploy_installer() {
|
||||
exec_as_sudo mkdir -p $CHROOT_DIR/usr/local/bin
|
||||
exec_as_sudo cp openGnsys-installer.sh $CHROOT_DIR/usr/local/bin
|
||||
exec_as_sudo chmod +x $CHROOT_DIR/usr/local/bin/openGnsys-installer.sh
|
||||
mkdir -p $CHROOT_DIR/usr/local/bin
|
||||
cp openGnsys-installer.sh $CHROOT_DIR/usr/local/bin
|
||||
chmod +x $CHROOT_DIR/usr/local/bin/openGnsys-installer.sh
|
||||
}
|
||||
|
||||
if [ -d $CHROOT_DIR ] && [ $CLEAN -eq 1 ];
|
||||
|
@ -80,16 +55,16 @@ then
|
|||
done
|
||||
for i in $SYS_MOUNT_POINT;
|
||||
do
|
||||
umount_in_host $CHROOT_DIR$i
|
||||
umount_in_host $UBUNTU_CHROOT_DIR$i
|
||||
umount $CHROOT_DIR$i
|
||||
umount $UBUNTU_CHROOT_DIR$i
|
||||
done
|
||||
if [ $CLEAN_CHROOT -eq 1 ];
|
||||
then
|
||||
exec_as_sudo rm -rf $CHROOT_DIR
|
||||
exec_as_sudo rm -rf $UBUNTU_CHROOT_DIR
|
||||
rm -rf $CHROOT_DIR
|
||||
rm -rf $UBUNTU_CHROOT_DIR
|
||||
fi
|
||||
exec_as_sudo rm -rf $DIR/image
|
||||
exec_as_sudo rm -f $OUTPUT_DIR/ubuntu-from-scratch.iso
|
||||
rm -rf $DIR/image
|
||||
rm -f $OUTPUT_DIR/ubuntu-from-scratch.iso
|
||||
fi
|
||||
|
||||
mkdir -p $IMAGE_DIR
|
||||
|
@ -103,65 +78,65 @@ chmod +x $CHROOT_DIR/chroot_setup.sh
|
|||
# # Deploy boot strap
|
||||
if [ $CLEAN_CHROOT -eq 1 ];
|
||||
then
|
||||
exec_as_sudo debootstrap --arch=amd64 --variant=$VARIANT $DIST $CHROOT_DIR $DEBOOT_STRAP_URL
|
||||
debootstrap --arch=amd64 --variant=$VARIANT $DIST $CHROOT_DIR $DEBOOT_STRAP_URL
|
||||
fi
|
||||
exec_as_sudo mkdir -p $CHROOT_DIR/etc/calamares/modules/
|
||||
exec_as_sudo cp calamares/settings.conf $CHROOT_DIR/etc/calamares/
|
||||
exec_as_sudo cp calamares/modules/*.conf $CHROOT_DIR/etc/calamares/modules/
|
||||
exec_as_sudo mkdir -p $CHROOT_DIR/usr/share/opengnsys/images
|
||||
exec_as_sudo cp art/* $CHROOT_DIR/usr/share/opengnsys/images/
|
||||
mkdir -p $CHROOT_DIR/etc/calamares/modules/
|
||||
cp calamares/settings.conf $CHROOT_DIR/etc/calamares/
|
||||
cp calamares/modules/*.conf $CHROOT_DIR/etc/calamares/modules/
|
||||
mkdir -p $CHROOT_DIR/usr/share/opengnsys/images
|
||||
cp art/* $CHROOT_DIR/usr/share/opengnsys/images/
|
||||
deploy_script_in_chroot $CHROOT_DIR openGnsys-installer.sh /usr/local/bin/
|
||||
|
||||
# # Create mount points
|
||||
exec_as_sudo mount --bind /dev/ $CHROOT_DIR/dev
|
||||
exec_as_sudo mount --bind /run/ $CHROOT_DIR/run
|
||||
mount --bind /dev/ $CHROOT_DIR/dev
|
||||
mount --bind /run/ $CHROOT_DIR/run
|
||||
|
||||
|
||||
# Execute chroot_setup.sh
|
||||
exec_as_sudo_in_chroot $CHROOT_DIR /chroot_setup.sh
|
||||
exec_as_sudo cp conf/pcmanfm.conf $CHROOT_DIR/etc/xdg/pcmanfm/default/pcmanfm.conf
|
||||
chroot $CHROOT_DIR /chroot_setup.sh
|
||||
cp conf/pcmanfm.conf $CHROOT_DIR/etc/xdg/pcmanfm/default/pcmanfm.conf
|
||||
|
||||
# Clean up the environment
|
||||
umount_in_host $CHROOT_DIR/dev
|
||||
umount_in_host $CHROOT_DIR/run
|
||||
umount $CHROOT_DIR/dev
|
||||
umount $CHROOT_DIR/run
|
||||
|
||||
# Compress the chroot deploy
|
||||
mkdir -p $IMAGE_DIR
|
||||
exec_as_sudo mv $CHROOT_DIR/image $DIR/
|
||||
mv $CHROOT_DIR/image $DIR/
|
||||
|
||||
|
||||
# Create squashfs imagesudo
|
||||
exec_as_sudo mksquashfs $CHROOT_DIR $IMAGE_DIR/casper/filesystem.squashfs \
|
||||
mksquashfs $CHROOT_DIR $IMAGE_DIR/casper/filesystem.squashfs \
|
||||
-noappend -no-duplicates -no-recovery \
|
||||
-wildcards \
|
||||
-comp xz -b 1M -Xdict-size 100% \
|
||||
-e "var/cache/apt/archives/*" -e "root/*" -e "root/.*" -e "tmp/*" -e "tmp/.*" -e "swapfile"
|
||||
|
||||
printf $(exec_as_sudo du -sx --block-size=1 $CHROOT_DIR | cut -f1) | sudo tee $IMAGE_DIR/casper/filesystem.size
|
||||
printf $(du -sx --block-size=1 $CHROOT_DIR | cut -f1) | sudo tee $IMAGE_DIR/casper/filesystem.size
|
||||
|
||||
# Deboot strap real Ubuntu image
|
||||
exec_as_sudo debootstrap --arch=amd64 --variant=minbase noble $UBUNTU_CHROOT_DIR $DEBOOT_STRAP_URL
|
||||
exec_as_sudo cp setup_chroot_ubuntu.sh $UBUNTU_CHROOT_DIR
|
||||
exec_as_sudo_in_chroot $UBUNTU_CHROOT_DIR chmod +x /setup_chroot_ubuntu.sh
|
||||
exec_as_sudo cp buildlib.sh $UBUNTU_CHROOT_DIR
|
||||
debootstrap --arch=amd64 --variant=minbase noble $UBUNTU_CHROOT_DIR $DEBOOT_STRAP_URL
|
||||
cp setup_chroot_ubuntu.sh $UBUNTU_CHROOT_DIR
|
||||
in_chroot $UBUNTU_CHROOT_DIR chmod +x /setup_chroot_ubuntu.sh
|
||||
cp buildlib.sh $UBUNTU_CHROOT_DIR
|
||||
deploy_script_in_chroot $UBUNTU_CHROOT_DIR component-installer.sh /opengnsys-installer/
|
||||
exec_as_sudo cp pat.txt $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
||||
cp pat.txt $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
||||
|
||||
|
||||
# Setup the chroot for ubuntu
|
||||
exec_as_sudo mount --bind /dev/ $UBUNTU_CHROOT_DIR/dev
|
||||
exec_as_sudo mount --bind /run/ $UBUNTU_CHROOT_DIR/run
|
||||
mount --bind /dev/ $UBUNTU_CHROOT_DIR/dev
|
||||
mount --bind /run/ $UBUNTU_CHROOT_DIR/run
|
||||
|
||||
exec_as_sudo_in_chroot $UBUNTU_CHROOT_DIR /setup_chroot_ubuntu.sh
|
||||
chroot $UBUNTU_CHROOT_DIR /setup_chroot_ubuntu.sh
|
||||
|
||||
|
||||
# Clean up the environment
|
||||
umount_in_host $UBUNTU_CHROOT_DIR/dev
|
||||
umount_in_host $UBUNTU_CHROOT_DIR/run
|
||||
umount $UBUNTU_CHROOT_DIR/dev
|
||||
umount $UBUNTU_CHROOT_DIR/run
|
||||
|
||||
|
||||
# Compress the ububtu chroot
|
||||
exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR $IMAGE_DIR/casper/filesystem.ubuntu.sqfs \
|
||||
mksquashfs $UBUNTU_CHROOT_DIR $IMAGE_DIR/casper/filesystem.ubuntu.sqfs \
|
||||
-noappend -no-duplicates -no-recovery \
|
||||
-wildcards \
|
||||
-comp xz -b 1M -Xdict-size 100% \
|
||||
|
@ -169,7 +144,7 @@ exec_as_sudo mksquashfs $UBUNTU_CHROOT_DIR $IMAGE_DIR/casper/filesystem.ubuntu.s
|
|||
|
||||
# Create ISO image
|
||||
cd $IMAGE_DIR && \
|
||||
exec_as_sudo xorriso \
|
||||
xorriso \
|
||||
-as mkisofs \
|
||||
-iso-level 3 \
|
||||
-full-iso9660-filenames \
|
||||
|
|
Loading…
Reference in New Issue