Skip to content

Commit d0c128c

Browse files
committed
Improved build.sh taking as a base the work of margueritev on the opensuse package build.
LZMA will always static link even if the linux distro doesn't ships a static build. OPENSSL will always static link even if the linux distro doesn't ships a static build. Root priviliges are not needeed anymore to build. Changed build-appdirs.sh to not depend on a specific libarchive version. Redirect errors of find command in build-appdirs.sh to stop script execution due to permission denied messages.
1 parent ce2d4d7 commit d0c128c

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

build-appdirs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cp -f build/appimaged appimaged.AppDir/usr/bin
4040
cp -f build/validate appimaged.AppDir/usr/bin
4141

4242
cp resources/AppRun appimaged.AppDir/
43-
find /usr/lib -name libarchive.so.3 -exec cp {} appimaged.AppDir/usr/lib/ \;
43+
find /usr -name "libarchive.so.*.*" -exec cp {} appimaged.AppDir/usr/lib/ \; > /dev/null 2>&1
4444

4545
cp resources/appimaged.desktop appimaged.AppDir/
4646
cp resources/appimagetool.svg appimaged.AppDir/appimaged.svg

build.sh

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,43 @@ git submodule update
2222
rm -rf build/ || true
2323

2424
# Build inotify-tools; the one from CentOS does not have .a
25-
2625
if [ ! -e "./inotify-tools-3.14/libinotifytools/src/.libs/libinotifytools.a" ] ; then
2726
wget -c http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
2827
tar xf inotify-tools-3.14.tar.gz
2928
cd inotify-tools-3.14
30-
./configure --prefix=/usr && make && sudo make install
29+
mkdir -p build/lib
30+
./configure --prefix=`pwd`/build --libdir=`pwd`/build/lib
31+
make
32+
make install
3133
cd -
32-
sudo rm /usr/*/libinotifytools.so* /usr/local/lib/libinotifytools.so* 2>/dev/null || true # Don't want the dynamic one
3334
fi
3435

36+
# Build lzma
37+
if [ ! -e "./xz-5.2.3/build/lib/liblzma.a" ] ; then
38+
wget http://tukaani.org/xz/xz-5.2.3.tar.gz
39+
tar xf xz-5.2.3.tar.gz
40+
cd xz-5.2.3
41+
mkdir -p build/lib
42+
./configure --prefix=`pwd`/build --libdir=`pwd`/build/lib --enable-static
43+
make && make install
44+
cd -
45+
fi
46+
47+
# Build openssl
48+
if [ ! -e "./openssl-1.1.0c/build/lib/libssl.a" ] ; then
49+
wget https://www.openssl.org/source/openssl-1.1.0c.tar.gz
50+
tar xf openssl-1.1.0c.tar.gz
51+
cd openssl-1.1.0c
52+
mkdir -p build/lib
53+
./config --prefix=`pwd`/build
54+
make && make install
55+
cd -
56+
fi
57+
58+
# Patch squashfuse-tools Makefile to link against static llzma
59+
sed -i "s|CFLAGS += -DXZ_SUPPORT|CFLAGS += -DXZ_SUPPORT -I../../xz-5.2.3/build/include|g" squashfs-tools/squashfs-tools/Makefile
60+
sed -i "s|LIBS += -llzma|LIBS += -L../../xz-5.2.3/build/lib -llzma|g" squashfs-tools/squashfs-tools/Makefile
61+
3562
# Patch squashfuse_ll to be a library rather than an executable
3663

3764
cd squashfuse
@@ -48,7 +75,7 @@ if [ ! -e ./Makefile ] ; then
4875
autoreconf -fi || true # Errors out, but the following succeeds then?
4976
autoconf
5077
sed -i '/PKG_CHECK_MODULES.*/,/,:./d' configure # https://github.com/vasi/squashfuse/issues/12
51-
./configure --disable-demo --disable-high-level --without-lzo --without-lz4 --with-xz=/usr/lib/
78+
./configure --disable-demo --disable-high-level --without-lzo --without-lz4 --with-xz=`pwd`/../xz-5.2.3/build/
5279
fi
5380

5481
bash --version
@@ -75,7 +102,7 @@ objcopy --add-section .sha256_sig=1024_blank_bytes \
75102

76103
# Now statically link against libsquashfuse_ll, libsquashfuse and liblzma
77104
# and embed .upd_info and .sha256_sig sections
78-
cc ../elf.c ../notify.c ../getsection.c runtime3.o ../squashfuse/.libs/libsquashfuse_ll.a ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -Wl,-Bdynamic -lfuse -lpthread -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -ldl -o runtime
105+
cc ../elf.c ../notify.c ../getsection.c runtime3.o ../squashfuse/.libs/libsquashfuse_ll.a ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -L../xz-5.2.3/build/lib -Wl,-Bdynamic -lfuse -lpthread -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -ldl -o runtime
79106
strip runtime
80107

