146 lines
4.7 KiB
Bash
146 lines
4.7 KiB
Bash
#!/usr/bin/bash
|
|
|
|
set -x
|
|
set -e
|
|
DIR=/ubuntu_scratch
|
|
CHROOT_DIR=$DIR/chroot
|
|
UBUNTU_CHROOT_DIR=$DIR/ubuntu_chroot
|
|
DIST=noble
|
|
VARIANT=minbase
|
|
CLEAN=${CLEAN:-1}
|
|
CLEAN_CHROOT=${CLEAN_CHROOT:-1}
|
|
OUTPUT_DIR=/installer
|
|
IMAGE_DIR=$DIR/image
|
|
DEBOOT_STRAP_URL=http://mirror.raiolanetworks.com/ubuntu/
|
|
|
|
mkdir -p $IMAGE_DIR
|
|
mkdir -p $CHROOT_DIR
|
|
# # Copio el script chroot_setup.sh al directorio chroot
|
|
cp chroot_setup.sh $CHROOT_DIR
|
|
cp buildlib.sh $CHROOT_DIR
|
|
cp root_passwd $CHROOT_DIR
|
|
chmod +x $CHROOT_DIR/chroot_setup.sh
|
|
|
|
# # Deploy boot strap
|
|
if [ $CLEAN_CHROOT -eq 1 ];
|
|
then
|
|
debootstrap --arch=amd64 --variant=$VARIANT $DIST $CHROOT_DIR $DEBOOT_STRAP_URL
|
|
fi
|
|
|
|
mkdir -p $CHROOT_DIR/usr/share/calamares/branding/
|
|
mkdir -p $CHROOT_DIR/etc/calamares/modules/
|
|
cp calamares/settings.conf $CHROOT_DIR/etc/calamares/
|
|
cp calamares/modules/*.conf $CHROOT_DIR/etc/calamares/modules/
|
|
cp -r calamares/src/branding/opengnsys $CHROOT_DIR/usr/share/calamares/branding/
|
|
chmod 755 $CHROOT_DIR/usr/share/calamares/branding/opengnsys
|
|
chmod 644 $CHROOT_DIR/usr/share/calamares/branding/opengnsys/*
|
|
chmod 755 $CHROOT_DIR/usr/share/calamares/branding/opengnsys/lang
|
|
chmod 644 $CHROOT_DIR/usr/share/calamares/branding/opengnsys/lang/*
|
|
mkdir -p $CHROOT_DIR/usr/share/opengnsys/images
|
|
cp art/* $CHROOT_DIR/usr/share/opengnsys/images/
|
|
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
|
|
|
|
|
|
# # Create mount points
|
|
mount --bind /dev/ $CHROOT_DIR/dev
|
|
mount --bind /run/ $CHROOT_DIR/run
|
|
|
|
|
|
# Execute chroot_setup.sh
|
|
chroot $CHROOT_DIR /chroot_setup.sh
|
|
cp conf/pcmanfm.conf $CHROOT_DIR/etc/xdg/pcmanfm/default/pcmanfm.conf
|
|
|
|
# Clean up the environment
|
|
umount $CHROOT_DIR/dev
|
|
umount $CHROOT_DIR/run
|
|
|
|
# Compress the chroot deploy
|
|
mkdir -p $IMAGE_DIR
|
|
mv $CHROOT_DIR/image $DIR/
|
|
|
|
|
|
# Create squashfs imagesudo
|
|
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 $(du -sx --block-size=1 $CHROOT_DIR | cut -f1) | tee $IMAGE_DIR/casper/filesystem.size
|
|
|
|
# Deboot strap real Ubuntu image
|
|
debootstrap --arch=amd64 --variant=minbase noble $UBUNTU_CHROOT_DIR $DEBOOT_STRAP_URL
|
|
rm -f $UBUNTU_CHROOT_DIR/etc/resolv.conf
|
|
echo 'nameserver 8.8.8.8' >$UBUNTU_CHROOT_DIR/etc/resolv.conf
|
|
cp setup_chroot_ubuntu.sh $UBUNTU_CHROOT_DIR
|
|
chroot $UBUNTU_CHROOT_DIR chmod +x /setup_chroot_ubuntu.sh
|
|
cp buildlib.sh $UBUNTU_CHROOT_DIR
|
|
mkdir -p $UBUNTU_CHROOT_DIR/opengnsys-installer
|
|
cp component-installer.sh $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
|
chmod +x $UBUNTU_CHROOT_DIR/opengnsys-installer/component-installer.sh
|
|
cp provision_ogcore.sh $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
|
chmod +x $UBUNTU_CHROOT_DIR/opengnsys-installer/provision_ogcore.sh
|
|
cp provision_oggui.sh $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
|
chmod +x $UBUNTU_CHROOT_DIR/opengnsys-installer/provision_oggui.sh
|
|
cp pat.txt $UBUNTU_CHROOT_DIR/opengnsys-installer/
|
|
|
|
|
|
# Setup the chroot for ubuntu
|
|
mount --bind /dev/ $UBUNTU_CHROOT_DIR/dev
|
|
mount --bind /run/ $UBUNTU_CHROOT_DIR/run
|
|
|
|
chroot $UBUNTU_CHROOT_DIR /setup_chroot_ubuntu.sh
|
|
|
|
|
|
# Clean up the environment
|
|
umount $UBUNTU_CHROOT_DIR/dev
|
|
umount $UBUNTU_CHROOT_DIR/run
|
|
|
|
|
|
# Compress the ububtu chroot
|
|
mksquashfs $UBUNTU_CHROOT_DIR $IMAGE_DIR/casper/filesystem.ubuntu.sqfs \
|
|
-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"
|
|
|
|
# Create ISO imageq
|
|
cd $IMAGE_DIR && \
|
|
xorriso \
|
|
-as mkisofs \
|
|
-iso-level 3 \
|
|
-full-iso9660-filenames \
|
|
-J -joliet-long \
|
|
-volid "Ubuntu_scratch" \
|
|
-output $OUTPUT_DIR/ubuntu-from-scratch.iso \
|
|
-eltorito-boot isolinux/bios.img \
|
|
-no-emul-boot \
|
|
-boot-load-size 4 \
|
|
-boot-info-table \
|
|
--eltorito-catalog boot.catalog \
|
|
--grub2-boot-info \
|
|
--grub2-mbr ../chroot/usr/lib/grub/i386-pc/boot_hybrid.img \
|
|
-partition_offset 16 \
|
|
--mbr-force-bootable \
|
|
-eltorito-alt-boot \
|
|
-no-emul-boot \
|
|
-e isolinux/efiboot.img \
|
|
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b isolinux/efiboot.img \
|
|
-appended_part_as_gpt \
|
|
-iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
|
|
-m "isolinux/efiboot.img" \
|
|
-m "isolinux/bios.img" \
|
|
-e '--interval:appended_partition_2:::' \
|
|
-exclude isolinux \
|
|
-graft-points \
|
|
"/EFI/boot/bootx64.efi=isolinux/bootx64.efi" \
|
|
"/EFI/boot/mmx64.efi=isolinux/mmx64.efi" \
|
|
"/EFI/boot/grubx64.efi=isolinux/grubx64.efi" \
|
|
"/EFI/ubuntu/grub.cfg=isolinux/grub.cfg" \
|
|
"/isolinux/bios.img=isolinux/bios.img" \
|
|
"/isolinux/efiboot.img=isolinux/efiboot.img" \
|
|
"."
|
|
cd -
|