| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Exit on error |
| 4 | set -e |
| 5 | |
| 6 | # Number of parallel jobs |
| 7 | jobs=$(nproc) |
| 8 | |
| 9 | if [ -z "$AppImageArch" ]; then |
| 10 | AppImageArch=x86_64 |
| 11 | fi |
| 12 | |
| 13 | # Set environment variables |
| 14 | export OS=`uname` |
| 15 | |
| 16 | if [ "$AppImageArch" = i686 ]; then |
| 17 | export HOST=i386-linux-gnu |
| 18 | export BUILD_X86=True |
| 19 | elif [ "$AppImageArch" = x86_64 ]; then |
| 20 | export HOST=x86_64-linux-gnu |
| 21 | elif [ "$AppImageArch" = armhf ]; then |
| 22 | export HOST=arm-linux-gnueabihf |
| 23 | elif [ "$AppImageArch" = aarch64 ]; then |
| 24 | export HOST=aarch64-linux-gnu |
| 25 | elif [ "$AppImageArch" = riscv64 ]; then |
| 26 | export HOST=riscv64-linux-gnu |
| 27 | elif [ "$AppImageArch" = ppc64el ]; then |
| 28 | export HOST=powerpc64le-linux-gnu |
| 29 | fi |
| 30 | |
| 31 | # Make tool |
| 32 | if [[ "$OS" = Linux ]]; then |
| 33 | export MAKE=make |
| 34 | else |
| 35 | export MAKE=gmake |
| 36 | fi |
| 37 | |
| 38 | # Build libcdio |
| 39 | ./tools/build-codecs libcdio libcdio-paranoia |
| 40 | |
| 41 | # Build libcurl |
| 42 | wget -c https://curl.se/download/curl-8.11.0.tar.bz2 |
| 43 | tar xfj curl-8.11.0.tar.bz2 |
| 44 | cd curl-8.11.0 |
| 45 | |
| 46 | if [ $AppImageArch = i686 ]; then |
| 47 | CFLAGS="-m32" ./configure --disable-docs --with-ssl --without-librtmp --without-libpsl --disable-ldap --without-zstd --without-brotli --without-nghttp2 --without-libidn2 |
| 48 | else |
| 49 | ./configure --host=$HOST --disable-docs --with-ssl --without-librtmp --without-libpsl --disable-ldap --without-zstd --without-brotli --without-nghttp2 --without-libidn2 |
| 50 | fi |
| 51 | |
| 52 | $MAKE -j$jobs |
| 53 | sudo $MAKE install |
| 54 | |
| 55 | if [ "$OS" = Linux ]; then |
| 56 | sudo rm /usr/local/bin/curl |
| 57 | fi |
| 58 | |
| 59 | cd .. |
| 60 | |
| 61 | # Build smooth |
| 62 | cd smooth |
| 63 | |
| 64 | CONFIG="release,bundledlibbz2,bundledlibfribidi,bundledlibjpeg,bundledlibpng,bundledlibxml2,bundledzlib" |
| 65 | |
| 66 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/$HOST/pkgconfig |
| 67 | |
| 68 | $MAKE config=$CONFIG -j$jobs |
| 69 | sudo $MAKE config=$CONFIG install |
| 70 | |
| 71 | unset PKG_CONFIG_PATH |
| 72 | |
| 73 | cd .. |
| 74 | |
| 75 | # Build BoCA |
| 76 | cd boca |
| 77 | |
| 78 | CONFIG="release,bundledlibexpat,bundledliburiparser,bundledzlib" |
| 79 | |
| 80 | $MAKE config=$CONFIG -j$jobs |
| 81 | |
| 82 | if [ "$AppImageArch" = i686 ]; then |
| 83 | sudo $MAKE BUILD_X86=True config=$CONFIG install |
| 84 | else |
| 85 | sudo $MAKE config=$CONFIG install |
| 86 | fi |
| 87 | |
| 88 | if [ "$AppImageArch" = x86_64 ]; then |
| 89 | # Install 32 bit Wine build tools |
| 90 | if [ "$OS" = Linux ]; then |
| 91 | sudo apt install -y wine32-tools |
| 92 | else |
| 93 | /usr/local/share/wine/pkg32.sh install -y wine |
| 94 | fi |
| 95 | |
| 96 | # Build 32 bit Core Audio connector |
| 97 | cd components/encoder/coreaudioconnect/connector |
| 98 | |
| 99 | $MAKE BUILD_X86=True config=$CONFIG clean |
| 100 | $MAKE BUILD_X86=True config=$CONFIG -j$jobs |
| 101 | sudo $MAKE BUILD_X86=True config=$CONFIG install |
| 102 | |
| 103 | cd ../../../.. |
| 104 | fi |
| 105 | |
| 106 | cd .. |
| 107 | |
| 108 | # Build fre:ac |
| 109 | CONFIG="release" |
| 110 | |
| 111 | $MAKE config=$CONFIG -j$jobs |
| 112 | sudo $MAKE config=$CONFIG install |
| 113 | |
| 114 | # Build codecs and DSP libraries |
| 115 | cd tools |
| 116 | |
| 117 | ./build-codecs faad2 fdk-aac mp4v2 |
| 118 | ./build-codecs lame mpg123 |
| 119 | ./build-codecs libogg opus speex vorbis |
| 120 | ./build-codecs flac mac musepack wavpack |
| 121 | ./build-codecs ffmpeg libsndfile |
| 122 | ./build-codecs libsamplerate rnnoise rubberband |
| 123 | |
| 124 | cd .. |
| 125 | |
| 126 | # Install codecs |
| 127 | mkdir -p appdir/codecs |
| 128 | |
| 129 | cp /usr/local/lib/libFLAC.so appdir/codecs/FLAC.so |
| 130 | cp /usr/local/lib/libMAC.so appdir/codecs/MAC.so |
| 131 | cp /usr/local/lib/libfaad.so appdir/codecs/faad.so |
| 132 | cp /usr/local/lib/libfdk-aac.so appdir/codecs/fdk-aac.so |
| 133 | cp /usr/local/lib/libmp3lame.so appdir/codecs/mp3lame.so |
| 134 | cp /usr/local/lib/libmp4v2.so appdir/codecs/mp4v2.so |
| 135 | cp /usr/local/lib/libmpg123.so appdir/codecs/mpg123.so |
| 136 | cp /usr/local/lib/libogg.so appdir/codecs/ogg.so |
| 137 | cp /usr/local/lib/libopus.so appdir/codecs/opus.so |
| 138 | cp /usr/local/lib/librnnoise.so appdir/codecs/rnnoise.so |
| 139 | cp /usr/local/lib/librubberband.so appdir/codecs/rubberband.so |
| 140 | cp /usr/local/lib/libsamplerate.so appdir/codecs/samplerate.so |
| 141 | cp /usr/local/lib/libsndfile.so appdir/codecs/sndfile.so |
| 142 | cp /usr/local/lib/libspeex.so appdir/codecs/speex.so |
| 143 | cp /usr/local/lib/libvorbis.so appdir/codecs/vorbis.so |
| 144 | cp /usr/local/lib/libvorbisenc.so appdir/codecs/vorbisenc.so |
| 145 | |
| 146 | strip --strip-all appdir/codecs/*.so |
| 147 | |
| 148 | mkdir -p appdir/codecs/cmdline |
| 149 | |
| 150 | install -m 0755 /usr/local/bin/ffmpeg appdir/codecs/cmdline/ffmpeg |
| 151 | install -m 0755 /usr/local/bin/mpcdec appdir/codecs/cmdline/mpcdec |
| 152 | install -m 0755 /usr/local/bin/mpcenc appdir/codecs/cmdline/mpcenc |
| 153 | install -m 0755 /usr/local/bin/wavpack appdir/codecs/cmdline/wavpack |
| 154 | install -m 0755 /usr/local/bin/wvunpack appdir/codecs/cmdline/wvunpack |
| 155 | |
| 156 | strip --strip-all appdir/codecs/cmdline/* |
| 157 | |
| 158 | # Copy icons |
| 159 | mkdir -p appdir/icons/gnome/32x32/status |
| 160 | |
| 161 | if [[ "$OS" = Linux ]]; then |
| 162 | cp /usr/share/icons/gnome/32x32/status/dialog-error.png appdir/icons/gnome/32x32/status |
| 163 | cp /usr/share/icons/gnome/32x32/status/dialog-information.png appdir/icons/gnome/32x32/status |
| 164 | cp /usr/share/icons/gnome/32x32/status/dialog-question.png appdir/icons/gnome/32x32/status |
| 165 | cp /usr/share/icons/gnome/32x32/status/dialog-warning.png appdir/icons/gnome/32x32/status |
| 166 | else |
| 167 | cp /usr/local/share/icons/gnome/32x32/status/dialog-error.png appdir/icons/gnome/32x32/status |
| 168 | cp /usr/local/share/icons/gnome/32x32/status/dialog-information.png appdir/icons/gnome/32x32/status |
| 169 | cp /usr/local/share/icons/gnome/32x32/status/dialog-question.png appdir/icons/gnome/32x32/status |
| 170 | cp /usr/local/share/icons/gnome/32x32/status/dialog-warning.png appdir/icons/gnome/32x32/status |
| 171 | fi |
| 172 | |
| 173 | # Copy smooth |
| 174 | cp /usr/local/lib/libsmooth*.so.? appdir |
| 175 | |
| 176 | # Copy BoCA |
| 177 | cp -r /usr/local/lib/boca appdir |
| 178 | cp /usr/local/lib/libboca-1.0.so.3 appdir/libboca-1.0.so.3 |
| 179 | |
| 180 | # Copy fre:ac |
| 181 | cp COPYING Readme* appdir |
| 182 | rm appdir/Readme.md |
| 183 | |
| 184 | cp -r /usr/local/lib/freac/* appdir/boca |
| 185 | cp -r /usr/local/share/freac/lang appdir |
| 186 | cp -r /usr/local/share/freac/icons appdir |
| 187 | cp -r /usr/local/share/doc/freac/manual appdir |
| 188 | |
| 189 | cp /usr/local/lib/libfreac-1.1.so.0 appdir/libfreac-1.1.so.0 |
| 190 | |
| 191 | install -m 0755 /usr/local/bin/freac appdir/freac |
| 192 | install -m 0755 /usr/local/bin/freaccmd appdir/freaccmd |
| 193 | install -m 0755 /usr/local/bin/smooth-translator appdir/translator |
| 194 | install -m 0755 packaging/appimage/AppRun appdir/AppRun |
| 195 | |
| 196 | mkdir -p appdir/usr/share/applications |
| 197 | mkdir -p appdir/usr/share/metainfo |
| 198 | |
| 199 | cp /usr/local/share/applications/org.freac.freac.desktop appdir/usr/share/applications |
| 200 | cp /usr/local/share/metainfo/org.freac.freac.appdata.xml appdir/usr/share/metainfo |
| 201 | ln -s usr/share/applications/org.freac.freac.desktop appdir/org.freac.freac.desktop |
| 202 | cp /usr/local/share/icons/hicolor/128x128/apps/org.freac.freac.png appdir |
| 203 | |
| 204 | # Copy other dependencies |
| 205 | cp /usr/local/lib/libcdio.so.19 appdir |
| 206 | cp /usr/local/lib/libcdio_cdda.so.2 appdir |
| 207 | cp /usr/local/lib/libcdio_paranoia.so.2 appdir |
| 208 | cp /usr/local/lib/libcurl.so.4 appdir |
| 209 | |
| 210 | strip --strip-all appdir/lib*.so* |
| 211 | |
| 212 | # Copy OpenSSL dependencies |
| 213 | mkdir -p appdir/openssl |
| 214 | |
| 215 | if [[ "$OS" = Linux ]]; then |
| 216 | cp -P /usr/lib/$HOST/libcrypto.so.3 appdir/openssl |
| 217 | cp -P /usr/lib/$HOST/libssl.so.3 appdir/openssl |
| 218 | else |
| 219 | cp -P /lib/libcrypto.so.* appdir/openssl |
| 220 | cp -P /usr/lib/libssl.so.* appdir/openssl |
| 221 | |
| 222 | chmod 0755 appdir/openssl/libcrypto.so.* |
| 223 | chmod 0755 appdir/openssl/libssl.so.* |
| 224 | fi |
| 225 | |
| 226 | strip --strip-all appdir/openssl/lib*.so* |
| 227 | |
| 228 | # Build custom AppImage runtime |
| 229 | if [[ "$AppImageArch" = riscv64 || "$AppImageArch" = ppc64el || "$OS" != Linux ]]; then |
| 230 | # Check out AppImage runtime |
| 231 | git clone https://github.com/AppImage/type2-runtime.git |
| 232 | cd type2-runtime |
| 233 | git reset --hard 5e7217b |
| 234 | cd .. |
| 235 | |
| 236 | # Build custom libfuse3 |
| 237 | if [[ "$OS" = Linux ]]; then |
| 238 | git clone --depth=1 --branch=fuse-3.16.2 https://github.com/libfuse/libfuse.git |
| 239 | else |
| 240 | git clone --depth=1 --branch=fuse-3.17.2 https://github.com/libfuse/libfuse.git |
| 241 | fi |
| 242 | cd libfuse |
| 243 | if [[ "$OS" = Linux ]]; then |
| 244 | patch -p1 < ../type2-runtime/patches/libfuse/mount.c.diff |
| 245 | fi |
| 246 | mkdir build |
| 247 | cd build |
| 248 | meson setup -D default_library=both .. |
| 249 | ninja && sudo ninja install |
| 250 | cd ../.. |
| 251 | |
| 252 | # Build libsquashfuse |
| 253 | git clone --depth=1 --branch=0.5.2 https://github.com/vasi/squashfuse.git |
| 254 | cd squashfuse |
| 255 | export pkgconfig_fuse3_CFLAGS="-I/usr/local/include/fuse3" |
| 256 | export pkgconfig_fuse3_LIBS="-L/usr/local/lib/$HOST -lfuse3 -lpthread" |
| 257 | autoreconf -i |
| 258 | ./configure |
| 259 | make && sudo make install |
| 260 | sudo cp fuseprivate.h /usr/local/include/squashfuse |
| 261 | cd .. |
| 262 | |
| 263 | # Build AppImage runtime |
| 264 | cd type2-runtime |
| 265 | if [[ "$OS" = Linux ]]; then |
| 266 | patch -p1 < ../.github/workflows/patches/appimage-type2-runtime-build.patch |
| 267 | else |
| 268 | patch -p1 < ../.github/workflows/patches/appimage-type2-runtime-build-freebsd.patch |
| 269 | fi |
| 270 | cd src/runtime |
| 271 | $MAKE |
| 272 | cd ../../.. |
| 273 | fi |
| 274 | |
| 275 | # Build custom appimagetool |
| 276 | if [[ "$OS" != Linux ]]; then |
| 277 | # Build appimagetool |
| 278 | git clone --branch=1.9.1 --depth=1 https://github.com/AppImage/appimagetool.git |
| 279 | cd appimagetool |
| 280 | mkdir build |
| 281 | cd build |
| 282 | cmake .. |
| 283 | make && sudo make install |
| 284 | cd ../.. |
| 285 | fi |
| 286 | |
| 287 | # Create AppImage using appimagetool |
| 288 | if [[ "$OS" = Linux ]]; then |
| 289 | wget -c -nv "https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-x86_64.AppImage" |
| 290 | chmod a+x appimagetool-x86_64.AppImage |
| 291 | |
| 292 | if [[ "$AppImageArch" = riscv64 || "$AppImageArch" = ppc64el ]]; then |
| 293 | ./appimagetool-x86_64.AppImage --appimage-extract |
| 294 | ARCH=x86_64 ./squashfs-root/AppRun --runtime-file=type2-runtime/src/runtime/runtime appdir freac-continuous-${OS,,}-$AppImageArch.AppImage |
| 295 | else |
| 296 | ARCH=$AppImageArch ./appimagetool-x86_64.AppImage appdir freac-continuous-${OS,,}-$AppImageArch.AppImage |
| 297 | fi |
| 298 | else |
| 299 | ARCH=$AppImageArch appimagetool --runtime-file=type2-runtime/src/runtime/runtime appdir freac-continuous-${OS,,}-$AppImageArch.AppImage |
| 300 | fi |
| 301 | |
| 302 | # Upload AppImage to GitHub |
| 303 | bash .github/workflows/tools/upload-build freac*.AppImage |