Permalink
Browse files

Use patched mksquashfs --offset feature (#277)

  • Loading branch information...
1 parent c48f645 commit 29decf8db2d53c83c43b8027187bf00f9efa67b8 @probonopd committed on GitHub Nov 12, 2016
Showing with 35 additions and 39 deletions.
  1. +2 −3 .travis.yml
  2. +20 −34 appimagetool.c
  3. +2 −2 build-appdirs.sh
  4. +11 −0 resources/AppRun
View
@@ -19,9 +19,8 @@ script:
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- find ./out/appimagetool.AppDir/
- find ./out/appimaged.AppDir/
- - export PATH=./appimagetool.AppDir/usr/bin/:$PATH
- - ( cd out/ ; ./appimagetool.AppDir/usr/bin/appimagetool ./appimagetool.AppDir/ -s -v -u "zsync|https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage.zsync" )
- - ( cd out/ ; ./appimagetool.AppDir/usr/bin/appimagetool ./appimaged.AppDir/ -s -v -u "zsync|https://github.com/probonopd/AppImageKit/releases/download/continuous/appimaged-x86_64.AppImage.zsync" )
+ - ( cd out/ ; ./appimagetool.AppDir/AppRun ./appimagetool.AppDir/ -s -v -u "zsync|https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage.zsync" )
+ - ( cd out/ ; ./appimagetool.AppDir/AppRun ./appimaged.AppDir/ -s -v -u "zsync|https://github.com/probonopd/AppImageKit/releases/download/continuous/appimaged-x86_64.AppImage.zsync" )
- rm -rf out/appimaged out/appimagetool out/validate out/digest out/mksquashfs || true
- rm -rf out/runtime || true # Not needed, might confuse users
- sudo rm -rf out/*.AppDir out/*.AppImage.digest || true # Not needed
View
@@ -105,7 +105,7 @@ int sfs_ls(char* image) {
/* Generate a squashfs filesystem using mksquashfs on the $PATH
* execlp(), execvp(), and execvpe() search on the $PATH */
-int sfs_mksquashfs(char *source, char *destination) {
+int sfs_mksquashfs(char *source, char *destination, int offset) {
pid_t parent = getpid();
pid_t pid = fork();
@@ -117,13 +117,15 @@ int sfs_mksquashfs(char *source, char *destination) {
waitpid(pid, &status, 0);
} else {
// we are the child
+ gchar *offset_string;
+ offset_string = g_strdup_printf("%i", offset);
if(0==strcmp("xz", sqfs_comp))
{
// https://jonathancarter.org/2015/04/06/squashfs-performance-testing/ says:
// improved performance by using a 16384 block size with a sacrifice of around 3% more squashfs image space
- execlp("mksquashfs", "mksquashfs", source, destination, "-comp", "xz", "-root-owned", "-noappend", "-Xdict-size", "100%", "-b", "16384", "-no-xattrs", "-root-owned", NULL);
+ execlp("mksquashfs", "mksquashfs", source, destination, "-offset", offset_string, "-comp", "xz", "-root-owned", "-noappend", "-Xdict-size", "100%", "-b", "16384", "-no-xattrs", "-root-owned", NULL);
} else {
- execlp("mksquashfs", "mksquashfs", source, destination, "-comp", sqfs_comp, "-root-owned", "-noappend", "-no-xattrs", "-root-owned", NULL);
+ execlp("mksquashfs", "mksquashfs", source, destination, "-offset", offset_string, "-comp", sqfs_comp, "-root-owned", "-noappend", "-no-xattrs", "-root-owned", NULL);
}
perror("execlp"); // execlp() returns only on error
return(-1); // exec never returns
@@ -472,53 +474,37 @@ main (int argc, char *argv[])
}
}
- /* mksquashfs can currently not start writing at an offset,
- * so we need a tempfile. https://github.com/plougher/squashfs-tools/pull/13
+ /* Upstream mksquashfs can currently not start writing at an offset,
+ * so we need a patched one. https://github.com/plougher/squashfs-tools/pull/13
* should hopefully change that. */
- char *tempfile;
+
fprintf (stderr, "Generating squashfs...\n");
- tempfile = br_strcat(destination, ".temp");
- int result = sfs_mksquashfs(source, tempfile);
- if(result != 0)
- die("sfs_mksquashfs error");
-
- fprintf (stderr, "Generating AppImage...\n");
- FILE *fpsrc = fopen(tempfile, "rb");
- if (fpsrc == NULL) {
- die("Not able to open the tempfile for reading, aborting");
- }
- FILE *fpdst = fopen(destination, "w");
- if (fpdst == NULL) {
- die("Not able to open the destination file for writing, aborting");
- }
-
/* runtime is embedded into this executable
* http://stupefydeveloper.blogspot.de/2008/08/cc-embed-binary-data-into-elf.html */
int size = (int)&_binary_runtime_size;
char *data = (char *)&_binary_runtime_start;
if (verbose)
printf("Size of the embedded runtime: %d bytes\n", size);
- fwrite(data, size, 1, fpdst);
- fseek (fpdst, 0, SEEK_END);
- char byte;
- while (!feof(fpsrc))
- {
- fread(&byte, sizeof(char), 1, fpsrc);
- fwrite(&byte, sizeof(char), 1, fpdst);
- }
+ int result = sfs_mksquashfs(source, destination, size);
+ if(result != 0)
+ die("sfs_mksquashfs error");
- fclose(fpsrc);
+ fprintf (stderr, "Embedding ELF...\n");
+ FILE *fpdst = fopen(destination, "rb+");
+ if (fpdst == NULL) {
+ die("Not able to open the AppImage for writing, aborting");
+ }
+
+ fseek(fpdst, 0, SEEK_SET);
+ fwrite(data, size, 1, fpdst);
fclose(fpdst);
-
+
fprintf (stderr, "Marking the AppImage as executable...\n");
if (chmod (destination, 0755) < 0) {
printf("Could not set executable bit, aborting\n");
exit(1);
}
- if(unlink(tempfile) != 0) {
- die("Could not delete the tempfile, aborting");
- }
if(bintray_user != NULL){
if(bintray_repo != NULL){
View
@@ -19,7 +19,7 @@ cp mksquashfs ../../build
cd ../../
-cp build/AppRun appimagetool.AppDir/
+cp resources/AppRun appimagetool.AppDir/
cp build/appimagetool appimagetool.AppDir/usr/bin/
cp build/mksquashfs appimagetool.AppDir/usr/bin/
@@ -39,7 +39,7 @@ mkdir -p appimaged.AppDir/usr/lib
cp -f build/appimaged appimaged.AppDir/usr/bin
cp -f build/validate appimaged.AppDir/usr/bin
-cp build/AppRun appimaged.AppDir/
+cp resources/AppRun appimaged.AppDir/
find /usr/lib -name libarchive.so.3 -exec cp {} appimaged.AppDir/usr/lib/ \;
cp resources/appimaged.desktop appimaged.AppDir/
View
@@ -0,0 +1,11 @@
+#!/bin/sh
+HERE="$(dirname "$(readlink -f "${0}")")"
+export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/sbin/:"${HERE}"/usr/games/:"${HERE}"/bin/:"${HERE}"/sbin/:"${PATH}"
+export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}"
+export PYTHONPATH="${HERE}"/usr/share/pyshared/:"${PYTHONPATH}"
+export XDG_DATA_DIRS="${HERE}"/usr/share/:"${XDG_DATA_DIRS}"
+export PERLLIB="${HERE}"/usr/share/perl5/:"${HERE}"/usr/lib/perl5/:"${PERLLIB}"
+export GSETTINGS_SCHEMA_DIR="${HERE}"/usr/share/glib-2.0/schemas/:"${GSETTINGS_SCHEMA_DIR}"
+export QT_PLUGIN_PATH="${HERE}"/usr/lib/qt4/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib32/qt4/plugins/:"${HERE}"/usr/lib64/qt4/plugins/:"${HERE}"/usr/lib/qt5/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib32/qt5/plugins/:"${HERE}"/usr/lib64/qt5/plugins/:"${QT_PLUGIN_PATH}"
+EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1)
+exec "${EXEC}" $@

0 comments on commit 29decf8

Please sign in to comment.