Improved script portability #19

Merged
depsterr merged 5 commits from depsterr/master into master 2021-07-06 19:17:33 +00:00
depsterr commented 2021-03-06 16:09:42 +00:00 (Migrated from github.com)

This PR improves the script portability in a multitude of ways. The script still retains all functionality and will be identical to the end user.

The most significant of which is porting the script from bash to sh, this means that systems which do not have bash preinstalled (e.g alpinelinux) don't have to install bash to run it.

The script has also been changed to support the busybox wget implementation, yet still use the --show-progress flag if present. The script can now also use curl instead of wget if wget is not installed but curl is.

The script now also supports using other methods of running commands as root, meaning users who prefer doas to sudo won't have to install sudo. Additionally, if neither doas nor sudo is found the script will now use su which should be present on all systems.

The scripts indentation has also been fixed so that it's easier to tell what code belongs to which logical block. Multiple prints after each other have been replaced with single multiline prints. Printing to stderr and exiting has been moved into a function. Variables have been quoted in order to avoid unwanted splitting (which could case errors).

This PR improves the script portability in a multitude of ways. The script still retains all functionality and will be identical to the end user. The most significant of which is porting the script from bash to sh, this means that systems which do not have bash preinstalled (e.g alpinelinux) don't have to install bash to run it. The script has also been changed to support the busybox wget implementation, yet still use the `--show-progress` flag if present. The script can now also use curl instead of wget if wget is not installed but curl is. The script now also supports using other methods of running commands as root, meaning users who prefer `doas` to `sudo` won't have to install sudo. Additionally, if neither doas nor sudo is found the script will now use `su` which should be present on all systems. The scripts indentation has also been fixed so that it's easier to tell what code belongs to which logical block. Multiple prints after each other have been replaced with single multiline prints. Printing to stderr and exiting has been moved into a function. Variables have been quoted in order to avoid unwanted splitting (which could case errors).
white-gecko commented 2021-03-08 18:58:04 +00:00 (Migrated from github.com)
I've resolved the merge conflict in https://github.com/white-gecko/flash-it/tree/feature/mergePortable
white-gecko commented 2021-03-08 19:00:10 +00:00 (Migrated from github.com)

The build process appeared to terminate correctly but actually did not prepare the SD card for the boot, so it does not boot.

Flashing rootFS...
Archive:  pinephone-1.1-rootfs.zip
  inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/Jolla-3.4.0.24-pinephone-1.1-armv7hl.ks  
  inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/Jolla-3.4.0.24-pinephone-1.1-armv7hl.packages  
  inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/Jolla-3.4.0.24-pinephone-1.1-armv7hl.urls  
  inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/sfe-pinephone-1.1-3.4.0.24-devel-20210301.tar.bz2  
pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/sfe-pinephone-1.1-3.4.0.24-devel-20210301.tar.bz2
Copying kernel to boot partition...
Boot partition mount: ./boot
cp: der Aufruf von stat für './data/boot/*' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
./boot
Cleaning up!
Unmounting /dev/sda
umount: /dev/sda: not mounted.
Unmounting /dev/sda1
Unmounting /dev/sda2
Flashing /dev/sda OK!
You may now remove the SD card and insert it in your Pine64 device!

Sorry, the error output is in German cp: der Aufruf von stat für './data/boot/*' ist nicht möglich: Datei oder Verzeichnis nicht gefunden. It is just tells, that './data/boot/*' does not exist. Actually ./data/boot/ exists and has content, it has to be some problem with the * in /bin/sh in combination with the implementation of as_root.

