Advertisement
siewdass

builder

Jan 2nd, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.89 KB | None | 0 0
  1. #!/bin/bash
  2. #apt install dos2unix && dos2unix builder.sh
  3. #dep: rsync, squashfs-tools, genisoimage, xserver-xephyr
  4.  
  5. workPath=/home
  6. linuxBase=/home/dev/distro.iso
  7. resolutionXephyr=1000x600
  8. linuxName="Nebulosa Linux"
  9. isoName=nebulosa-live-64bit
  10. logPath=/home/dev
  11.  
  12. echo -n "# Creating workspace..."
  13. mkdir $workPath/base $workPath/nebulosa
  14.     echo -e "                 [ \e[0;32mOK\e[0m ]"
  15.  
  16. echo -n "# Mounting ISO..."
  17. mount -o loop $linuxBase $workPath/base
  18.     echo -e "                         [ \e[0;32mOK\e[0m ]"
  19.  
  20. echo -n "# Uncompressing SQUASHFS..."
  21. unsquashfs -p 3 -f -d $workPath/squashfs $workPath/base/casper/filesystem.squashfs
  22. #mv $workPath/squashfs-root $workPath/squashfs
  23.     echo -e "                      [ \e[0;32mOK\e[0m ]"
  24.  
  25. echo -n "# Mounting CHROOT..."
  26. mount --bind /dev $workPath/squashfs/dev
  27. mount -o bind /var/lib/dbus $workPath/squashfs/var/lib/dbus
  28.     echo -e "                      [ \e[0;32mOK\e[0m ]"
  29.  
  30. echo -n "# Copying host needed files..."
  31. cp /etc/hosts $workPath/squashfs/etc/hosts
  32. cp /etc/resolv.conf $workPath/squashfs/etc/resolv.conf
  33. cp /etc/apt/sources.list $workPath/squashfs/etc/apt/sources.list
  34.     echo -e "            [ \e[0;32mOK\e[0m ]"
  35.  
  36. echo -n "# Starting Xephyr..." 
  37. Xephyr -ac -screen $resolutionXephyr :1 &
  38.     echo -e "                     [ \e[0;32mOK\e[0m ]"
  39.  
  40. echo -n "# Accessing CHROOT..."
  41.     echo -e "                     [ \e[0;32mOK\e[0m ]"
  42. #echo -n
  43. chroot squashfs
  44.  
  45. echo -n "# Synchronizing files..."
  46. rsync -avz --exclude=casper/filesystem.squashfs --exclude=md5sum.txt $workPath/base/* $workPath/nebulosa/
  47.     echo -e "            [ \e[0;32mOK\e[0m ]"
  48.  
  49. echo -n "# Unmounting ISO..."
  50. umount $workPath/base
  51.     echo -e "                      [ \e[0;32mOK\e[0m ]"
  52.  
  53. echo -n "# Unmounting CHROOT..."
  54. umount $workPath/squashfs/dev
  55. umount $workPath/squashfs/var/lib/dbus
  56.     echo -e "                      [ \e[0;32mOK\e[0m ]"
  57.    
  58. echo -n "# Compressing SQUASHFS..."
  59. mksquashfs $workPath/squashfs nebulosa/casper/filesystem.squashfs
  60.     echo -e "                 [ \e[0;32mOK\e[0m ]"
  61.  
  62. echo -n "# Copying needed files..."
  63. cp $workPath/squashfs/vmlinuz-**-** $workPath/nebulosa/casper/vmlinuz
  64. cp $workPath/squashfs/initrd.img-**-*** $workPath/nebulosa/casper/initrd.img
  65.     echo -e "            [ \e[0;32mOK\e[0m ]"
  66.  
  67. echo -n "# Recalculating MD5 sums..."
  68. cd $workPath/nebulosa >> $logPath/builder.log 2>&1
  69. find . -type f -print0 | xargs -0 md5sum | grep -v "./md5sum.txt" > md5sum.txt
  70.     echo -e "               [ \e[0;32mOK\e[0m ]"
  71.  
  72. echo -n "# Generating ISO..."
  73. 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 .
  74.     echo -e "                       [ \e[0;32mOK\e[0m ]"
  75.  
  76. echo -n "# Cleaning workspace..."
  77. cd
  78. rm -r $workPath/base $workPath/nebulosa $workPath/squashfs
  79.     echo -e "                             [ \e[0;32mOK\e[0m ]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement