Commit 51aa646
committed
runtime: Always use link target for /proc/self/exe
When running an AppImage under [gcompat][0] (e.g. on Alpine Linux),
`fopen("/proc/self/exe", "rb")` opens the dynamic linker (e.g.
`/lib/ld-musl-x86_64.so.1`) instead of the AppImage itself. However,
`readlink("/proc/self/exe", ...)` does give the path to the AppImage as
expected, even under gcompat.
This commit fixes this problem by always using the link target for
`/proc/self/exe` in places that read the AppImage instead of the link
itself. Without this commit, running an AppImage under gcompat results
in [the error message "This doesn't look like a squashfs image." from
squashfuse][1]. With this commit, AppImages run as expected under
gcompat.
In order to make `--appimage-help` and
`--appimage-portable-{home,config}` work under gcompat, I also move the
calculation of the `fullpath` variable in `main()` to earlier in the
function and change `print_help()` and `portable_option()` to use it
instead of calculating the fullpath separately. (When
`$TARGET_APPIMAGE` is set, since `realpath()` is (already) used instead
of `readlink()` in that case, this change could result in a different
path being used in help output and when _creating_ the portable home and
config directories with the respective command line options, but
`fullpath` is already being used to find existing portable directories
when running an AppImage, so this should not affect existing portable
installations.) For consistency, I also rename the `fullpath` variable
in `main()` and the corresponding arguments in `print_help()` and
`portable_option()` to `appimage_fullpath`.
Fixes #1015 on Alpine Linux systems with gcompat installed, for
AppImages made with this commit applied.
Tested on Alpine Linux edge x86_64 and postmarketOS (based on Alpine)
edge aarch64.
[0]: https://git.adelielinux.org/adelie/gcompat/
[1]: https://github.com/vasi/squashfuse/blob/e51978cd6bb5c4d16fae9eee43d0b258f570bb0f/util.c#L81-L821 parent a2d9cfc commit 51aa646
1 file changed
+38
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
| 247 | + | |
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | 258 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 259 | + | |
268 | 260 | | |
269 | 261 | | |
270 | 262 | | |
| |||
536 | 528 | | |
537 | 529 | | |
538 | 530 | | |
539 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
| |||
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
580 | 598 | | |
581 | 599 | | |
582 | 600 | | |
| |||
599 | 617 | | |
600 | 618 | | |
601 | 619 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
| 620 | + | |
612 | 621 | | |
613 | 622 | | |
614 | 623 | | |
| |||
642 | 651 | | |
643 | 652 | | |
644 | 653 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | 654 | | |
668 | 655 | | |
669 | 656 | | |
| |||
727 | 714 | | |
728 | 715 | | |
729 | 716 | | |
730 | | - | |
| 717 | + | |
731 | 718 | | |
732 | 719 | | |
733 | 720 | | |
| |||
785 | 772 | | |
786 | 773 | | |
787 | 774 | | |
788 | | - | |
789 | | - | |
| 775 | + | |
| 776 | + | |
790 | 777 | | |
791 | 778 | | |
792 | 779 | | |
| |||
908 | 895 | | |
909 | 896 | | |
910 | 897 | | |
911 | | - | |
| 898 | + | |
912 | 899 | | |
913 | 900 | | |
914 | 901 | | |
915 | 902 | | |
916 | 903 | | |
917 | 904 | | |
918 | 905 | | |
919 | | - | |
| 906 | + | |
920 | 907 | | |
921 | 908 | | |
922 | 909 | | |
923 | 910 | | |
924 | 911 | | |
925 | 912 | | |
926 | 913 | | |
927 | | - | |
| 914 | + | |
928 | 915 | | |
929 | 916 | | |
930 | 917 | | |
| |||
0 commit comments