diff --git a/src/build-runtime.sh.in b/src/build-runtime.sh.in index 8455f6683..bc7d9b4ce 100755 --- a/src/build-runtime.sh.in +++ b/src/build-runtime.sh.in @@ -66,9 +66,20 @@ HEXOFFSET=$(objdump -h runtime | grep .upd_info | awk '{print $6}') HEXLENGTH=$(objdump -h runtime | grep .upd_info | awk '{print $3}') dd bs=1 if=runtime skip=$(($(echo 0x$HEXOFFSET)+0)) count=$(($(echo 0x$HEXLENGTH)+0)) | xxd +APPIMAGEOFFSET=$(./runtime --appimage-offset) + # Insert AppImage magic bytes printf '\x41\x49\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc +# Pad runtime to multiple of 512bytes +dd if=/dev/null of=runtime bs=1 count=1 seek=$APPIMAGEOFFSET + +# Add boot signature to runtime, this way fdisk recognize the appimage as a partitioned disk image +printf '\x55\xaa' | dd of=runtime bs=1 seek=510 count=2 conv=notrunc + +# Add partition entry to runtime, this way gnome-disk-image-mounter can open it. +printf "0x%08x" $((APPIMAGEOFFSET / 512 )) | xxd -r | tac -rs. | dd of=runtime bs=1 seek=454 count=4 conv=notrunc + # Convert runtime into a data object that can be embedded into appimagetool ld -r -b binary -o data.o runtime diff --git a/src/runtime.c b/src/runtime.c index e3c69c138..99052fa83 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -289,7 +289,9 @@ main (int argc, char *argv[]) sprintf(argv0_path, argv[0]); fs_offset = get_elf_size(appimage_path); - + /*It's better to keep filesystems aligned at 512bytes intervals, like sectors on a real partitioned disk*/ + fs_offset = ((fs_offset-1)|511)+1; + arg=getArg(argc,argv,'-'); /* Print the help and then exit */