81108
# Test if we can read it back
@@ -97,13 +124,12 @@ ld -r -b binary -o data.o runtime
97124

98125
# Compile and link digest tool
99126

100-
cc -o digest ../getsection.c ../digest.c -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -lz -ldl
101-
# cc -o digest -Wl,-Bdynamic ../digest.c -Wl,-Bstatic -static -lcrypto -Wl,-Bdynamic -ldl # 1.4 MB
127+
cc -o digest ../getsection.c ../digest.c -I../openssl-1.1.0c/build/include -L../openssl-1.1.0c/build/lib -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -lz -ldl
102128
strip digest
103129

104130
# Compile and link validate tool
105131

106-
cc -o validate ../getsection.c ../validate.c -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -lglib-2.0 $(pkg-config --cflags glib-2.0) -lz -ldl
132+
cc -o validate ../getsection.c ../validate.c -I../openssl-1.1.0c/build/include -L../openssl-1.1.0c/build/lib -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic -lglib-2.0 $(pkg-config --cflags glib-2.0) -lz -ldl
107133
strip validate
108134

109135
# Test if we can read it back
@@ -121,11 +147,11 @@ ld -r -b binary -o data.o runtime
121147

122148
# Compile appimagetool but do not link - glib version
123149

124-
cc -DVERSION_NUMBER=\"$(git describe --tags --always --abbrev=7)\" -D_FILE_OFFSET_BITS=64 -I../squashfuse/ $(pkg-config --cflags glib-2.0) -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -Os ../getsection.c -c ../appimagetool.c
150+
cc -DVERSION_NUMBER=\"$(git describe --tags --always --abbrev=7)\" -D_FILE_OFFSET_BITS=64 -I../squashfuse/ $(pkg-config --cflags glib-2.0) -g -Os ../getsection.c -c ../appimagetool.c
125151

126152
# Now statically link against libsquashfuse and liblzma - glib version
127153

128-
cc data.o appimagetool.o ../elf.c ../getsection.c -DENABLE_BINRELOC ../binreloc.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -Wl,-Bdynamic -lfuse -lpthread -lglib-2.0 $(pkg-config --cflags glib-2.0) -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimagetool # liblz4
154+
cc data.o appimagetool.o ../elf.c ../getsection.c -DENABLE_BINRELOC ../binreloc.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -L../xz-5.2.3/build/lib -Wl,-Bdynamic -lfuse -lpthread -lglib-2.0 $(pkg-config --cflags glib-2.0) -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimagetool # liblz4
129155

130156
# Version without glib
131157
# cc -D_FILE_OFFSET_BITS=64 -I ../squashfuse -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -Os -c ../appimagetoolnoglib.c
@@ -144,7 +170,7 @@ fi
144170
rm -f a.out
145171

146172
# appimaged, an optional component
147-
cc -std=gnu99 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBARCHIVE3=$have_libarchive3 -DVERSION_NUMBER=\"$(git describe --tags --always --abbrev=7)\" ../getsection.c ../notify.c -Wl,-Bdynamic ../elf.c ../appimaged.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -I../squashfuse/ -Wl,-Bstatic -linotifytools -Wl,-Bdynamic -larchive${archive_n} $(pkg-config --cflags --libs glib-2.0) $(pkg-config --cflags --libs gio-2.0) $(pkg-config --libs --cflags cairo) -ldl -lpthread -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimaged # liblz4
173+
cc -std=gnu99 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBARCHIVE3=$have_libarchive3 -DVERSION_NUMBER=\"$(git describe --tags --always --abbrev=7)\" ../getsection.c ../notify.c -Wl,-Bdynamic ../elf.c ../appimaged.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -I../squashfuse/ -L../xz-5.2.3/build/lib -I../inotify-tools-3.14/build/include -L../inotify-tools-3.14/build/lib -Wl,-Bstatic -linotifytools -Wl,-Bdynamic -larchive${archive_n} $(pkg-config --cflags --libs glib-2.0) $(pkg-config --cflags gio-2.0) $(pkg-config --libs gio-2.0) $(pkg-config --libs --cflags cairo) -ldl -lpthread -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimaged # liblz4
148174

149175
cd ..
150176

@@ -155,13 +181,13 @@ strip build/* 2>/dev/null
155181
chmod a+x build/*
156182
ls -lh build/*
157183
for FILE in $(ls build/*) ; do
158-
echo "build/$FILE"
159-
ldd "build/$FILE" || true
184+
echo "$FILE"
185+
ldd "$FILE" || true
160186
done
161187

162188
bash -ex "$HERE/build-appdirs.sh"
163189

164190
ls -lh
165191

166-
mkdir -p /out/
167-
cp -r build/* ./*.AppDir /out/
192+
mkdir -p out
193+
cp -r build/* ./*.AppDir out/

0 commit comments

Comments
 (0)