woof-CE icon indicating copy to clipboard operation
woof-CE copied to clipboard

filemnt fails to "install" SFSs in frugalified pups

Open mavrothal opened this issue 3 years ago • 2 comments

Here is a rough patch to help with SFS installation in frugalified PUPMODE 6. Should probably be harden and look for the layer system too.

--- a/usr/sbin/filemnt	2022-01-29 02:38:32.000000000 +0200
+++ b/usr/sbin/filemnt	2022-02-03 17:09:17.911926864 +0200
@@ -2,6 +2,7 @@
 # assume squashfs 4.0
 
 . /etc/DISTRO_SPECS
+. /etc/rc.d/PUPSTATE
 
 export TEXTDOMAIN=filemnt
 export OUTPUT_CHARSET=UTF-8
@@ -125,13 +126,20 @@
         LABELINSTALL="$(gettext 'Install SFS')"
         TEXTINSTALL="$(gettext 'install it')"
       fi
-      SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL}.")" #'geany
-      SFSMSG1b="$(gettext 'Regarding the latter, traditionally SFS files are selected by the <b>BootManager</b> for loading at bootup (see System menu), which you can do, or you can choose to install (load) it now (which will not require a reboot).')"
-      SFSMSG1c="$(gettext 'Note1: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
-      SFSMSG1d="$(gettext 'Note2: In the case of a full HD installation, without a layered filesystem, installation is irreversible. For all other installation modes, the BootManager can be used to unload an installed (loaded) SFS file.')"
+      if [ $PUPMODE -eq 6 ];then
+        SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL} (requires reboot).")" #'geany
+        SFSMSG1b="$(gettext 'Regarding the latter, the SFS file will be moved at /mnt/home and will be loaded at startup. In this PUPMODE to install (load) a new SFS requires reboot.')"
+        SFSMSG1d="$(gettext 'Note2: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
+        SFSMSG1c="$(gettext 'Note1: To uninstall the SFS file just remove it from the root of the partition to another place and reboot.')"     
+      else
+        SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL}.")" #'geany
+        SFSMSG1b="$(gettext 'Regarding the latter, traditionally SFS files are selected by the <b>BootManager</b> for loading at bootup (see System menu), which you can do, or you can choose to install (load) it now (which will not require a reboot).')"
+        SFSMSG1c="$(gettext 'Note1: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
+        SFSMSG1d="$(gettext 'Note2: In the case of a full HD installation, without a layered filesystem, installation is irreversible. For all other installation modes, the BootManager can be used to unload an installed (loaded) SFS file.')"
+      fi
       /usr/lib/gtkdialog/box_yesno --yes-first --yes-label "$(gettext 'View contents')" --no-label "$LABELINSTALL"  --extra-button "$(gettext 'Cancel')" --no-icon package_sfs.svg --extra-icon close.svg "${imgFileBASE}" "${SFSMSG1a}" "${SFSMSG1b}" "${SFSMSG1c}" "${SFSMSG1d}"
       RETVAL=$?
-      [ $RETVAL -eq 1 ] && exec sfs_load "$1"
+      [ $RETVAL -eq 1 ] && [ $PUPMODE -eq 6 ] && mv "$1" /initrd/ ||  exec sfs_load "$1"
       [ $RETVAL -ne 0 ] && exit #120527
   else
      /usr/lib/gtkdialog/box_yesno --yes-first "Filemnt: Mount Image" "Do you want to mount this image?" "$imgFileBASE"

mavrothal avatar Feb 03 '22 18:02 mavrothal

Here is a better one (sorry no git or gihub fork now days ☺️ )

--- a/usr/sbin/filemnt	2022-01-29 02:38:32.000000000 +0200
+++ b/usr/sbin/filemnt	2022-02-05 08:58:41.271978684 +0200
@@ -2,6 +2,7 @@
 # assume squashfs 4.0
 
 . /etc/DISTRO_SPECS
