Advertisement
s243a

trim_puppy_retry.sh (v2)

Mar 29th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.41 KB | None | 0 0
  1. curdir=`pwd`
  2. s_rootfs="rootfs"
  3. alt_s_rootfs="/mnt/+mnt++root+Downloads+xslacko-slim-4.4r25.iso+puppy_xslacko_4.4.sfs"
  4. if [ -d "$alt_s_rootfs=" ]; then
  5.   retry=1 #Default action for an array
  6. fi
  7. prefix=""
  8. action="mv"
  9.  
  10. chroot_remove_builtin=0
  11. no_mount_rootfs=1
  12.  
  13. #After we remove packages we might install some replacement versions
  14. #When distro not specified in path look for pkg dirs in dir containing distro name in this order
  15. post_rm_pkg_dirs=( "pupngo" ) #Replaceing bash with pupngo's version can save a fair bit of space
  16. #When arch not specified in path look for pkg arch dir containing distro name in this order
  17. arches=( "i386" "no-arch" "i486" "i586" "i686" )
  18.  
  19.  
  20. #Applications
  21. #Let's remove these applications and maybe put them into an sfs
  22. ALL=()
  23. ALL_ArrNames=()
  24.  
  25. A_SystemCore=( "bash")
  26. ALL+=( "${A_SystemCore[@]}" )
  27. ALL_ArrNames+=( "A_SystemCore" )
  28.  
  29. curdir=`pwd`
  30. rootfs="$s_rootfs"
  31. xinteractive=1S
  32. prefix=""
  33. xinteractive=1
  34.  
  35. Post_Remove_Install_Fm_Dir=( \
  36. "i386/pupngo/bash-4.2" \
  37. )
  38.  
  39. #source pkgs_arry
  40.  
  41. #Coppies a more recent version of remove_built_in
  42. #and also a list of icu related files (to be removed) which aren't associated
  43. #with any packages
  44. pre_remove_patch="pre_remove_patch"
  45. cp --remove-destination -arf $pre_remove_patch/* \
  46.                                  $s_rootfs/ 2>/dev/null
  47. source trim_puppy_functions.sh
  48.  
  49.  
  50.  
  51.  
  52. if [ no_mount_rootfs -eq 0 ]; then
  53.   trap unmount_vfs EXIT
  54.   trap unmount_vfs SIGKILL
  55.   trap unmount_vfs SIGTERM
  56.  
  57.  
  58.   echo "PUPMODE='2'" > $curdir/$rootfs$prefix/etc/rc.d/PUPSTATE
  59.   mkdir -p $curdir/$rootfs/proc;
  60.   mkdir -p $curdir/$rootfs/sys
  61.  
  62.   mount -o rbind /proc $curdir/$rootfs/proc
  63.   mount -t sysfs none $curdir/$rootfs/sys
  64.   if [ $xinteractive -eq 1 ]; then
  65.     echo "Removing block device files..."
  66.     #rm -rf $curdir/$rootfs/dev/*
  67.     #mount bind -t devtmpfs none $curdir/$rootfs/dev
  68.     mount -o rbind /dev $curdir/$rootfs/dev
  69.     cp -f /etc/resolv.conf $curdir/$rootfs/etc/resolv.conf
  70.   fi
  71.  
  72. else
  73.   trap close_file_descriptors EXIT
  74.   trap close_file_descriptors SIGKILL
  75.   trap close_file_descriptors SIGTERM
  76. fi
  77.  
  78.  
  79.  
  80. dissect_rootfs
  81.  
  82.  
  83.  
  84.  
  85. for pkg_dir in "${Post_Remove_Install_Fm_Dir[@]}"; do
  86.   if [ "${pkg_dir:0:1}" = "." ]; then
  87.     pkg_dir="$curdir/${pkg_dir:1:}"
  88.   elif [ ! "${pkg_dir:0:1}" = "/" ]; then
  89.         rel_path=${pkg_dir%/*}
  90.         pkg_name=`basename pkg_dir`
  91.         if [ -z "$rel_path" ]; then
  92.           for pkg_arch in "${arches[@]}" "."; do
  93.             for pkg_distro in "${post_rm_pkg_dirs[@]}" "."
  94.               rel_path="$pkg_arch/$distro"
  95.               a_pkg_dir="$curdir/post_patch/$pkg_arch/$pkg_distro/$pkg_name"
  96.               if [ -d "a_pkg_dir" ] || [ -d `readlink "$a_pkg_dir"` ]; then
  97.                  pkg_dir="$a_pkg_dir"
  98.                  break 2;
  99.               fi
  100.                  
  101.             done
  102.           done
  103.         else
  104.           pkg_dir="$curdir/post_patch/$arch/pupngo/$pkg_dir/$pkg_dir"
  105.         fi
  106.   fi
  107.   inst_builtin_fm_dir "$pkg_dir"
  108. done
  109.  
  110. if [ no_mount_rootfs -eq 0 ]; then
  111.   if [ chroot_remove_builtin = 1 ];then
  112.     chroot "$s_rootfs_prefixed" remove_builtin "${ALL[@]}"
  113.   fi
  114.   if [ "$(mount | grep "$curdir/$rootfs/dev")" != "" ]; then
  115.    umount -l $curdir/$rootfs/dev
  116.   fi   
  117.  
  118.   if [ "$(mount | grep "$curdir/$rootfs/sys")" != "" ]; then
  119.    umount -l $curdir/$rootfs/sys
  120.   fi   
  121.   if [ "$(mount | grep "$curdir$rootfs/proc")" != "" ]; then
  122.    umount -l $curdir/$rootfs/proc
  123.   fi
  124. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement