diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f04ec43b0b2..f786193a6f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,6 +37,10 @@ on: description: 'File name prefix' required: false default: 'slacko64' + unionfs: + description: 'Layered file system, aufs or overlay' + required: false + default: 'aufs' jobs: build: @@ -71,6 +75,8 @@ jobs: run: sudo sed -i s/^DISTRO_VERSION=.*/DISTRO_VERSION=${{ github.event.inputs.version }}/ ../woof-out_*/DISTRO_SPECS - name: Set file name prefix run: sudo sed -i s/^DISTRO_FILE_PREFIX=.*/DISTRO_FILE_PREFIX=${{ github.event.inputs.prefix }}/ ../woof-out_*/DISTRO_SPECS + - name: Set layered file system + run: echo "UNIONFS=${{ github.event.inputs.unionfs }}" | sudo tee -a ../woof-out_*/_00build_2.conf - name: 0setup run: | cd ../woof-out_* diff --git a/initrd-progs/0initrd/README.txt b/initrd-progs/0initrd/README.txt index 7cbcbdbecb8..0ffb34fbf00 100644 --- a/initrd-progs/0initrd/README.txt +++ b/initrd-progs/0initrd/README.txt @@ -136,6 +136,11 @@ psubdir= If a leading "/" is not provided, init will add it. This is the default path for locating any puppy file and any partition. +punionfs= + Overrides the union file system choice made at build time. + Use with care, as aufs and overlay are incompatible with each other. + To switch from aufs to overlay or vice versa, start with a fresh save layer (pfix=ram). + ------------------------------------------------------------ pupsfs= Specifies the puppy...sfs partition zdrv= Specifies the zdrv...sfs partition diff --git a/initrd-progs/0initrd/init b/initrd-progs/0initrd/init index dd77b07d7bc..2015fbdb01f 100755 --- a/initrd-progs/0initrd/init +++ b/initrd-progs/0initrd/init @@ -42,7 +42,7 @@ L_ERR_ONEPART_MOUNT_SFS_FAILED="%s %s mount of sfs failed." #printf L_ERR_AUFS_SFS_FAILED="aufs mount of %s failed." #printf L_ERR_TYPE_PUPSAVE="Type a number to choose which personal file to use:" L_DROPPED_TO_INITRD_SHELL="Dropped to initramfs shell. Type 'exec switch' to continue booting Puppy." -L_SWITCH_ROOT="Performing a 'switch_root' to the layered filesystem..." +L_SWITCH_ROOT="Performing a 'switch_root' to the %s filesystem..." #printf L_FOLDER_MARKED_BAD="Folder %s marked bad." #printf L_0_NONE="0 none" L_ERROR_FAILED_AUFS_STACK='Failed to create empty aufs stack' @@ -105,6 +105,9 @@ LINUXFSLIST="ext2|ext3|ext4|btrfs|minix|f2fs|reiserfs" #Filesystem to be fsck FSCKLIST="ext2|ext3|ext4|vfat|msdos|exfat" +# Layered file system to use +UNIONFS='aufs' + #============================================================= # FUNCTIONS #============================================================= @@ -294,8 +297,10 @@ ensure_save_mounted() { if [ "$ONE_MP" != "$SAVE_MP" ];then #ensure SAVEPART is mounted on /mnt/dev_save [ -d "$SAVE_MP" ] || mkdir -p $SAVE_MP - echo "mount -o move $ONE_MP $SAVE_MP" #debug - mount -o move $ONE_MP $SAVE_MP + OPT="move" + [ "$UNIONFS" = 'overlay' ] && OPT="bind" + echo "mount -o $OPT $ONE_MP $SAVE_MP" #debug + mount -o $OPT $ONE_MP $SAVE_MP fi SAVE_FS="$ONE_FS" else @@ -306,6 +311,7 @@ ensure_save_mounted() { find_drv_file() { # "$1" - specified filename - ex: /pup/mydrv-1.2.3.sfs # "$2" - default filename - ex: adrv_tahr_6.0.5.sfs +# "$3" - look under root too - ex. 1 ONE_FN="" [ "${1}" ] || [ "${2}" ] || return if [ "${1}" ];then @@ -315,6 +321,7 @@ find_drv_file() { esac else ONE_TRY_FN="${PSUBDIR}/${2}" + [ "$3" -a ! -e "${ONE_MP}${ONE_TRY_FN}" ] && ONE_TRY_FN="/$2" fi if [ -L "${ONE_MP}${ONE_TRY_FN}" ];then C_MP="$(readlink -f "$ONE_MP")" @@ -329,6 +336,7 @@ find_onepupdrv() { # "$2" - specified filename - ex: /pup/mydrv-1.2.3.sfs # "$3" - default filename - ex: adrv_tahr_6.0.5.sfs # "$4" - prefix for "drv" mountpoint - ex: a +# "$5" - look under root too - ex. 1 ONE_FN="" [ "${2}" ] || [ "${3}" ] || return [ "${4}" ] || return @@ -340,7 +348,7 @@ find_onepupdrv() { [ "$ONE_PART" ] || return ensure_mounted "$ONE_PART" "/mnt/${4}drv" [ "$ONE_MP" ] || return - find_drv_file "${2}" "${3}" + find_drv_file "${2}" "${3}" "${5}" [ "$ONE_FN" = "" -a "${2}" ] && echo "$ONE_PART, $ONE_TRY_FN file not found." } @@ -423,14 +431,31 @@ setup_onepupdrv() { if ! [ "$ONE_LAYER" ] ; then return 4 #sfs mount failed fi - if [ "$ONE_PREP" ];then - echo "mount -o remount,add:1:$ONE_LAYER /pup_new" #debug - mount -o remount,add:1:$ONE_LAYER /pup_new + if [ -n "$punionfs" ]; then + UNIONFS="$punionfs" + elif [ -f $SFS_MP/etc/rc.d/PUPSTATE ]; then + . $SFS_MP/etc/rc.d/PUPSTATE + [ -n "$PUNIONFS" ] && UNIONFS="$PUNIONFS" + fi + if [ "$UNIONFS" = 'overlay' ]; then + remount_overlay -e "s~lowerdir=([^,]+)~lowerdir=${SFS_MP}:\1~" -e "s~lowerdir=,~lowerdir=${SFS_MP},~" [ $? -eq 0 ] || return 5 else - echo "mount -o remount,append:$ONE_LAYER /pup_new" #debug - mount -o remount,append:$ONE_LAYER /pup_new - [ $? -eq 0 ] || return 5 + mountpoint -q /pup_new + if [ $? -ne 0 ];then + echo "mount -t aufs -o udba=reval,diropq=w,br=/mnt/tmpfs/pup_rw=rw,xino=/mnt/tmpfs/.aufs.xino unionfs /pup_new" #debug + mount -t aufs -o udba=reval,diropq=w,br=/mnt/tmpfs/pup_rw=rw,xino=/mnt/tmpfs/.aufs.xino unionfs /pup_new + [ $? -eq 0 ] || fatal_error "${L_ERROR_FAILED_AUFS_STACK}" + fi + if [ "$ONE_PREP" ];then + echo "mount -o remount,add:1:$ONE_LAYER /pup_new" #debug + mount -o remount,add:1:$ONE_LAYER /pup_new + [ $? -eq 0 ] || return 5 + else + echo "mount -o remount,append:$ONE_LAYER /pup_new" #debug + mount -o remount,append:$ONE_LAYER /pup_new + [ $? -eq 0 ] || return 5 + fi fi NEWUNIONRECORD="${NEWUNIONRECORD}${ONE_BASENAME} " return 0 @@ -451,17 +476,36 @@ setup_psave(){ # setup savefile or savefolder /sbin/load_ext_file "$SAVE_FN" "$SAVE_MP" #reads $PFSCK if [ -f /tmp/savefile_loop ] ; then . /tmp/savefile_loop # $SAVEFILE_LOOP $SFFS - [ -d "$SAVE_LAYER" ] || mkdir $SAVE_LAYER - echo "mount -t $SFFS -o noatime $SAVEFILE_LOOP $SAVE_LAYER" #debug - mount -t $SFFS -o noatime $SAVEFILE_LOOP $SAVE_LAYER - [ $? -ne 0 ] && PUPSAVE="" + if [ "$UNIONFS" = 'overlay' ]; then + mkdir /pup_loop + echo "mount -t $SFFS -o noatime $SAVEFILE_LOOP /pup_loop" #debug + mount -t $SFFS -o noatime $SAVEFILE_LOOP /pup_loop + if [ $? -ne 0 ]; then + PUPSAVE="" + else + mkdir -p "/pup_loop/upper" "/pup_loop/work" + ln -sv "/pup_loop/upper" "$SAVE_LAYER" + ln -sv "/pup_loop/work" "$WORKDIR" + fi + else + [ -d "$SAVE_LAYER" ] || mkdir $SAVE_LAYER + echo "mount -t $SFFS -o noatime $SAVEFILE_LOOP $SAVE_LAYER" #debug + mount -t $SFFS -o noatime $SAVEFILE_LOOP $SAVE_LAYER + [ $? -ne 0 ] && PUPSAVE="" + fi else # load_ext_file failed FLAG_NO_TIMEOUT=1 PUPSAVE="" fi elif [ -d "$SAVE_FN" ];then #savefolder echo "--SAVEFOLDER-- $SAVE_FN" #debug - ln -sv "$SAVE_FN" "$SAVE_LAYER" + if [ "$UNIONFS" = 'overlay' ]; then + mkdir -p "$SAVE_FN/upper" "$SAVE_FN/work" + ln -sv "$SAVE_FN/upper" "$SAVE_LAYER" + ln -sv "$SAVE_FN/work" "$WORKDIR" + else + ln -sv "$SAVE_FN" "$SAVE_LAYER" + fi else PUPSAVE="" fi @@ -662,7 +706,7 @@ $TRY_PARTS_LAST" fi fi if [ "$LOOK_PUP" ];then - find_drv_file "$P_BP_FN" "$P_DEF_FN" + find_drv_file "$P_BP_FN" "$P_DEF_FN" "" if [ "$ONE_FN" ];then PDRV="$ONE_PART,$ONE_FS,$ONE_FN" P_MP="$ONE_MP" @@ -742,6 +786,25 @@ fatal_error() { check_status -critical 1 "$1" } +remount_overlay() { + OPTS=`grep '^unionfs /pup_new overlay' /proc/mounts | awk '{print $4}'` + if [ -n "$OPTS" ]; then + umount -l /pup_new + else + mkdir /mnt/tmpfs/pup_work + OPTS="lowerdir=,upperdir=/mnt/tmpfs/pup_rw,workdir=/mnt/tmpfs/pup_work,xino=on" + fi + NEWOPTS=`echo "$OPTS" | sed -E "$@"` + echo "mount -t overlay -o ${NEWOPTS} unionfs /pup_new" #debug + mount -t overlay -o ${NEWOPTS} unionfs /pup_new + STATUS=$? + if [ $STATUS -ne 0 ]; then + echo "mount -t overlay -o ${OPTS} unionfs /pup_new" #debug + mount -t overlay -o ${OPTS} unionfs /pup_new + fi + return $STATUS +} + #============================================================= # MAIN #============================================================= @@ -874,7 +937,7 @@ P_PART=""; LOOK_PUP=""; LOOK_SAVE="" if [ "$P_BP_ID" ];then #specified as parameter decode_id "$P_BP_ID" [ "$ONE_PART" ] && { P_PART="$ONE_PART"; P_BP_ID=""; } - find_onepupdrv "$P_PART" "$P_BP_FN" "$P_DEF_FN" "p" + find_onepupdrv "$P_PART" "$P_BP_FN" "$P_DEF_FN" "p" "" [ "$ONE_FN" ] && { PDRV="$ONE_PART,$ONE_FS,$ONE_FN"; P_MP="$ONE_MP"; } [ "$PDEBUG" ] && echo "2: ONE_PART=$ONE_PART ONE_FN=$ONE_FN ONE_MP=$ONE_MP" elif [ "$PDRV" = "" ];then #not specified anywhere @@ -931,8 +994,6 @@ RAMSIZE=$(free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 2 -d ' ') #total physica mount -t tmpfs tmpfs /mnt/tmpfs [ -d "/mnt/tmpfs/pup_rw" ] || mkdir /mnt/tmpfs/pup_rw -mount -t aufs -o udba=reval,diropq=w,br=/mnt/tmpfs/pup_rw=rw,xino=/mnt/tmpfs/.aufs.xino unionfs /pup_new -[ $? -eq 0 ] || fatal_error "${L_ERROR_FAILED_AUFS_STACK}" NEWUNIONRECORD="" COPY2RAM="" @@ -961,27 +1022,27 @@ PUP_LAYER="$SFS_MP" [ "$SAVE_BP_ID" ] && log_part_id "$SAVE_BP_ID" #have basic system, now try to add optional stuff -find_onepupdrv "$F_PART" "$F_BP_FN" "$F_DEF_FN" "f" +find_onepupdrv "$F_PART" "$F_BP_FN" "$F_DEF_FN" "f" "" [ "$ONE_FN" ] && FDRV="$ONE_PART,$ONE_FS,$ONE_FN" [ "$FDRV" ] && { LOADMSG="fdrv"; setup_onepupdrv "$FDRV" "f"; } -find_onepupdrv "$Z_PART" "$Z_BP_FN" "$Z_DEF_FN" "z" +find_onepupdrv "$Z_PART" "$Z_BP_FN" "$Z_DEF_FN" "z" "" [ "$ONE_FN" ] && ZDRV="$ONE_PART,$ONE_FS,$ONE_FN" [ "$ZDRV" ] && { LOADMSG="zdrv"; setup_onepupdrv "$ZDRV" "z"; } -find_onepupdrv "$Y_PART" "$Y_BP_FN" "$Y_DEF_FN" "y" +find_onepupdrv "$Y_PART" "$Y_BP_FN" "$Y_DEF_FN" "y" "" [ "$ONE_FN" ] && YDRV="$ONE_PART,$ONE_FS,$ONE_FN" [ "$YDRV" ] && { LOADMSG="ydrv"; setup_onepupdrv "$YDRV" "y" "p"; } -find_onepupdrv "$B_PART" "$B_BP_FN" "$B_DEF_FN" "b" +find_onepupdrv "$B_PART" "$B_BP_FN" "$B_DEF_FN" "b" "" [ "$ONE_FN" ] && BDRV="$ONE_PART,$ONE_FS,$ONE_FN" [ "$BDRV" ] && { LOADMSG="bdrv"; setup_onepupdrv "$BDRV" "b" "p"; } -find_onepupdrv "$A_PART" "$A_BP_FN" "$A_DEF_FN" "a" +find_onepupdrv "$A_PART" "$A_BP_FN" "$A_DEF_FN" "a" "" [ "$ONE_FN" ] && ADRV="$ONE_PART,$ONE_FS,$ONE_FN" [ "$ADRV" ] && { LOADMSG="adrv"; setup_onepupdrv "$ADRV" "a" "p"; } -find_onepupdrv "" "" "$KBUILD_DEF_FN" "k" +find_onepupdrv "" "" "$KBUILD_DEF_FN" "k" "" [ "$ONE_FN" ] && KBUILD="$ONE_PART,$ONE_FS,$ONE_FN" [ "$KBUILD" ] && { LOADMSG="kbuild"; setup_onepupdrv "$KBUILD" "k" "p"; } @@ -1152,6 +1213,7 @@ if [ "${SAVE_MP}" != "" -a "$PRAMONLY" != "yes" ];then #have mounted save? parti fi SAVE_LAYER="" +WORKDIR="/pup_work" if [ "$PUPSAVE" ];then #refine pupmode # refine pupmode if [ $PUPMODE -eq 12 ];then @@ -1179,8 +1241,14 @@ case $PUPMODE in #prepend ro1 - #SAVE_LAYER=/pup_ro1 rm -rf ${SAVE_LAYER}/tmp #in case last boot was pupmode=12 #adjust stack - echo "mount -o remount,add:1:${SAVE_LAYER}=ro+wh /pup_new" #debug - mount -o remount,add:1:${SAVE_LAYER}=ro+wh /pup_new #ro+wh = Readonly branch and it has/might have whiteouts on it + if [ "$UNIONFS" = 'overlay' ]; then + #pup_rw is bigger because files are copied, not moved to pup_ro1 + mount -o remount,size=75% /mnt/tmpfs + remount_overlay "s~lowerdir=([^,]+)~lowerdir=${SAVE_LAYER}:\1~" + else + echo "mount -o remount,add:1:${SAVE_LAYER}=ro+wh /pup_new" #debug + mount -o remount,add:1:${SAVE_LAYER}=ro+wh /pup_new #ro+wh = Readonly branch and it has/might have whiteouts on it + fi if [ $? -eq 0 ];then [ $PUPMODE -ne 77 ] && KEEPMOUNTED="${KEEPMOUNTED}${SAVEPART} " [ "$SAVE_NAME" ] && NEWUNIONRECORD="$SAVE_NAME $NEWUNIONRECORD" @@ -1196,8 +1264,12 @@ case $PUPMODE in #setup empty /tmp on tmpfs for in stack rm -rf ${SAVE_LAYER}/tmp #adjust stack - echo "mount -o remount,prepend:${SAVE_LAYER}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new" #debug - mount -o remount,prepend:${SAVE_LAYER}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new + if [ "$UNIONFS" = 'overlay' ]; then + remount_overlay -e "s~upperdir=[^,]+~upperdir=${SAVE_LAYER}~" -e "s~workdir=[^,]+~workdir=${WORKDIR}~" + else + echo "mount -o remount,prepend:${SAVE_LAYER}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new" #debug + mount -o remount,prepend:${SAVE_LAYER}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new + fi if [ $? -eq 0 ];then rm -rf /mnt/tmpfs/pup_rw KEEPMOUNTED="${KEEPMOUNTED}${SAVEPART} " @@ -1216,13 +1288,23 @@ case $PUPMODE in rm -r -f "$PM66_DIR" [ -d "$PM66_DIR" ] || mkdir $PM66_DIR mount -t tmpfs tmpfs $PM66_DIR - tar xf "$ARCHIVE_FN" -m -C $PM66_DIR 2>/dev/null - STATUS=$? - if [ $STATUS -eq 0 ];then - #replace rw branch with new populated tmpfs - echo "mount -o remount,prepend:${PM66_DIR}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new" #debug - mount -o remount,prepend:${PM66_DIR}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new + if [ "$UNIONFS" = 'overlay' ]; then + mkdir $PM66_DIR/upper $PM66_DIR/work + tar xf "$ARCHIVE_FN" -m -C $PM66_DIR/upper 2>/dev/null + STATUS=$? + if [ $STATUS -eq 0 ];then + remount_overlay -e "s~upperdir=[^,]+~upperdir=${PM66_DIR}/upper~" -e "s~workdir=[^,]+~workdir=${PM66_DIR}/work~" + STATUS=$? + fi + else + tar xf "$ARCHIVE_FN" -m -C $PM66_DIR 2>/dev/null STATUS=$? + if [ $STATUS -eq 0 ];then + #replace rw branch with new populated tmpfs + echo "mount -o remount,prepend:${PM66_DIR}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new" #debug + mount -o remount,prepend:${PM66_DIR}=rw,mod:/mnt/tmpfs/pup_rw=ro,del:/mnt/tmpfs/pup_rw /pup_new + STATUS=$? + fi fi if [ $STATUS -eq 0 ];then SAVE_MP='' @@ -1238,6 +1320,16 @@ case $PUPMODE in ;; esac +if [ "$SAVEPART" -a "$UNIONFS" = 'overlay' -a -f /pup_new/etc/rc.d/BOOTCONFIG ]; then + EXTRASFSLIST="" + . /pup_new/etc/rc.d/BOOTCONFIG + for ONE_SFS in $EXTRASFSLIST; do + LOOP=`losetup -f` + find_onepupdrv "$SAVEPART" "" "$ONE_SFS" "p" "1" + [ "$ONE_FN" ] && { LOADMSG="extra"; setup_onepupdrv "$ONE_PART,$ONE_FS,$ONE_FN" "ro${LOOP#/dev/loop}" "p"; } + done +fi + umount_unneeded echo -n $(($TOTAL_SIZEK_SFS_RAM - 5)) > /tmp/sfs_ram_sizek @@ -1275,7 +1367,7 @@ echo "PSAVEMARK='$PSAVEMARK'" echo "PSAVEPART='$PSAVEPART'" echo "PSAVEDIR='$SAVE_BP_DIR'" echo "PSUBDIR='$PSUBDIR'" -echo "PUNIONFS='aufs'" +echo "PUNIONFS='$UNIONFS'" echo "DOIMODS='yes'" echo "DOMIBS='no'" [ -f /sbin/set_plang ] && plang_pupstate #echo @@ -1290,19 +1382,21 @@ else echo "LASTUNIONRECORD=''" >> /pup_new/etc/rc.d/BOOTCONFIG fi -echo -n "${L_SWITCH_ROOT}" > /dev/console +echo -n "$(printf "${L_SWITCH_ROOT}" "${UNIONFS}")" >/dev/console echo "Moving mountpoints to /pup_new/initrd for after switch..." #debug rm -r -f "/pup_new/initrd${SAVE_LAYER}" +OPT="move" +[ "$UNIONFS" = 'overlay' ] && OPT="bind" for ONEMNT in $(mount | cut -f 3 -d ' ' | grep -v 'pup_new' | grep '^/pup_' | tr '\n' ' ');do mkdir -p /pup_new/initrd${ONEMNT} - echo "mount -o move $ONEMNT /pup_new/initrd${ONEMNT}" #debug - mount -o move $ONEMNT /pup_new/initrd${ONEMNT} + echo "mount -o $OPT $ONEMNT /pup_new/initrd${ONEMNT}" #debug + mount -o $OPT $ONEMNT /pup_new/initrd${ONEMNT} done for ONEMNT in $(mount | cut -f 3 -d ' ' | grep '^/mnt/' | tr '\n' ' ');do mkdir -p /pup_new/initrd${ONEMNT} - echo "mount -o move $ONEMNT /pup_new/initrd${ONEMNT}" #debug - mount -o move $ONEMNT /pup_new/initrd${ONEMNT} + echo "mount -o $OPT $ONEMNT /pup_new/initrd${ONEMNT}" #debug + mount -o $OPT $ONEMNT /pup_new/initrd${ONEMNT} done echo -------------------- # debug @@ -1324,7 +1418,7 @@ echo "SAVE_LAYER=${SAVE_LAYER}" #debug # (for savefiles and savepartitions the SAVE_LAYER is not a symlink) if [ "$PUPSAVE" ];then if [ "$SAVE_LAYER" -a -L "$SAVE_LAYER" ];then - ln -sv "/initrd${SAVE_FN}" "/pup_new/initrd${SAVE_LAYER}" #for after switch + ln -sv "/initrd`readlink ${SAVE_LAYER}`" "/pup_new/initrd${SAVE_LAYER}" #for after switch fi fi diff --git a/woof-code/3builddistro b/woof-code/3builddistro index 77a0fd31bd9..5c36407358c 100755 --- a/woof-code/3builddistro +++ b/woof-code/3builddistro @@ -886,6 +886,8 @@ if [ "$SDFLAG" != "" -o "$CROSFLAG" != "" ];then echo "BOOT_BOARD='${BOOT_BOARD}'" >> rootfs-complete/etc/rc.d/BOOTCONSTRAINED #120714 read by quicksetup. fi +echo "PUNIONFS='$UNIONFS'" >> rootfs-complete/etc/rc.d/PUPSTATE + # users shouldn't be able to read files under another home directory - i.e. leak .netrc busybox chmod 700 rootfs-complete/root rootfs-complete/home/spot diff --git a/woof-code/rootfs-skeleton/etc/rc.d/rc.shutdown b/woof-code/rootfs-skeleton/etc/rc.d/rc.shutdown index b42c4c213ca..67f94eecbab 100755 --- a/woof-code/rootfs-skeleton/etc/rc.d/rc.shutdown +++ b/woof-code/rootfs-skeleton/etc/rc.d/rc.shutdown @@ -265,23 +265,31 @@ case $PUPMODE in mount -t $FILEFS -o noatime,rw /dev/mapper/savefile /tmp/save1stpup fi #120522 testing precise puppy with aufs, have two dirs here .wh..wh.orph, .wh..wh.plnk, filter out... - RDIRS="`find /initrd/pup_rw/ -mindepth 1 -maxdepth 1 -mount -type d | grep -v '/\.wh\.' | grep -v -E '/$|/mnt|/media|/tmp|/proc|/sys|/dev|/lost' | tr '\n' ' '`" + if [ "$PUNIONFS" = 'overlay' ]; then + mkdir -p /tmp/save1stpup/upper + PFIX="/upper" + RDIRS="`find /initrd/pup_rw/ -mindepth 1 -maxdepth 1 -mount -type d | grep -v -E '/$|^/initrd/pup_rw/initrd|/mnt|/media|/tmp|/proc|/sys|/dev|/lost' | tr '\n' ' '`" + else + PFIX="" + RDIRS="`find /initrd/pup_rw/ -mindepth 1 -maxdepth 1 -mount -type d | grep -v '/\.wh\.' | grep -v -E '/$|/mnt|/media|/tmp|/proc|/sys|/dev|/lost' | tr '\n' ' '`" + fi for ONEDIR in $RDIRS do BASENAME="`basename $ONEDIR`" # set owner/permission of dirs when 1st save. this is important when choose to run as finn on 1st shutdown. - if [ ! -d /tmp/save1stpup/${BASENAME} ];then - mkdir -p /tmp/save1stpup/${BASENAME} + if [ ! -d /tmp/save1stpup${PFIX}/${BASENAME} ];then + mkdir -p /tmp/save1stpup${PFIX}/${BASENAME} #110503 got this from /usr/sbin/snapmergepuppy... - chmod "/tmp/save1stpup/${BASENAME}" --reference="$ONEDIR" + chmod "/tmp/save1stpup${PFIX}/${BASENAME}" --reference="$ONEDIR" OWNER="`stat -c %U "$ONEDIR"`" - chown $OWNER "/tmp/save1stpup/${BASENAME}" + chown $OWNER "/tmp/save1stpup${PFIX}/${BASENAME}" GRP="`stat -c %G "$ONEDIR"`" - chgrp $GRP "/tmp/save1stpup/${BASENAME}" - touch "/tmp/save1stpup/${BASENAME}" --reference="$ONEDIR" + chgrp $GRP "/tmp/save1stpup${PFIX}/${BASENAME}" + touch "/tmp/save1stpup${PFIX}/${BASENAME}" --reference="$ONEDIR" fi - cp -a $ONEDIR/ /tmp/save1stpup/ + cp -a $ONEDIR/ /tmp/save1stpup${PFIX}/ done + [ "$PUNIONFS" = 'overlay' ] && find /tmp/save1stpup${PFIX} -type c -delete #copy initmodules config file from /tmp if it exists [ -f /tmp/${DISTRO_FILE_PREFIX}initmodules.txt ] && cp -f /tmp/${DISTRO_FILE_PREFIX}initmodules.txt ${SMNTPT}${SAVEPATH}/${DISTRO_FILE_PREFIX}initmodules.txt sync @@ -410,7 +418,7 @@ if [ "$SAVE_LAYER" ];then #remove from unionfs if [ "$uniFS" == "aufs" ]; then busybox mount -t aufs -o remount,del:/initrd${SAVE_LAYER} unionfs / - else + elif [ "$uniFS" != "overlay" ]; then busybox mount -t unionfs -o remount,del=/initrd${SAVE_LAYER} unionfs / fi @@ -436,7 +444,7 @@ if [ "$SAVE_LAYER" ];then #Remove from unionfs if [ "$uniFS" == "aufs" ]; then busybox mount -t aufs -o remount,del:${PDRVPATH} unionfs / - else + elif [ "$uniFS" != "overlay" ]; then busybox mount -t unionfs -o remount,del=${PDRVPATH} unionfs / fi diff --git a/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit b/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit index ec217962130..e2a1e06721f 100755 --- a/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit +++ b/woof-code/rootfs-skeleton/etc/rc.d/rc.sysinit @@ -285,7 +285,11 @@ if [ "$SWAPON" = "yes" ];then # taking into account swap space and sfs_ram_sizek[might be removed] EXTRAALLOCK=$(($EXTRAALLOCK / 2048)) #use half in KiB RAMSIZE=$(free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 2 -d ' ') - FREEK=$(($RAMSIZE / 2)) #half of physical. + if [ "$PUNIONFS" = "overlay" -a $PUPMODE -eq 13 ]; then + FREEK=$(($RAMSIZE * 3 / 4)) #3/4 of physical. + else + FREEK=$(($RAMSIZE / 2)) #half of physical. + fi ALLOCK=$(($FREEK + $EXTRAALLOCK)) if [ "$(grep -m 1 '/initrd/mnt/tmpfs' /proc/mounts)" != "" ];then #mounted [ -s /initrd/tmp/sfs_ram_sizek ] && ALLOCK=$(($ALLOCK + $(cat /initrd/tmp/sfs_ram_sizek))) #proper size diff --git a/woof-code/rootfs-skeleton/etc/rc.d/rc.update b/woof-code/rootfs-skeleton/etc/rc.d/rc.update index b95ba6c30ba..f886bd6920d 100755 --- a/woof-code/rootfs-skeleton/etc/rc.d/rc.update +++ b/woof-code/rootfs-skeleton/etc/rc.d/rc.update @@ -298,7 +298,7 @@ if [ -f /initrd/tmp/version_update_flag ]; then for ONESCRIPT in dir2pet dirs2pets evince gtkdialog-splash lprshell man new2dir pet2tgz petspec pman pupdialog restartwm startx tgz2pet wmexit wmpoweroff wmreboot wvdialshell xterm xwin yaf-splash do [ -f ${OLDFILESMNTPT}/bin/$ONESCRIPT ] && cp -a -f --remove-destination ${NEWFILESMNTPT}/usr/bin/$ONESCRIPT /usr/bin/ 2>/dev/null done - for ONESCRIPT in alsawizard askpass background_reshape bcrypt_gui bootflash bootmanager burniso2cd calcfreespace.sh cdburner-wizard chooselocale connectwizard connectwizard_2nd countrywizard cups_shell dotpup delayedrun deskshortcut.sh download_file eventmanager exploderpm filemnt fitimage2root fixdesk fixmenus fixPuppyPin floppy-format.sh freememappletshell gen_modem_init_string get_bluetooth_connection get_modem_alternate_device grubconfig grubconfigREADME.txt icon_switcher icon_switcher_cli input-wizard ipinfo loginmanager modemdisconnect modemprobe modemprobe_erase modemprobe_help modemtest networkdisconnect partview pcur pdict Pdisk petget pgprs-shell pmodemdiag pmonitork.sh pmonitorx.sh pmount pmovie pngoverlay pngoverlay.bac pngoverlay.sh pppconnect pppdisconnect pppsetup Pudd pup-advert-blocker pupautodetect pupcamera pupdial pupdial_init_hotpluggable pupdial_wizard_helper puppyhelp puppyinstaller puppypdf pupscan remasterpup2 remove_builtin report-video resizepfile.sh root2user save2flash savesession-dvd scannerwizard.sh securetelnetshell set_bg set_hwclock_type set-time-for-puppy set-xftdpi sfsget shutdownconfig snapmergepuppy sns spacereplace timezone-set updatenetmoduleslist.sh usb_modem_special_status usb_modeswitch_status video_upgrade_wizard video-wizard welcome1stboot welcome1stboot.bac wizardwizard xdelta_gui xgamma-gui xinitrc_test xorgwizard xorgwizard-automatic xrandrshell xserverwizard + for ONESCRIPT in alsawizard askpass background_reshape bcrypt_gui bootflash bootmanager burniso2cd calcfreespace.sh cdburner-wizard chooselocale connectwizard connectwizard_2nd countrywizard cups_shell dotpup delayedrun deskshortcut.sh download_file eventmanager exploderpm filemnt fitimage2root fixdesk fixmenus fixPuppyPin floppy-format.sh freememappletshell gen_modem_init_string get_bluetooth_connection get_modem_alternate_device grubconfig grubconfigREADME.txt icon_switcher icon_switcher_cli input-wizard ipinfo loginmanager modemdisconnect modemprobe modemprobe_erase modemprobe_help modemtest networkdisconnect partview pcur pdict Pdisk petget pgprs-shell pmodemdiag pmonitork.sh pmonitorx.sh pmount pmovie pngoverlay pngoverlay.bac pngoverlay.sh pppconnect pppdisconnect pppsetup Pudd pup-advert-blocker pupautodetect pupcamera pupdial pupdial_init_hotpluggable pupdial_wizard_helper puppyhelp puppyinstaller puppypdf pupscan remasterpup2 remove_builtin report-video resizepfile.sh root2user save2flash savesession-dvd scannerwizard.sh securetelnetshell set_bg set_hwclock_type set-time-for-puppy set-xftdpi sfsget shutdownconfig snapmergepuppy snapmergepuppy.overlay sns spacereplace timezone-set updatenetmoduleslist.sh usb_modem_special_status usb_modeswitch_status video_upgrade_wizard video-wizard welcome1stboot welcome1stboot.bac wizardwizard xdelta_gui xgamma-gui xinitrc_test xorgwizard xorgwizard-automatic xrandrshell xserverwizard do [ -f ${OLDFILESMNTPT}/bin/$ONESCRIPT ] && cp -a -f --remove-destination ${NEWFILESMNTPT}/usr/sbin/$ONESCRIPT /usr/sbin/ 2>/dev/null done [ -f ${OLDFILESMNTPT}usr/local/petget ] && cp -a -f --remove-destination ${NEWFILESMNTPT}/usr/local/petget /usr/local/ diff --git a/woof-code/rootfs-skeleton/usr/sbin/resizepfile.sh b/woof-code/rootfs-skeleton/usr/sbin/resizepfile.sh index d3d798fef4e..f71c4d57b8c 100755 --- a/woof-code/rootfs-skeleton/usr/sbin/resizepfile.sh +++ b/woof-code/rootfs-skeleton/usr/sbin/resizepfile.sh @@ -23,6 +23,11 @@ $(eval_gettext "If you have installed Puppy to hard drive, or installed such tha esac +if [ -L "$PERSISTMNTPT" ] ; then + PERSISTMNTPT="`readlink "$PERSISTMNTPT"`" + [ -d "$PERSISTMNTPT" ] && PERSISTMNTPT="${PERSISTMNTPT%/upper}" +fi + SAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`" SAVEPART="`echo -n "$PUPSAVE" | cut -f 1 -d ','`" SAVEFILE="`echo -n "$PUPSAVE" | cut -f 3 -d ','`" diff --git a/woof-code/rootfs-skeleton/usr/sbin/sfs_load b/woof-code/rootfs-skeleton/usr/sbin/sfs_load index 49f039c8641..5fde9ce7d7d 100755 --- a/woof-code/rootfs-skeleton/usr/sbin/sfs_load +++ b/woof-code/rootfs-skeleton/usr/sbin/sfs_load @@ -84,7 +84,7 @@ fi if [ "$PUNIONFS" = "overlay" ] ; then - exit + exec sfs_load.overlay "$@" fi for i in $@ ; do diff --git a/woof-code/rootfs-skeleton/usr/sbin/sfs_load.overlay b/woof-code/rootfs-skeleton/usr/sbin/sfs_load.overlay new file mode 100755 index 00000000000..14e8ee77da1 --- /dev/null +++ b/woof-code/rootfs-skeleton/usr/sbin/sfs_load.overlay @@ -0,0 +1,118 @@ +#!/bin/sh + +. /etc/rc.d/BOOTCONFIG +. /etc/rc.d/PUPSTATE +. /etc/DISTRO_SPECS + +[ "$PUNIONFS" != "overlay" ] && exit 1 + +export TEXTDOMAIN=sfs_load +export OUTPUT_CHARSET=UTF-8 + +queue() { + . /etc/rc.d/BOOTCONFIG + cat << EOF > /etc/rc.d/BOOTCONFIG.tmp +EXTRASFSLIST='`echo "$EXTRASFSLIST $1" | tr ' ' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/^ //' -e 's/ $//'`' +PREVUNIONRECORD='$PREVUNIONRECORD' +LASTUNIONRECORD='$LASTUNIONRECORD' +EOF + mv -f /etc/rc.d/BOOTCONFIG.tmp /etc/rc.d/BOOTCONFIG +} + +unqueue() { + . /etc/rc.d/BOOTCONFIG + cat << EOF > /etc/rc.d/BOOTCONFIG.tmp +EXTRASFSLIST='`echo "$EXTRASFSLIST $1" | tr ' ' '\n' | sort | uniq | fgrep -v $1 | tr '\n' ' ' | sed -e 's/^ //' -e 's/ $//'`' +PREVUNIONRECORD='$PREVUNIONRECORD' +LASTUNIONRECORD='$LASTUNIONRECORD' +EOF + mv -f /etc/rc.d/BOOTCONFIG.tmp /etc/rc.d/BOOTCONFIG +} + +if [ $# -ne 0 ]; then + for SFS in "$@"; do + BASE="${SFS##*/}" + + SKIP=0 + case "$BASE" in + $DISTRO_BDRVSFS|$DISTRO_PUPPYSFS|$DISTRO_ZDRVSFS|$DISTRO_FDRVSFS|$DISTRO_ADRVSFS|$DISTRO_YDRVSFS|kbuild-*.sfs) SKIP=1 ;; + esac + + if [ $SKIP -eq 0 -a $PUPMODE -ne 5 ]; then + QUEUED=0 + for QBASE in $EXTRASFSLIST; do + [ "$BASE" != "$QBASE" ] && continue + QUEUED=1 + break + done + + if [ $QUEUED -eq 0 ]; then + yad --title sfs_load --window-icon=dialog-question --image=dialog-question --text "$(gettext "Do you want to queue") ${SFS}?" --form --button="gtk-yes:0" --button="gtk-no:1" + if [ $? -eq 0 ]; then + DST="/initrd${PUP_HOME}${PSUBDIR}/${BASE}" + if [ ! -e "$DST" -a ! -e "/initrd${PUP_HOME}/${BASE}" ]; then + cp -f "$SFS" "$DST" || continue + fi + SFS="$DST" + queue "$BASE" + fi + else + yad --title sfs_load --window-icon=dialog-question --image=dialog-question --text "$(gettext "Do you want to unqueue") ${SFS}?" --form --button="gtk-yes:0" --button="gtk-no:1" + [ $? -eq 0 ] && unqueue "$BASE" + fi + fi + + MNT="/mnt/`echo "$BASE" | tr '/ ' '+_'`" + mkdir -p "$MNT" + mountpoint -q "$MNT" + if [ $? -ne 0 ]; then + mount -r -t squashfs -o loop,noatime "$SFS" "$MNT" || continue + fi + + defaultfilemanager "$MNT" & + done + + exit 0 +fi + +export -f queue unqueue + +if [ -z "$PUP_HOME" ]; then + SFS_DIRS="/initrd/mnt/pdrv" +else + SFS_DIRS="/initrd${PUP_HOME}" + [ -n "$PSUBDIR" ] && SFS_DIRS="$SFS_DIRS /initrd${PUP_HOME}${PSUBDIR}" +fi + +BUTTONS="" +KBUILDSFS="kbuild-`uname -r`.sfs" +for SFS in `find $SFS_DIRS -maxdepth 1 -name '*.sfs' -printf '%f\n' | sort | uniq`; do + case "$SFS" in + $DISTRO_BDRVSFS|$DISTRO_PUPPYSFS|$DISTRO_ZDRVSFS|$DISTRO_FDRVSFS|$DISTRO_ADRVSFS|$DISTRO_YDRVSFS|$KBUILDSFS) + BUTTONS="truefalse$BUTTONS" + continue + ;; + esac + + DEF=false + for BASE in $EXTRASFSLIST; do + [ "$BASE" != "$SFS" ] && continue + DEF=true + break + done + + BUTTONS="$BUTTONS$DEFif true queue \"$SFS\"if false unqueue \"$SFS\"" +done + +[ -z "$BUTTONS" ] && BUTTONS="" + +export DIALOG=' + + '`/usr/lib/gtkdialog/xml_info fixed package_sfs.svg 20 "$(gettext "Which SFS do you want to load?")"`' + + '$BUTTONS' + + +' + +exec gtkdialog -p DIALOG \ No newline at end of file diff --git a/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy b/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy index 10aa2b07586..61ec4a06348 100755 --- a/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy +++ b/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy @@ -28,6 +28,14 @@ #140102 SFR: various fixes + gettext #140512 SFR: performance improvements +#variables created at bootup by 'init' script in initramfs... +. /etc/rc.d/PUPSTATE + +if [ "$PUNIONFS" = 'overlay' ]; then + snapmergepuppy.overlay "$@" + exit $? +fi + remove_merge_lock() { if [ $? -ne 255 ]; then [ -e /tmp/snapmergepuppy.lock ] && rm -f /tmp/snapmergepuppy.lock @@ -46,8 +54,6 @@ export OUTPUT_CHARSET=UTF-8 OLDLANG="$LANG" export LANG=C -#variables created at bootup by 'init' script in initramfs... -. /etc/rc.d/PUPSTATE . /etc/DISTRO_SPECS [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} diff --git a/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy.overlay b/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy.overlay new file mode 100755 index 00000000000..818b482c219 --- /dev/null +++ b/woof-code/rootfs-skeleton/usr/sbin/snapmergepuppy.overlay @@ -0,0 +1,227 @@ +#!/bin/sh +#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html) +#Barry Kauler www.puppylinux.com +#called from savepuppyd and rc.shutdown, to save tmpfs layer to permanent flash storage. +#updated 13 Sept 2007. copy-down only. flushing is done in petget. +#updated 24 Sept 2007. removed '-u' option when copy-down files. +#8 oct 2007: screen out /root/tmp when saving. +#4 nov 2007: reintroduce '-u' copy option. +#v4.01 19may2008 BK: now called from /sbin/pup_eventd daemon (savepuppyd now history). +#v4.01 19may2008 BK: if called from pup_eventd then X running: graceful exit if X shutdown. +#v409 BK: save /var dir. previously screened out to save space, but prevents crontab from running. +#v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc. +#w000 pup files renamed to woofr555.sfs, woofsave.2fs. +#w003 screened out some dirs in /dev that should not be saved. +#v424 fix for more layers in unionfs/aufs. +#100222 shinobar: possible timezone problem with BOOTCONFIG. more file exclusions. +#100422 added ^root/ftpd exclusion. +#100429 modify 'trash' exclusion. +#100820 added /var/tmp exclusion (apparently filled by opera crashes). +#101221 yaf-splash fix. +#110206 Dougal: clean up some testing. speedup: LANG=C, also change to /bin/ash. +#110212 Jemimah: files may disappear, more efficient calc of free space, fix i/o err. +#110222 shinobar: remove all /dev, allow 'pup_ro10-19', exit code for no space +#110224 BK: revert remove all /dev, for now. 110503 added dev/snd +#110505 support sudo for non-root user. +#111229 rerwin: fix jemimah code (110212). +#120103 rerwin: screen out /.XLOADED when save. +#140102 SFR: various fixes + gettext +#140512 SFR: performance improvements + +remove_merge_lock() { + if [ $? -ne 255 ]; then + [ -e /tmp/snapmergepuppy.lock ] && rm -f /tmp/snapmergepuppy.lock + fi +} + +trap remove_merge_lock EXIT +trap remove_merge_lock SIGKILL +trap remove_merge_lock SIGTERM + +[ -e /tmp/snapmergepuppy.lock ] && exit 255 + +export TEXTDOMAIN=snapmergepuppy +export OUTPUT_CHARSET=UTF-8 + +OLDLANG="$LANG" +export LANG=C + +#variables created at bootup by 'init' script in initramfs... +. /etc/rc.d/PUPSTATE +. /etc/DISTRO_SPECS + +[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} + +touch /tmp/snapmergepuppy.lock + +if [ $PUPMODE -ne 13 ] ; then + echo "$0: Wrong PUPMODE ($PUPMODE)" + exit 1 +fi + +SAVEPART="`echo -n "$PUPSAVE" | cut -f 1 -d ','`" + +SHUTDOWN="no" +pidof rc.shutdown >/dev/null && SHUTDOWN="yes" +XRUNNING="no" +pidof X >/dev/null 2>&1 || pidof Xorg >/dev/null 2>&1 || pidof Xwayland >/dev/null 2>&1 && XRUNNING="yes" + +PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin" +WD="`pwd`" + + # all the action takes places inside $SNAP +SNAP="/initrd/pup_rw" +cd $SNAP || exit 1 + +# files are copied from $SNAP/* to $BASE/ +BASE="/initrd/pup_ro1" +BASEDEV="`grep -m1 /initrd/mnt/dev_save /proc/mounts | cut -f 1 -d ' '`" + +# Precautions +[ "$BASEDEV" ] || { echo "$BASEDEV is not mounted!"; exit 1; } + +echo "Merging $SNAP onto $BASE..." + +# ============================================================================= +# WHITEOUTS +# ============================================================================= + +SFSPoints="`grep -m1 ^unionfs /proc/mounts | sed -E 's~.*lowerdir=([^,]+).*~\1~' | sed -e s~^~/initrd~ -e 's~:~\n/initrd~g' | grep -v '^/initrd/pup_ro1$' | tac`" + +find . -type c | sed -e 's/\.\///' | +while read -r N +do + DN="${N%/*}" + BN="${N##*/}" + [ "$DN" = "$N" ] || [ "$DN" = "" ] && DN="." + [ "$DN" = "." ] && continue + + [ "`stat -c '%t,%T' "$N" 2>/dev/null`" != '0,0' ] && continue + if [ -c "$BASE/$N" ]; then + [ "`stat -c '%t,%T' "$BASE/$N"`" = '0,0' ] && continue + fi + + rm -rf "$BASE/$N" + + #if file exists on a lower layer, have to save the whiteout file... + #110206 Dougal: speedup and refine the search... + for P in $SFSPoints + do + if [ -e "$P/$N" ] || [ -L "$P/$N" ] ; then # SFR: broken symlinks also deserve to be processed ( '-e' won't detect them, needs to be also '-L') + [ -d "${BASE}/${DN}" ] || mkdir -p "${BASE}/${DN}" + mknod "${BASE}/${N}" c 0 0 + break + fi + done #110206 End Dougal. +done + +# ============================================================================= +# DIRECTORIES +# ============================================================================= + +find . -mount -type d | tail +2 | sed -e 's/\.\///' | grep -v -E '^mnt|^media|^initrd|^proc|^sys|^tmp|^root/tmp|^dev|^var/tmp|^var/lock' | +while read -r N +do + #v4.01 graceful exit if shutdown X (see /usr/X11R7/bin/restartwm,wmreboot,wmpoweroff)... + [ "$XRUNNING" = "yes" ] && [ -f /tmp/wmexitmode.txt ] && exit + mkdir -p "$BASE/$N" + #i think nathan advised this, to handle non-root user (SFR: improved/simplified) + chmod "$BASE/$N" --reference="$N" + OWNERSHIP="`stat -c %u:%g "$N"`" + chown $OWNERSHIP "$BASE/$N" + touch "$BASE/$N" --reference="$N" +done + +# ============================================================================= +# FILES +# ============================================================================= + +FREEBASE=`df -B 1 | grep -m1 "^$BASEDEV" | tr -s ' ' | cut -f 4 -d ' '` #110212 Jemimah #110222 shinobar # SFR: result in bytes (see 'find' below) + +rm -f /tmp/snapmergepuppy-nospace #110222 shinobar +rm -f /tmp/snapmergepuppy-error #140102 SFR + +#Copy Files... v409 remove '^var'. 100222 shinobar: more exclusions. 100422 added ^root/ftpd. 100429 modify 'trash' exclusion. 100820 added var/tmp 120103 rerwin: add .XLOADED # SFR: added dev/snd # SFR: added .crdownload +# SFR: move as much as possible into 'find' itself +# Limitation - files with newline (\n) in its name are processed wrong (but this is not a new issue) +find . -mount \ + -not -path . \ + -not -type d \ + -not -type c \ + -regextype posix-extended \ + -not \( -regex '^./initrd.*|^./mnt.*|^./media.*|^./proc.*|^./sys.*|^./tmp.*|^./pup_.*|^./zdrv_.*|^./root/tmp.*|.*_zdrv_.*|^./dev.*|^./var/run.*|^./root/ftpd.*|^./var/tmp.*|^./var/lock.*|.*\.XLOADED$' \) \ + -not \( -regex '.*\.thumbnails.*|.*\.part$|.*\.crdownload$' \) \ + -printf "%C@ %s %P\n" | sort -rn | +while read -r NCTIME NSIZE N +do + #v4.01 graceful exit if shutdown X (see /usr/X11R7/bin/restartwm,wmreboot,wmpoweroff)... + [ "$XRUNNING" = "yes" ] && [ -f /tmp/wmexitmode.txt ] && exit + + if [ ! -e "$N" ] && [ ! -L "$N" ] ; then + continue # SFR: skip non-existing files (btw, '-e' won't detect broken symlinks, so '-L' is necessary!) + fi + + #stop saving if not enough room left in ${DISTRO_FILE_PREFIX}save file... + if [ $((NSIZE+204800)) -gt $FREEBASE ]; then # 204800 = 200K slack space + FREEBASE=`df -B 1 | grep -m1 "^$BASEDEV" | tr -s ' ' | cut -f 4 -d ' '` #110212 Jemimah: this is very slow; try not to check every iteration #110222 shinobar: fix for pup_ro10 and more + if [ $((NSIZE+204800)) -gt $FREEBASE ]; then #110212 Jemimah. + touch /tmp/snapmergepuppy-nospace #110222 shinobar + break + fi + else + FREEBASE=$((FREEBASE-NSIZE)) #110212 Jemimah: keep track of the worst case + fi + + if [ -L "$N" ];then + [ "`readlink "$BASE/$N" 2>/dev/null`" = "`readlink "$N"`" ] && continue + rm -rf "$BASE/$N" # SFR: in case if folder has been replaced with a symlink (cp won't overwrite a dir with a symlink) + cp -af "$N" "$BASE/$N" 2>>/tmp/snapmergepuppy-error + else + if [ ! -e "$BASE/$N" ] ; then + cp -af "$N" "$BASE/$N" 2>>/tmp/snapmergepuppy-error + elif [ ${NCTIME%%.*} -gt `stat -c %Z "$BASE/$N"` ] ; then + cp -af "$N" "$BASE/$N" 2>>/tmp/snapmergepuppy-error + fi + fi +done + +# ============================================================================= + +sync +cd "$WD" + +# ============================================================================= + +error_msg () { + if [ "$SHUTDOWN" = "no" -a "$XRUNNING" = "yes" ];then + export DISPLAY=':0' + /usr/lib/gtkdialog/box_splash -timeout 30 -close box -icon gtk-dialog-warning -bg red -text "$1" + else + echo "$1" + fi +} + +export LANG="$OLDLANG" +ERRSTATUS=0 + +if [ -f /tmp/snapmergepuppy-nospace ]; then #110222 shinobar + ERRMSG="$(gettext 'WARNING! +Unable to save all files. You need to delete some.')" + error_msg "$ERRMSG" + ERRSTATUS=1 +fi + +sed -i '/No such file or directory/d' /tmp/snapmergepuppy-error # discard errors caused by bad timing + +if [ -s /tmp/snapmergepuppy-error ]; then #140102 SFR + ERRMSG="$(gettext "WARNING! +There were some errors detected. +(see '/tmp/snapmergepuppy-error' for details) +Filesystem check of the savefile (pfix=fsck) is highly recommended.")" + error_msg "$ERRMSG" + ERRSTATUS=1 +fi + +exit $ERRSTATUS + +# ============================================================================= diff --git a/woof-code/support/mk_iso.sh b/woof-code/support/mk_iso.sh index 2c73e0e2278..0b6e46159c7 100755 --- a/woof-code/support/mk_iso.sh +++ b/woof-code/support/mk_iso.sh @@ -255,6 +255,9 @@ title pdev1=sdc1 The boot partition.\nPress Enter to go back to main menu title psubdir=/pathto/slacko64 Path in which the OS is installed.\nPress Enter to go back to main menu configfile /boot/grub/menu.lst +title punionfs=aufs Union file system to use.\n aufs overlay + configfile /boot/grub/menu.lst + title psavemark=2 Partition no. (in boot drive) to save session to.\nPress Enter to go back to main menu configfile /boot/grub/menu.lst