Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ROOT=/initrd/mnt/dev_save/precise/light/5.7.2/precisesave-basic
- target_root=/initrd/mnt/dev_save/precise/light/5.7.2/precisesave
- DEFAULT_POLICY="exclude_by_blacklist"
- cd $ROOT
- # https://linux.die.net/man/1/cpio
- #-u, --unconditional'
- #Replace all files, without asking whether to replace existing newer files with older files.
- #'-m, --preserve-modification-time'
- #Retain previous file modification times when creating files.
- #'-0, --null'
- #Read a list of filenames terminated by a null character, instead of a newline, so that files whose names contain newlines can be archived. GNU find is one way to produce a list of null-terminated filenames. This option may be used in copy-out and copy-pass modes.
- #'-d, --make-directories'
- #Create leading directories where needed.
- #'-p, --pass-through'
- #Run in copy-pass mode. see 'Copy-pass mode'.
- DIRS_INCLUDE_ALL=("/etc" "/initrd" "/lib" "/mnt" "/root" "/usr" "/var")
- FILES_INCLUDE=("/.wh..wh.orph" "/.wh..wh.aufs" "/.DirIcon" "/tmp")
- declare -A DIRS_INCLUDE_ALL
- declare -A DIR_CONTENTS_NAME
- declare -A PATH_INCLUDE
- declare -A PATH_NAME
- for prefix in '' '.'; do
- for a_dir in ${DIRS_INCLUDE_ALL[@]}; do
- a_dir="$prefix"$a_dir
- key=md5_$(md5sum < <( echo "$a_dir" ) | cut -f1 -d' ')
- DIR_CONTENTS_INCLUDE[$key]=yes
- DIR_CONTENTS_NAME[$key]="$a_dir"
- done
- for a_file in ${FILES_INCLUDE[@]}; do
- a_file=$prefix$a_file
- key=md5_$(md5sum < <( echo "$a_file" ) | cut -f1 -d' ')
- PATH_INCLUDE[$key]=yes
- PATH_NAME[$key]="$a_file"
- done
- done
- #function do_cmd(){
- #
- #}
- function get_include_policy(){
- local path1=$1
- local key1=$2;
- local path2=$3
- local key2=$4
- [ -z "$key1" ] && key1=md5_$(md5sum < <( echo "$path2" ) | cut -f1 -d' ')
- if [ -z "${DIR_POLICY[$key1]}" ]; then
- if [ ${#path1} -gt 2 ]; then
- [ -z "$path2" ] && path2="$(dirname "$path1")"
- [ -z "$key2" ] && key2=md5_$(md5sum < <( echo "$path2" ) | cut -f1 -d' ')
- get_include_policy "$path2" "$key2"
- DIR_POLICY[$key]="$get_include_policy_rtn"
- else
- DIR_POLICY[$key]="$DEFAULT_POLICY"
- fi
- fi
- get_include_policy_rtn="${DIR_POLICY[$key]}"
- }
- function get_include_status(){
- local path_arg=$1; shift
- local category=$1; shift
- local opts="$@" #To be determined
- local key=md5_$(md5sum < <( echo "$path_arg" ) | cut -f1 -d' ')
- local include=maybe
- local policy=maybe
- if [ "${PATH_INCLUDE[$key]}" = yes ]; then
- include=yes
- elif [ "${PATH_INCLUDE[$key]}" = no ]; then
- include=no
- fi
- path_arg2="$(dirname "$path_arg")"
- key2=md5_$(md5sum < <( echo "$(dirname "$path_arg2")" ) | cut -f1 -d' ')
- category2=${CATEGORIES["$key2"]}
- if [ -d "$path_arg" ]; then
- pkey="$key"
- p_path="$path_arg"
- else
- pkey="$key2"
- p_path="$path_arg2"
- fi
- if [ -z "${DIR_POLICY[$pkey]}" ]; then
- if [ ${#p_path} -gt 2 ]; then
- get_include_policy "$p_path" "$pkey"
- DIR_POLICY[$pkey]="$get_include_policy_rtn"
- else
- DIR_POLICY[$pkey]="$DEFAULT_POLICY"
- fi
- fi
- policy="${DIR_POLICY[$pkey]}"
- if [ "$include" = maybe ]; then
- if [ -d $path_arg ]; then
- if [ ${DIR_CONTENTS_INCLUDE[$key]} = yes ]; then
- include=yes
- elif [ ${DIR_CONTENTS_INCLUDE[$key]} = no ]; then
- include=no
- elif [ ${#path_arg} -le 2 ]; then
- DEFAULT_POLICY
- fi
- fi
- if [ "$include" = maybe ]; then
- if [ policy = maybe ]; then
- get_include_policy "$eval_mode" "$path_arg2" "$category2"
- policy2="$get_include_policy_rtn"
- fi
- get_include_status "$eval_mode" "$path_arg2" "$category2"
- include="$get_include_status_rtn"
- fi
- fi
- get_include_status_rtn="$include"
- get_include_status_rtn_policy="$policy"
- }
- function query_process_path(){
- case "$2" in
- directories:*)
- echo yes; ;;
- directory_contents:*)
- key=md5_$(md5sum < <( echo "$1" ) | cut -f1 -d' ')
- if [ DIR_CONTENTS_INCLUDE[$key] = yes ]; then
- echo yes
- elif [ DIR_CONTENTS_INCLUDE[$key] = no ]; then
- echo no
- else
- echo maybe
- fi; ;;
- esac
- }
- function pre_eval_line(){
- CMD=find
- LAST_OPT="-wholename"
- line="$1"
- line="${line%%#*}" #Strip comments
- #INDENT_NEW=${line##[[:space:]]*}
- LEN_LINE=${#line}
- #line=${line##[[:space:]]*}
- line="$(echo "$line" | sed 's#^[[:space:]]*##')"
- LEN_LINE2=${#line}
- INDENT_NEW=$((LEN_LINE-LEN_LINE2)) #Not used yet (See comments below)
- #line=${line:${#INDENT_NEW}}
- set -- $line
- #if [ ${#INDENT_NEW} -le ${#INDENT} ]; then
- # PROCESS_LINE=yes
- #else
- # if [ "$PROCESS_LINE" = maybe ]; then
- # PROCESS_LINE="$(query_process_line "$@")"
- # if [ $PROCESS_LINE = yes ] || [ $PROCESS_LINE = maybe ]; then
- # INDENT=$INDENT_NEW
- # fi
- # else
- # PROCESS_LINE=no
- # fi
- #fi
- #if [ "$PROCESS_LINE" = yes ] || [ "$PROCESS_LINE" = maybe ]; then
- case "${line:0:1}" in #"${line:$LEADING_SPACES:1}" in
- # [[:space:]]) #https://stackoverflow.com/questions/21623268/check-if-a-given-character-is-whitespace
- # line=""; ;; #This should never happen
- -)
- PROCESS_OPTIONS=yes; ;;
- *)
- PROCESS_OPTIONS=no
- line=${line:$INDENT}; ;;
- esac
- options=(".")
- if [ ! -z "$line" ]; then
- if [ "$PROCESS_OPTIONS" = yes ]; then
- while [ $# -gt 0 ]; do
- case $1 in
- -regextype)
- options+=("$1" "$2")
- shift;
- shift;
- LAST_OPT="-regex"; ;;
- --)
- shift 1
- break; ;;
- esac
- done
- fi
- #do_cmd "$@" && $CMD "${options[@]}" $LAST_OPT "$1"
- fi
- #else
- # line=''
- #fi
- pre_eval_line_rtn_line="$line"
- eval "pre_eval_line_rtn_pattern=$1"
- eval "pre_eval_line_rtn_category=$2"
- eval "pre_eval_line_rtn_policy=$3"
- pre_eval_line_rtn_CMD="$CMD"
- pre_eval_line_rtn_opt=( "${options[@]}" )
- pre_eval_line_rtn__last_opt="$LAST_OPT"
- }
- function eval_line(){
- eval_mode=$1; shift
- path=$1; shift
- opts="$@"
- if [ ! -z "$processed_line" ]; then
- if [ $eval_mode -eq 1 ]; then
- get_include_status_and_policy "$path" ${opts[@]}
- include_status
- include_policy do_cmd "$@"
- $CMD "${options[@]}" $LAST_OPT "$1"
- elif [ $eval_mode -eq 2 ]; then
- do_cmd "$@" && $CMD "${options[@]}" $LAST_OPT "$1"
- fi
- fi
- }
- INDENT=0
- INDENT_STEP=2
- for mode in 1 2; do
- while IFS="" read -r line || [ -n "$line" ]; do
- result1=query_process_path
- first_char=${line}
- pre_eval_line "$line"
- #line="$pre_eval_line_rtn_line""
- pattern="$pre_eval_line_rtn_pattern"
- category="$pre_eval_line_rtn_category"
- policy="$pre_eval_line_rtn_policy"
- #CMD=pre_eval_line_rtn_CMD
- #options=( "${pre_eval_line_rtn_opt[@]}" )
- #LAST_OPT="${pre_eval_line_rtn__last_opt}"
- while IFS="" read -r path; do
- get_include_status "$path" "$category" "$policy"
- case $mode in
- 2)
- include="$get_include_status_rtn" #returned from get_include_status
- policy="$get_include_status_rtn_policy" #returned from get_include_status
- echo "pre:cpio; path=$path"
- if [ "$include" = yes ] || [ $policy = "$exclude_by_blacklist" ]; then
- cd $ROOT
- echo "$path" | cpio -pdmu "$target_root"
- fi
- ;;
- esac
- done < <($CMD "${options[@]}" $LAST_OPT "$pattern") #These values are set in pre_eval_line
- done << 'EOF'
- "./usr" "directories:user"
- "./usr/*" "directory_contents:user"
- "./usr/lib" "directories:lib"
- "./usr/lib/*" "directories_contents:user/lib"
- -regextype posix-basic -- "\./usr/lib/gdk-pixbuf-[^/]*" "pixbuf"
- -regextype posix-basic -- "\./usr/lib/gdk-pixbuf-[^/]/*" "pixbuf"
- "./usr/share" "directories:share"
- "./usr/share/*" "directory_contents:user/share"
- "./usr/share/icons" "directories:icons"
- "./usr/share/icons/hicolor" "icons:hicolor
- "./usr/share/icons/hicolor/*" "icons:hicolor
- -regextype posix-basic -- "./usr/share/glib-[^/]*" "directories:glib"
- -regextype posix-basic -- "\./usr/share/glib-[^/]*/schemas" "glib:schemas"
- -regextype posix-basic -- "\./usr/share/glib-[^/]*/schemas/.*" "glib:schemas"
- "./usr/share/backgrounds_original*" "custom:desktop:background"
- "./usr/share/backgrounds_original/*" "custom:desktop:background"
- "./usr/share/i18n" "local:i18n" #Internationalizations
- "./usr/share/i18n/dialog_table_x" "local:i18n" #Internationalizations
- "./usr/bin" "directories:usr/bin"
- "./usr/bin/*" "directory_contents:usr/bin"
- "./usr/bin/VGA_On.sh" "custon:s243a"
- "./usr/bin/X" "symlinks:X"
- "./usr/local" "directories:usr/local"
- "./usr/local/*" "directory_contents:usr/local"
- "./usr/local/psync/" "custom:local:timeserver:psync" #Defines the time zone
- "./usr/local/psync/setcountry" "custom:local:timeserver:psync" #Defines the time zone
- "./usr/local/apps" "directories:roxaps"
- "./usr/local/apps/ROX-Filer" "directories:roxaps"
- "./usr/local/apps/ROX-Filer/ROX" "roxaps:rox"
- "./usr/local/apps/ROX-Filer/ROX/*" "roxaps:rox"
- "./usr/local/bin" "directories:defaults:applications"
- "./usr/local/bin/defaultconnect" "custom:applications:defaultconnect"
- "./initrd" "directories:initrd"
- "./initrd/*" "directories_contents:initrd"
- "./initrd/init" "initrd:init_scripts"
- "./initrd/init_full_install" "initrd:init_scripts"
- "./initrd/README.txt" "initrd:init_scripts"
- "./initrd/mnt" "directories:initrd/mnt"
- "./initrd/mnt/*" "directories_contents:initrd/mnt"
- "./initrd/pup_a" "directories:layers:pup_a"
- "./initrd/files" "directories:layers:files"
- "./initrd/pup_z" "directories:layers:pup_z"
- "./initrd/pup_ro2" "directories:layers:pup_ro2"
- "./initrd/pup_rw" "directories:layers:pup_rw"
- "./initrd/tmp"
- "./initrd/tmp/*" "directories_contents:initrd/tmp"
- "./initrd/tmp/ATADRIVES0" logs:initrd
- "./initrd/tmp/dmesg.txt" logs:initrd
- "./initrd/tmp/sfs_ram_sizek" logs:initrd
- "./initrd/tmp/probedisk.log" logs:initrd
- "./initrd/tmp/probepart.log" logs:initrd
- "./initrd/tmp/ALLDRVS0" logs:initrd
- "./initrd/tmp/HAVE_PARTS" logs:initrd
- "./initrd/tmp/bootinit.log" logs:initrd
- "./initrd/DISTRO_SPECS" "config:DISTRO_SPECS"
- "./.wh..wh.aufs" "whitout:type"
- "./mnt" "directories:mnt"
- "./mnt/home" "symlinks:home"
- "./root" "directories:root"
- "./root/*" "directories_contents:root"
- "./root/.xinitrc"
- "./root/.getflash"
- "./root/.getflash/getflash-prefs"
- "./root/Startup"
- "./root/Startup/timesync.sh"
- "./root/.local"
- "./root/.local/share"
- "./root/.local/share/recently-used.xbel" "private:recently-used.xbel"
- "./root/.jwmrc-previous"
- "./root/.XLOADED"
- "./root/.icons"
- "./root/.icons/ROX"
- "./root/.pup_event"
- "./root/.thumbnails"
- "./root/.spot-status"
- "./root/.jwmrc-tray"
- "./root/Choices"
- "./root/Choices/ROX-Filer"
- "./root/Choices/ROX-Filer/PuppyPin"
- "./root/.cache"
- "./root/.cache/dconf"
- "./root/.cache/dconf/user"
- "./root/.jwmrc"
- "./root/.connectwizardrc"
- "./root/.config"
- "./root/.config/rox.sourceforge.net"
- "./root/.config/rox.sourceforge.net/ROX-Filer"
- "./root/.config/rox.sourceforge.net/ROX-Filer/panels"
- "./root/.config/rox.sourceforge.net/ROX-Filer/globicons"
- "./root/.config/pmcputemp"
- "./root/.config/pmcputemp/pmcputemprc"
- "./root/.config/pmcputemp/temp.png"
- "./root/.config/geany"
- "./root/.config/geany/filedefs"
- "./root/.config/geany/filedefs/filetypes.README"
- "./root/.config/geany/keybindings.conf"
- "./root/.config/geany/geany.conf"
- "./root/.config/geany/templates"
- "./root/.config/geany/templates/files"
- "./root/.config/geany/templates/templates.README"
- "./etc" "directories:etc"
- "./etc/*" "directories_contents:etc"
- ./etc/network-wizard
- ./etc/network-wizard/wireless
- ./etc/network-wizard/wireless/profiles
- ./etc/network-wizard/wireless/profiles/??:??:??:??:??:??.*.conf "private:custom"
- ./etc/network-wizard/wireless/wpa_profiles
- ./etc/network-wizard/wireless/wpa_profiles/??:??:??:??:??:??.*.conf "private:custom"
- ./etc/network-wizard/wireless/interfaces
- ./etc/network-wizard/wireless/interfaces/??:??:??:??:??:??.conf "private:custom"
- ./etc/network-wizard/network
- ./etc/network-wizard/network/interfaces
- ./etc/network-wizard/network/interfaces/selected_conf "private:custom"
- ./etc/network-wizard/network/interfaces/??:??:??:??:??:??.conf "private:custom"
- ./etc/asound.state
- ./etc/hostname
- ./etc/mousedevice
- ./etc/keymap
- ./etc/plogin
- ./etc/codepage
- ./etc/printcap
- ./etc/machine-id
- ./etc/issue
- ./etc/cups
- ./etc/cups/cupsd.conf
- ./etc/cups/ssl
- ./etc/cups/printers.conf
- ./etc/cups/printers.conf.O
- ./etc/cups/ppd
- ./etc/services
- ./etc/modprobe.d
- ./etc/modprobe.d/blacklist.conf
- ./etc/modprobe.d/.wh.blacklist-modem.conf
- ./etc/mtab
- ./etc/hosts
- ./etc/xdg
- ./etc/xdg/templates
- ./etc/xdg/templates/_root_.jwmrc
- ./etc/resolv.conf
- ./etc/X11
- ./etc/X11/xorg.conf
- ./etc/localtime
- ./etc/rc.d
- ./etc/rc.d/PUPSTATE
- ./etc/rc.d/MODULESCONFIG
- ./etc/rc.d/BOOTCONFIG.save
- ./etc/rc.d/BOOTCONFIG
- ./etc/rc.d/rc.local
- ./etc/pwf
- ./etc/pwf/pwf.conf
- ./etc/clock
- ./etc/oldmousedevice
- ./etc/DISTRO_SPECS
- ./var
- ./var/cache
- ./var/cache/cups
- ./var/cache/cups/job.cache
- ./var/cache/cups/rss
- ./var/cache/cups/CUPS-PDF.pwg3
- ./var/cache/cups/CUPS-PDF.ipp4
- ./var/cache/fontconfig
- ./var/cache/fontconfig/43c5f0feff18dfd82945432563d9d274-le32d4.cache-3
- ./var/run
- ./var/run/dbus
- ./var/run/cups
- ./var/run/cups/certs
- ./var/run/dhcpcd
- ./var/run/dhcpcd/resolv.conf
- ./var/lib
- ./var/lib/dbus
- ./var/lib/dbus/machine-id
- ./var/lib/xkb
- ./var/lib/xkb/server-1E98292D90C4F55FD33B97814F1C19BE08CADA56.xkm
- ./var/lib/xkb/server-5517831893F7E63A5A6D917848C42481F8E4E257.xkm
- ./var/lib/dhcpcd
- ./var/lib/dhcpcd/dhcpcd-wlan0.lease
- ./var/local
- ./var/local/quicksetup-network-check-flag2
- ./var/local/quicksetup-timezone-table-x
- ./var/local/shared
- ./var/local/mscw
- ./var/local/shutdown_date_saved
- ./var/local/quicksetup-network-check-flag1
- ./var/local/quicksetup-timezone-table-cli
- ./var/local/delayedrun_firstboot_flag
- ./var/local/etc_profile_at_shutdown
- ./var/spool
- ./var/spool/cups
- ./var/spool/cups/tmp
- ./var/tmp
- ./var/log
- ./var/log/cups
- ./var/log/cups/error_log
- ./var/log/Xorg.0.log
- ./var/log/Xorg.0.log.old
- ./var/log/previous.messages
- ./.DirIcon
- ./tmp
- EOF
- done
Advertisement
Add Comment
Please, Sign In to add comment