+. /etc/rc.d/PUPSTATE
 
 export TEXTDOMAIN=filemnt
 export OUTPUT_CHARSET=UTF-8
@@ -125,13 +126,27 @@
         LABELINSTALL="$(gettext 'Install SFS')"
         TEXTINSTALL="$(gettext 'install it')"
       fi
-      SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL}.")" #'geany
-      SFSMSG1b="$(gettext 'Regarding the latter, traditionally SFS files are selected by the <b>BootManager</b> for loading at bootup (see System menu), which you can do, or you can choose to install (load) it now (which will not require a reboot).')"
-      SFSMSG1c="$(gettext 'Note1: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
-      SFSMSG1d="$(gettext 'Note2: In the case of a full HD installation, without a layered filesystem, installation is irreversible. For all other installation modes, the BootManager can be used to unload an installed (loaded) SFS file.')"
+      if [ $PUPMODE -eq 6 -a "$PUNIONFS" = "overlay" ];then
+        SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL} (requires reboot).")" #'geany
+        SFSMSG1b="$(gettext 'Regarding the latter, the SFS file will be moved at /mnt/home and will be loaded at startup. In this pupmode to install (load) a new SFS requires reboot.')"
+        SFSMSG1c="$(gettext 'Note1: To uninstall the SFS file just remove it from the root of the partition to another place and reboot.')"
+        SFSMSG1d="$(gettext 'Note2: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"    
+      else
+        SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL}.")" #'geany
+        SFSMSG1b="$(gettext 'Regarding the latter, traditionally SFS files are selected by the <b>BootManager</b> for loading at bootup (see System menu), which you can do, or you can choose to install (load) it now (which will not require a reboot).')"
+        SFSMSG1c="$(gettext 'Note1: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
+        SFSMSG1d="$(gettext 'Note2: In the case of a full HD installation, without a layered filesystem, installation is irreversible. For all other installation modes, the BootManager can be used to unload an installed (loaded) SFS file.')"
+      fi
       /usr/lib/gtkdialog/box_yesno --yes-first --yes-label "$(gettext 'View contents')" --no-label "$LABELINSTALL"  --extra-button "$(gettext 'Cancel')" --no-icon package_sfs.svg --extra-icon close.svg "${imgFileBASE}" "${SFSMSG1a}" "${SFSMSG1b}" "${SFSMSG1c}" "${SFSMSG1d}"
       RETVAL=$?
-      [ $RETVAL -eq 1 ] && exec sfs_load "$1"
+      if [ $RETVAL -eq 1 ]; then
+        if [ $PUPMODE -eq 6 -a "$PUNIONFS" = "overlay" ];then
+          mv "$1" /initrd/
+          /usr/lib/gtkdialog/box_ok "$(gettext "Reboot is needed")" info "$(gettext "The ${imgFileBASE} SFS will be loaded upon reboot")"
+        else  
+          exec sfs_load "$1"
+        fi
+      fi
       [ $RETVAL -ne 0 ] && exit #120527
   else
      /usr/lib/gtkdialog/box_yesno --yes-first "Filemnt: Mount Image" "Do you want to mount this image?" "$imgFileBASE"

mavrothal avatar Feb 07 '22 11:02 mavrothal

Added the ability to view the contents of an SFS already in the overlayfs

--- a/usr/sbin/filemnt
+++ b/usr/sbin/filemnt
@@ -2,6 +2,7 @@
 # assume squashfs 4.0
 
 . /etc/DISTRO_SPECS
+. /etc/rc.d/PUPSTATE
 
 export TEXTDOMAIN=filemnt
 export OUTPUT_CHARSET=UTF-8
@@ -125,13 +126,31 @@
         LABELINSTALL="$(gettext 'Install SFS')"
         TEXTINSTALL="$(gettext 'install it')"
       fi
