-
Notifications
You must be signed in to change notification settings - Fork 11
Fix setup on OS 3.27+ (hashtab) and 3.28+ (AppLoad hooks) #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
frapeti
wants to merge
1
commit into
MaximeRivest:main
Choose a base branch
from
frapeti:fix/os-3.27-hashtab-and-3.28-appload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| *.tar.gz | ||
| *.zip | ||
| *.so | ||
| !cli/embedded/ | ||
| !cli/embedded/*.so | ||
| *.swp | ||
| .DS_Store | ||
| cli/remagic | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| _ "embed" | ||
| "strconv" | ||
| "strings" | ||
| ) | ||
|
|
||
| // Upstream v0.5.3 hooks target OS <=3.27. On 3.28+ the sidebar QML moved and | ||
| // appload panics with "Couldn't resolve the hashed identifier … AppLoad hooks". | ||
| // Built from asivery/rm-appload PR #59 until a stable upstream release ships. | ||
| // | ||
| //go:embed embedded/appload-3.28-aarch64.so | ||
| var appload328 []byte | ||
|
|
||
| func osNeedsAppLoad328(osv string) bool { | ||
| parts := strings.Split(strings.TrimSpace(osv), ".") | ||
| if len(parts) < 2 || parts[0] != "3" { | ||
| return false | ||
| } | ||
| minor, err := strconv.Atoi(parts[1]) | ||
| return err == nil && minor >= 28 | ||
| } | ||
|
|
||
| func apploadSOForOS(osv string) ([]byte, string) { | ||
| if osNeedsAppLoad328(osv) { | ||
| return appload328, "3.28 (PR #59 build — upstream v0.5.3 breaks on this OS)" | ||
| } | ||
| return nil, "" | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/maximerivest/remagic/cli/internal/device" | ||
| ) | ||
|
|
||
| // rebuildHashtabScript drives xochitl with only qt-resource-rebuilder loaded | ||
| // and waits until the per-OS-version hashtab file exists. Upstream's | ||
| // rebuild_hashtable blocks on "press enter" and remagic's old setup used | ||
| // `timeout … rebuild_hashtable </dev/null`, which fails on device images | ||
| // without coreutils timeout — leaving AppLoad to crash-loop xochitl on | ||
| // OS 3.27+ when the hashtab is missing. | ||
| const rebuildHashtabScript = ` | ||
| set -u | ||
| xovi=/home/root/xovi | ||
| qrr_so="$xovi/extensions.d/qt-resource-rebuilder.so" | ||
| qrr_dir="$xovi/exthome/qt-resource-rebuilder" | ||
| hashtab="$qrr_dir/hashtab" | ||
| xovi_root=/tmp/xovi-hashtab-build | ||
| log=/tmp/xovi-hashtab.log | ||
|
|
||
| if [ ! -f "$qrr_so" ]; then | ||
| echo "qt-resource-rebuilder not installed" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| systemctl stop xochitl 2>/dev/null || true | ||
| for sig in 15 9; do | ||
| pid=$(pidof xochitl 2>/dev/null || true) | ||
| [ -n "$pid" ] || break | ||
| kill -$sig $pid 2>/dev/null || true | ||
| sleep 1 | ||
| done | ||
|
|
||
| rm -rf "$xovi_root" "$log" | ||
| mkdir -p "$xovi_root/extensions.d" "$qrr_dir" | ||
| ln -sf "$qrr_so" "$xovi_root/extensions.d/" | ||
| rm -f "$hashtab" | ||
|
|
||
| export XOVI_ROOT="$xovi_root" | ||
| QMLDIFF_HASHTAB_CREATE="$hashtab" \ | ||
| QML_DISABLE_DISK_CACHE=1 \ | ||
| LD_PRELOAD="$xovi/xovi.so" \ | ||
| /usr/bin/xochitl >>"$log" 2>&1 & | ||
| xpid=$! | ||
|
|
||
| deadline=$(($(date +%s) + 180)) | ||
| ok=0 | ||
| while [ "$(date +%s)" -lt "$deadline" ]; do | ||
| if [ -s "$hashtab" ]; then | ||
| ok=1 | ||
| break | ||
| fi | ||
| if grep -qF "[qmldiff]: Hashtab saved to $hashtab" "$log" 2>/dev/null; then | ||
| ok=1 | ||
| break | ||
| fi | ||
| if ! kill -0 "$xpid" 2>/dev/null; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| pid=$(pidof xochitl 2>/dev/null || true) | ||
| [ -n "$pid" ] && kill -15 $pid 2>/dev/null || true | ||
| sleep 1 | ||
| pid=$(pidof xochitl 2>/dev/null || true) | ||
| [ -n "$pid" ] && kill -9 $pid 2>/dev/null || true | ||
|
|
||
| rm -rf "$xovi_root" | ||
|
|
||
| if [ "$ok" = 1 ] && [ -s "$hashtab" ]; then | ||
| echo "Hashtab rebuilt at $hashtab" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Hashtab rebuild failed." >&2 | ||
| echo "--- last log lines ---" >&2 | ||
| tail -30 "$log" 2>/dev/null >&2 || true | ||
| exit 1 | ||
| ` | ||
|
|
||
| const hashtabPath = "/home/root/xovi/exthome/qt-resource-rebuilder/hashtab" | ||
|
|
||
| // rebuildHashtab runs the non-interactive rebuild on the tablet. Returns true | ||
| // when qt-resource-rebuilder is absent (nothing to do) or the hashtab exists. | ||
| func rebuildHashtab(d *device.Device) bool { | ||
| if _, err := d.Run("test -f /home/root/xovi/extensions.d/qt-resource-rebuilder.so"); err != nil { | ||
| ok("not needed (no qt-resource-rebuilder in this bundle)") | ||
| return true | ||
| } | ||
| out, err := d.RunIn("bash -s", strings.NewReader(rebuildHashtabScript)) | ||
| out = strings.TrimSpace(out) | ||
| if err != nil { | ||
| if out != "" { | ||
| for _, line := range strings.Split(out, "\n") { | ||
| warn("%s", strings.TrimSpace(line)) | ||
| } | ||
| } | ||
| warn("AppLoad needs this hashtab on OS 3.27+ — without it xochitl crash-loops") | ||
| warn("retry with: remagic rebuild-hashtab") | ||
| return false | ||
| } | ||
| if out != "" { | ||
| ok("%s", out) | ||
| } else { | ||
| ok("hashtable rebuilt") | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| // hasHashtab reports whether the on-device hashtab file exists and is non-empty. | ||
| func hasHashtab(d *device.Device) bool { | ||
| _, err := d.Run("test -s " + hashtabPath) | ||
| return err == nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the rebuild times out or xochitl exits before writing the hashtab, this failure path returns after the script has already run
systemctl stop xochitland killed any remaining process, andcmdSetupthen skips/home/root/xovi/startwhenhashtabOKis false. That leaves the tablet with no running xochitl/UI until the user reboots or manually starts it; the duplicatedscripts/rebuild-hashtab.shhas the same failure path. Please start stock xochitl (or otherwise restore the prior UI state) before exiting with failure.Useful? React with 👍 / 👎.