The build process appeared to terminate correctly but actually did not prepare the SD card for the boot, so it does not boot. ``` Flashing rootFS... Archive: pinephone-1.1-rootfs.zip inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/Jolla-3.4.0.24-pinephone-1.1-armv7hl.ks inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/Jolla-3.4.0.24-pinephone-1.1-armv7hl.packages inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/Jolla-3.4.0.24-pinephone-1.1-armv7hl.urls inflating: pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/sfe-pinephone-1.1-3.4.0.24-devel-20210301.tar.bz2 pinephone-1.1/sfe-pinephone-1.1-3.4.0.24-devel-20210301/sfe-pinephone-1.1-3.4.0.24-devel-20210301.tar.bz2 Copying kernel to boot partition... Boot partition mount: ./boot cp: der Aufruf von stat für './data/boot/*' ist nicht möglich: Datei oder Verzeichnis nicht gefunden ./boot Cleaning up! Unmounting /dev/sda umount: /dev/sda: not mounted. Unmounting /dev/sda1 Unmounting /dev/sda2 Flashing /dev/sda OK! You may now remove the SD card and insert it in your Pine64 device! ``` Sorry, the error output is in German `cp: der Aufruf von stat für './data/boot/*' ist nicht möglich: Datei oder Verzeichnis nicht gefunden`. It is just tells, that `'./data/boot/*'` does not exist. Actually `./data/boot/` exists and has content, it has to be some problem with the `*` in `/bin/sh` in combination with the implementation of `as_root`.
white-gecko commented 2021-03-08 20:28:40 +00:00 (Migrated from github.com)

Once this is done, it will also fix #21 and #22.

Once this is done, it will also fix #21 and #22.
depsterr commented 2021-03-09 17:13:30 +00:00 (Migrated from github.com)

working on a fix for the copying issue

working on a fix for the copying issue
depsterr commented 2021-03-09 17:30:04 +00:00 (Migrated from github.com)

The issue seems to be that data/boot/ is only readable by root, and that the /* expands as the user running the script, not by sudo. Since the user cannot read this directory it expands to ./data/boot/* instead of the list of files. This can just be solved by allowing all users to read the directory before doing the copy.

as_root chmod a+rx "$MOUNT_DATA/boot"

Just gonna go through the script once, flashing to my SD card before I commit the changes.

The issue seems to be that data/boot/ is only readable by root, and that the /* expands as the user running the script, not by sudo. Since the user cannot read this directory it expands to `./data/boot/*` instead of the list of files. This can just be solved by allowing all users to read the directory before doing the copy. ```sh as_root chmod a+rx "$MOUNT_DATA/boot" ``` Just gonna go through the script once, flashing to my SD card before I commit the changes.
depsterr commented 2021-03-09 17:59:33 +00:00 (Migrated from github.com)

Ran the script! It now copies successfully. I'm not to sure what conflicts should be resolved to be able to merge this, but I guess I'll look into it.

Ran the script! It now copies successfully. I'm not to sure what conflicts should be resolved to be able to merge this, but I guess I'll look into it.
depsterr commented 2021-03-09 18:17:38 +00:00 (Migrated from github.com)

There we go! I merged master and redid the changes from the 4 commits since my fork.

There we go! I merged master and redid the changes from the 4 commits since my fork.
white-gecko (Migrated from github.com) requested changes 2021-03-09 18:31:51 +00:00
white-gecko (Migrated from github.com) commented 2021-03-09 18:31:41 +00:00

This should be

for opt in "PinePhone 1.0 (Development) device" "PinePhone 1.1 (Brave Heart) or 1.2 (Community Editions) device" "PineTab device" "PineTab Dev device" "Dont Be Evil devkit"; do

something came out duplicated

This should be for opt in "PinePhone 1.0 (Development) device" "PinePhone 1.1 (Brave Heart) or 1.2 (Community Editions) device" "PineTab device" "PineTab Dev device" "Dont Be Evil devkit"; do something came out duplicated
depsterr (Migrated from github.com) reviewed 2021-03-09 18:50:21 +00:00
depsterr (Migrated from github.com) commented 2021-03-09 18:50:21 +00:00

thank you, solved!

thank you, solved!
white-gecko commented 2021-03-09 21:31:19 +00:00 (Migrated from github.com)

Flash an boot successful for me.

Flash an boot successful for me.
white-gecko (Migrated from github.com) approved these changes 2021-03-09 21:32:06 +00:00
white-gecko (Migrated from github.com) left a comment

Looks got to me, the bugs I have discovered have existed before already ;-) (#24)

Looks got to me, the bugs I have discovered have existed before already ;-) (#24)
crt0mega merged commit 2378c7cd14 into master 2021-07-06 19:17:33 +00:00
Sign in to join this conversation.
No description provided.