-      SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL}.")" #'geany
-      SFSMSG1b="$(gettext 'Regarding the latter, traditionally SFS files are selected by the <b>BootManager</b> for loading at bootup (see System menu), which you can do, or you can choose to install (load) it now (which will not require a reboot).')"
-      SFSMSG1c="$(gettext 'Note1: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
-      SFSMSG1d="$(gettext 'Note2: In the case of a full HD installation, without a layered filesystem, installation is irreversible. For all other installation modes, the BootManager can be used to unload an installed (loaded) SFS file.')"
+      if [ $PUPMODE -eq 6 -a "$PUNIONFS" = "overlay" ];then
+        SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL} (requires reboot).")" #'geany
+        SFSMSG1b="$(gettext 'Regarding the latter, the SFS file will be moved at /mnt/home and will be loaded at startup. In this pupmode to install (load) a new SFS requires reboot.')"
+        SFSMSG1c="$(gettext 'Note1: To uninstall the SFS file just remove it from the root of the partition to another place and reboot.')"
+        SFSMSG1d="$(gettext 'Note2: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"    
+      else
+        SFSMSG1a="$(eval_gettext "You can choose to mount the ${imgFileBASE} file to view it's contents (read-only), or you can ${TEXTINSTALL}.")" #'geany
+        SFSMSG1b="$(gettext 'Regarding the latter, traditionally SFS files are selected by the <b>BootManager</b> for loading at bootup (see System menu), which you can do, or you can choose to install (load) it now (which will not require a reboot).')"
+        SFSMSG1c="$(gettext 'Note1: If you want to edit the contents of an SFS file, you have to use the commandline utilities <b>unsquashfs</b> and <b>mksquashfs</b>.')"
+        SFSMSG1d="$(gettext 'Note2: In the case of a full HD installation, without a layered filesystem, installation is irreversible. For all other installation modes, the BootManager can be used to unload an installed (loaded) SFS file.')"
+      fi
       /usr/lib/gtkdialog/box_yesno --yes-first --yes-label "$(gettext 'View contents')" --no-label "$LABELINSTALL"  --extra-button "$(gettext 'Cancel')" --no-icon package_sfs.svg --extra-icon close.svg "${imgFileBASE}" "${SFSMSG1a}" "${SFSMSG1b}" "${SFSMSG1c}" "${SFSMSG1d}"
       RETVAL=$?
-      [ $RETVAL -eq 1 ] && exec sfs_load "$1"
+      if [ $RETVAL -eq 1 ]; then
+        if [ $PUPMODE -eq 6 -a "$PUNIONFS" = "overlay" ];then
+          if [ "$(dirname "$1")" != "/mnt/home" ]; then
+            mv "$1" /initrd/
+            /usr/lib/gtkdialog/box_ok "$(gettext "Reboot is needed")" info "$(gettext "The ${imgFileBASE} SFS will be loaded upon reboot")"
+          else
+            /usr/lib/gtkdialog/box_ok "$(gettext "Load on Reboot")" info "$(gettext "The ${imgFileBASE} SFS will be loaded (again) upon reboot")" # need a test for the SFSs already in union
+          fi
+        else  
+          exec sfs_load "$1"
+        fi
+      fi
       [ $RETVAL -ne 0 ] && exit #120527
   else
      /usr/lib/gtkdialog/box_yesno --yes-first "Filemnt: Mount Image" "Do you want to mount this image?" "$imgFileBASE"
@@ -198,7 +217,12 @@
            wimmount "$imgFile" "$MOUNTPOINT"
          ;;
       *) 
-         mount -t ${Type} -o loop,rw "$imgFile" "$MOUNTPOINT"
+         if [ $PUPMODE -eq 6 -a "$PUNIONFS" = "overlay" ];then
+           losetup "$DEVLOOP" "$imgFile"
+           mount -t ${Type} -o loop,rw "$DEVLOOP" "$MOUNTPOINT"
+         else
+           mount -t ${Type} -o loop,rw "$imgFile" "$MOUNTPOINT"
+         fi
          ;;
     esac
     Err=$?

mavrothal avatar Feb 09 '22 19:02 mavrothal