Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #apt install dos2unix && dos2unix builder.sh
- #dep: rsync, squashfs-tools, genisoimage, xserver-xephyr
- workPath=/home
- linuxBase=/home/dev/distro.iso
- resolutionXephyr=1000x600
- linuxName="Nebulosa Linux"
- isoName=nebulosa-live-64bit
- logPath=/home/dev
- echo -n "# Creating workspace..."
- mkdir $workPath/base $workPath/nebulosa
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Mounting ISO..."
- mount -o loop $linuxBase $workPath/base
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Uncompressing SQUASHFS..."
- unsquashfs -p 3 -f -d $workPath/squashfs $workPath/base/casper/filesystem.squashfs
- #mv $workPath/squashfs-root $workPath/squashfs
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Mounting CHROOT..."
- mount --bind /dev $workPath/squashfs/dev
- mount -o bind /var/lib/dbus $workPath/squashfs/var/lib/dbus
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Copying host needed files..."
- cp /etc/hosts $workPath/squashfs/etc/hosts
- cp /etc/resolv.conf $workPath/squashfs/etc/resolv.conf
- cp /etc/apt/sources.list $workPath/squashfs/etc/apt/sources.list
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Starting Xephyr..."
- Xephyr -ac -screen $resolutionXephyr :1 &
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Accessing CHROOT..."
- echo -e " [ \e[0;32mOK\e[0m ]"
- #echo -n
- chroot squashfs
- echo -n "# Synchronizing files..."
- rsync -avz --exclude=casper/filesystem.squashfs --exclude=md5sum.txt $workPath/base/* $workPath/nebulosa/
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Unmounting ISO..."
- umount $workPath/base
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Unmounting CHROOT..."
- umount $workPath/squashfs/dev
- umount $workPath/squashfs/var/lib/dbus
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Compressing SQUASHFS..."
- mksquashfs $workPath/squashfs nebulosa/casper/filesystem.squashfs
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Copying needed files..."
- cp $workPath/squashfs/vmlinuz-**-** $workPath/nebulosa/casper/vmlinuz
- cp $workPath/squashfs/initrd.img-**-*** $workPath/nebulosa/casper/initrd.img
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Recalculating MD5 sums..."
- cd $workPath/nebulosa >> $logPath/builder.log 2>&1
- find . -type f -print0 | xargs -0 md5sum | grep -v "./md5sum.txt" > md5sum.txt
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Generating ISO..."
- genisoimage -r -V $linuxName -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o $workPath/$isoName.iso -input-charset utf-8 .
- echo -e " [ \e[0;32mOK\e[0m ]"
- echo -n "# Cleaning workspace..."
- cd
- rm -r $workPath/base $workPath/nebulosa $workPath/squashfs
- echo -e " [ \e[0;32mOK\e[0m ]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement