1
+ #! /bin/sh
2
+
3
+ set -ex
4
+
1
5
# ############################################
2
6
# Download and extract minimal Alpine system
3
7
# ############################################
@@ -56,38 +60,46 @@ cd ../../
56
60
# Build static desktop-file-utils
57
61
apk add glib-static glib-dev
58
62
wget -c https://www.freedesktop.org/software/desktop-file-utils/releases/desktop-file-utils-0.15.tar.gz
59
- tar xf desktop-file-utils-0.15.tar.gz
63
+ tar xf desktop-file-utils-0.15.tar.gz
60
64
cd desktop-file-utils-0.15
61
65
# The next 2 lines are a workaround for: checking build system type... ./config.guess: unable to guess system type
62
66
wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' -O config.guess
63
67
wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' -O config.sub
64
68
autoreconf --install # https://github.com/shendurelab/LACHESIS/issues/31#issuecomment-283963819
65
69
./configure
66
- make -j$( nproc)
70
+ make -j$( nproc)
67
71
cd src/
68
72
gcc -static -o desktop-file-validate keyfileutils.o validate.o validator.o -lglib-2.0 -lintl
69
73
gcc -static -o update-desktop-database update-desktop-database.o -lglib-2.0 -lintl
70
74
gcc -static -o desktop-file-install keyfileutils.o validate.o install.o -lglib-2.0 -lintl
71
75
strip desktop-file-install desktop-file-validate update-desktop-database
72
- cd -
76
+ cd ../..
73
77
74
78
# Build appstreamcli
75
- # But entirely unclear how to make meson build a static binary
76
- # but unlike with glibc it is rather easy to "bundle everything" with musl, result is 2.8 MB
77
- apk add glib-static meson cmake libxml2-dev yaml-dev lmdb-dev gobject-introspection-dev snowball-dev gperf
79
+ apk add glib-static meson cmake libxml2-dev yaml-dev gobject-introspection-dev snowball-dev gperf
80
+ # Compile liblmdb from source as Alpine only ship it as a .so
81
+ wget https://git.openldap.org/openldap/openldap/-/archive/LMDB_0.9.29/openldap-LMDB_0.9.29.tar.gz
82
+ tar xf openldap-LMDB_0.9.29.tar.gz
83
+ cd openldap-LMDB_0.9.29/libraries/liblmdb
84
+ make liblmdb.a
85
+ sudo install -D -m 644 liblmdb.a /usr/local/lib/liblmdb.a
86
+ sudo install -D -m 644 lmdb.h /usr/local/include/lmdb.h
87
+ cd -
78
88
wget -c https://github.com/ximion/appstream/archive/v0.12.9.tar.gz
79
89
tar xf v0.12.9.tar.gz
80
90
cd appstream-0.12.9
81
- mkdir build && cd build
82
- meson ..
83
- ninja -v
84
- libs=$( ldd ./tools/appstreamcli | cut -d " " -f 3 | sort | uniq )
85
- cp $libs tools/
86
- cp /lib/ld-musl-*.so.1 tools/
87
- patchelf --set-rpath '$ORIGIN ' tools/appstreamcli
88
- strip ./tools/appstreamcli
89
- (cd tools/ ; tar cfvj ../appstreamcli.tar.bz2 * )
90
- cd ../../
91
+ # Ask for static dependencies
92
+ sed -i -E -e "s|(dependency\('.*')|\1, static: true|g" meson.build
93
+ # Disable po, docs and tests
94
+ sed -i -e "s|subdir('po/')||" meson.build
95
+ sed -i -e "s|subdir('docs/')||" meson.build
96
+ sed -i -e "s|subdir('tests/')||" meson.build
97
+ # -no-pie is required to statically link to libc
98
+ CFLAGS=-no-pie LDFLAGS=-static meson setup build --buildtype=release --default-library=static --prefix="$( pwd) /prefix" --strip -Db_lto=true -Db_ndebug=if-release -Dstemming=false -Dgir=false -Dapidocs=false
99
+ # Install in a staging enviroment
100
+ meson install -C build
101
+ file prefix/bin/appstreamcli
102
+ cd -
91
103
92
104
# Build static bsdtar
93
105
apk add zlib-dev bzip2-dev # What happened to zlib-static?
@@ -114,15 +126,15 @@ sudo umount miniroot/proc miniroot/sys miniroot/dev
114
126
115
127
116
128
# Use the same architecture names as https://github.com/AppImage/AppImageKit/releases/
117
- if [ " $ARCHITECTURE " == " x86" ] ; then export ARCHITECTURE=i686 ; fi
129
+ if [ " $ARCHITECTURE " = " x86" ] ; then export ARCHITECTURE=i686 ; fi
118
130
119
- mkdir -p out/
131
+ mkdir out/
120
132
sudo find miniroot/ -type f -executable -name ' mksquashfs' -exec cp {} out/mksquashfs-$ARCHITECTURE \; 2> /dev/null
121
133
sudo find miniroot/ -type f -executable -name ' unsquashfs' -exec cp {} out/unsquashfs-$ARCHITECTURE \; 2> /dev/null
122
134
sudo find miniroot/ -type f -executable -name ' bsdtar' -exec cp {} out/bsdtar-$ARCHITECTURE \; 2> /dev/null
123
135
sudo find miniroot/ -type f -executable -name ' desktop-file-install' -exec cp {} out/desktop-file-install-$ARCHITECTURE \; 2> /dev/null
124
136
sudo find miniroot/ -type f -executable -name ' desktop-file-validate' -exec cp {} out/desktop-file-validate-$ARCHITECTURE \; 2> /dev/null
125
137
sudo find miniroot/ -type f -executable -name ' update-desktop-database' -exec cp {} out/update-desktop-database-$ARCHITECTURE \; 2> /dev/null
126
- sudo find miniroot/ -type f -name ' appstreamcli.tar.bz2 ' -exec cp {} out/appstreamcli-$ARCHITECTURE .tar.bz2 \; 2> /dev/null
138
+ sudo cp miniroot/appstream-0.12.9/prefix/bin/appstreamcli out/appstreamcli-$ARCHITECTURE
127
139
sudo find patchelf-* / -type f -executable -name ' patchelf' -exec cp {} out/patchelf-$ARCHITECTURE \; 2> /dev/null
128
140
sudo rm -rf miniroot/ patchelf-* /
0 commit comments