Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curdir=`pwd`
- s_rootfs="rootfs"
- prefix=""
- action="move"
- #Let's remove these applications and maybe put them into an sfs
- A=( "leafpad" "solitaire-minesweeper-1.3-i486"
- "gtkhash-0.6.0-i686-up" "leafpad" "MPlayer" "clipit" "geany" "get_java" \
- "getflash" "get_libreoffice" "gnome-mplayer" "pfind" )
- #Let's remove this desktop related stuff and move it into a different sfs
- B=( "desk_icon_theme_blue_moon_Slacko" "desk_icon_theme_stardust" \
- "desk_icon_theme_zabuton" "desktop-file-utils" "gnome-menus" )
- #!/bin/sh
- curdir=`pwd`
- rootfs="$s_rootfs"
- xinteractive =1
- unmount_vfs(){
- umount -l $curdir/$rootfs/dev 2>/dev/null
- umount -l $curdir/$rootfs/sys 2>/dev/null
- umount -l $curdir/$rootfs/proc 2>/dev/null
- #umount /mnt/wktaz 2>/dev/null
- #umount /mnt/wksfs 2>/dev/null
- }
- trap unmount_vfs EXIT
- trap unmount_vfs SIGKILL
- trap unmount_vfs SIGTERM
- xinteractive=1
- echo "PUPMODE='2'" > $curdir/$rootfs$prefix/etc/rc.d/PUPSTATE
- mkdir -p $curdir/$rootfs/proc;
- mkdir -p $curdir/$rootfs/sys
- mount -o rbind /proc $curdir/$rootfs/proc
- mount -t sysfs none $curdir/$rootfs/sys
- if [ $xinteractive -eq 1 ]; then
- echo "Removing block device files..."
- #rm -rf $curdir/$rootfs/dev/*
- #mount bind -t devtmpfs none $curdir/$rootfs/dev
- mount -o rbind /dev $curdir/$rootfs/dev
- cp -f /etc/resolv.conf $curdir/$rootfs/etc/resolv.conf
- fi
- copy_built_in(){
- set -x
- file_list="$curdir/$s_rootfs/root/.packages/builtin_files/$1"
- echo "file_list=$file_list"
- mkdir -p /tmp/trim_puppy
- exec 10<> /tmp/trim_puppy/fd_9
- subdir="/"
- while IFS=$'\n' read -r -d $'\n' -u10 line ; do
- line=`echo "$line" | tr -d '[:space:]'`
- if [ ! "${line:0:1}" = "/" ]; then
- line=$subdir$line
- fi
- if [ "${target:0:1}" = "/" ]; then
- target_prefixed="$target$line"
- target_root="$target"
- else
- target_root="$curdir/$target"
- target_prefixed="$curdir/$target$line"
- fi
- if [ "${s_rootfs:0:1}" = "/" ]; then
- source_prefixed="$s_rootfs$line"
- cd "$s_rootfs" #this is necessary for the cpio command below
- else
- source_prefixed="$curdir/$s_rootfs$line"
- cd "$curdir/$s_rootfs" #this is necessary for the cpio command below
- fi
- if [ -d "$source_prefixed" ]; then
- subdir="$line"
- echo ".$line" | cpio -pd "$target_root"
- subdir=${subdir%/}/
- else
- target_dir=`dirname $target_prefixed`
- if [ ! -d "$target_dir" ]; then
- source_dir=`dirname $line`
- echo ".$source_dir" | cpio -pd "$target_root"
- fi
- cp -a -u "$source_prefixed" "$target_prefixed"
- fi
- done 10< <( cat "$file_list" )
- exec 10>&-
- set +x
- }
- #copy_built_in(){
- # #file_list="$curdir/$s_rootfs/root/.packages/builtin_files/$1"
- # mkdir -p /tmp/trim_puppy
- # exec 10<> /tmp/trim_puppy/fd_9
- # while IFS=$'\n' read -r -d $'\n' -u10 line ; do
- # if [ -d "$line" ]; then
- # cd "$s_rootfs/$line"
- # echo "$s_rootfs/$line" | cpio -pd "$target/$line"
- # else
- # if [ "${line:0:1}" -eq "/" ]; then
- # cp -a -u "$s_rootfs/$line" "$target$line" #http://www.lostsaloon.com/technology/how-to-copy-directory-structure-without-the-files-in-linux/
- # else
- # cp -a -u "$line" "$target/$line"
- # fi
- # fi
- # done 10< <( cat "$file_list" | tr -d '[:space:]' )
- # exec 10>&-
- #}
- for arr_name in A B; do
- eval "arr=( \"\${"$arr_name"[@]}\" )"
- arr_action=`$"$arr_name"_action`
- #Move is faster but perhaps copy is safer
- arr_action=${arr_action:-cp}
- set -x
- eval 'target="$'$arr_name'_target"'
- target=${target:-"$curdir/$arr_name"}
- set +x
- if [ "${s_rootfs:0:1}" = "/" ]; then
- s_rootfs_prefixed="$s_rootfs"
- else
- s_rootfs_prefixed="$curdir/$s_rootfs"
- fi
- for app in "${arr[@]}"; do
- echo "arr_action=$arr_action"
- case "$arr_action" in
- cp)
- echo "app=$app"
- copy_built_in "$app"
- ;;
- #mv)
- # move_built_in()
- #;;
- #pet) #We might also want to convert to other package formats
- # mk_pet_fm_built_in()
- #;;
- esac
- chroot "$s_rootfs_prefixed" remove_builtin "$app"
- done
- done
- if [ "$(mount | grep "$curdir/$rootfs/dev")" != "" ]; then
- umount -l $curdir/$rootfs/dev
- fi
- if [ "$(mount | grep "$curdir/$rootfs/sys")" != "" ]; then
- umount -l $curdir/$rootfs/sys
- fi
- if [ "$(mount | grep "$curdir$rootfs/proc")" != "" ]; then
- umount -l $curdir/$rootfs/proc
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement