According to USB_INSTALLATION.txt, it's intended to work "From any Linux Distribution other than Porteus".
Issues 2-3 are caused by Ubuntu's default handling of ownership and permissions on FAT filesystems.
- The installer tries to parse the target device from $PWD, but Ubuntu mounts storage devices at /media/USER_NAME/VOLUME_LABEL (rather than the expected /mnt/DEV_NAME), so that is not possible on Ubuntu.
Installer result: "Installing Porteus to /dev/josh" (which doesn't exist). There's a universal POSIX way to do this instead (see below).
. - Ubuntu does not silently ignore chown on a FAT filesystem, causing MakeSelf's default targetdir="." to fail UnTAR(), and the installer thus terminates with "Extraction failed." (tar's default behavior as root is --same-owner, which performs chown.)
. - Ubuntu uses an opaque heuristic to determine executable permissions on a FAT filesystem, by default. Ultimately, the extlinux binary cannot be run when extracted to the target device.
The POSIX-guaranteed way to acquire the device node name from a directory is by parsing the output of df -P <dirname>.
The code you currently have is this:
Code: Select all
PRT=/dev/`echo $PWD | cut -d/ -f3`
MPT=/mnt/`echo $PWD | cut -d/ -f3`
DEV=/dev/`lsblk -ndo pkname $PRT`
PRTN=`echo ${PRT#"$DEV"} | sed 's/[^0-9]*//g'`
and so the installer says "Installing Porteus to /dev/USER_NAME" (which obviously doesn't exist).
These replacement definitions should be portable for all Linux, and work fine for Ubuntu:
Code: Select all
PRT="$(df -P "$PWD" | grep -o '^/dev/[^ ]\+')"
MPT="$(grep "^$PRT" /proc/mounts | cut -d' ' -f2)"
If you try to workaround issues #2-3 by invoking the installer with "--target /tmp" (or some other Unix-compatible filesystem), then the inner installer.com's $PWD is no longer on the target device, and so it fails to detect the target device even if issue #1 was fixed.
The only simple workaround I found for issue #2 was adding --no-same-owner to the tar command:
Code: Select all
UnTAR()
{
if test x"$quiet" = xn; then
tar $1vf - --no-same-owner 2>&1 || { echo " ... Extraction failed." >&2; kill -15 $$; }
else
tar $1f - --no-same-owner 2>&1 || { echo Extraction failed. >&2; kill -15 $$; }
fi
}
This is where it gets uglier...
The installer pack extracted to a FAT filesystem on Ubuntu (tested 22.04) had the following permissions:
Code: Select all
-rw-r--r-- 1 root root 208480 Feb 17 16:36 extlinux.x32
-rw-r--r-- 1 root root 209424 Feb 17 16:36 extlinux.x64
-rwxr-xr-x 1 root root 5589 Feb 17 16:36 installer.com
-rwxr-xr-x 1 root root 95392 Feb 17 16:36 lilo.com
-rw-r--r-- 1 root root 440 Feb 17 16:36 mbr.bin
Anyway, LILO and the entry script are OK, but AFAIK the only way to run extlinux from FAT on Ubuntu is using the ld interpreter trick. The interpreter paths are hardcoded into the binaries (check them by running "file <binary>"), so it should be safe.
That was the only way I was able to get the installer to work on Ubuntu.
Basically, you'd need to change this line in installer.com:
Code: Select all
$bin/$extlinux -i "$IPT"/syslinux >/dev/null 2>&1
Code: Select all
/lib64/ld-linux-x86-64.so.2 $bin/$extlinux -i "$IPT"/syslinux >/dev/null 2>&1
Code: Select all
/lib/ld-linux.so.2 $bin/$extlinux -i "$IPT"/syslinux >/dev/null 2>&1
These are ugly approaches for #2-3, IMO. I think it would be cleaner and safer for the MakeSelf script to extract its payload to "/tmp" by default, and then pass its own launch location to the inner script as a "--target-dir" param. Then the inner installer.com would use that param to determine the target device.
Just a suggestion.