Path: blob/master/scripts/packaging/appimage/inject-libc.sh
4251 views
#!/usr/bin/env bash12set -e34function retry_command {5# Package servers tend to be unreliable at times..6# Retry a bunch of times.7local RETRIES=1089for i in $(seq 1 "$RETRIES"); do10"$@" && break11if [ "$i" == "$RETRIES" ]; then12echo "Command \"$@\" failed after ${RETRIES} retries."13exit 114fi15done16}1718this_dir="$(readlink -f "$(dirname "$0")")"1920if [ "$#" -ne 4 ]; then21echo "Syntax: $0 <path to AppDir> <.deb arch> <triple> <ubuntu mirror> <binary to run>"22echo "e.g. $0 DuckStation.AppDir amd64 x86_64-linux-gnu duckstation-qt"23exit 124fi252627APPDIR=$128DEBARCH=$229TRIPLE=$330APPNAME=$43132GLIBC_VERSION=2.353334if [ ! -f "libc.deb" ]; then35retry_command wget -O "libc.deb" "https://github.com/stenzek/duckstation-ext-qt-minimal/releases/download/linux/libc6_2.35-0ubuntu3.9_${DEBARCH}.deb"36fi37if [ ! -f "libgccs.deb" ]; then38retry_command wget -O "libgccs.deb" "https://github.com/stenzek/duckstation-ext-qt-minimal/releases/download/linux/libgcc-s1_12.3.0-1ubuntu1.22.04_${DEBARCH}.deb"39fi40if [ ! -f "libstdc++.deb" ]; then41retry_command wget -O "libstdc++.deb" "https://github.com/stenzek/duckstation-ext-qt-minimal/releases/download/linux/libstdc++6_12.3.0-1ubuntu1.22.04_${DEBARCH}.deb"42fi4344rm -fr "temp"45mkdir "temp"46cd "temp"47dpkg -x "../libc.deb" .48dpkg -x "../libgccs.deb" .49dpkg -x "../libstdc++.deb" .5051# Copy everything into AppDir52RUNTIME="${APPDIR}/libc-runtime"53mkdir -p "${RUNTIME}"5455# libc.so.6 and friends56cd "lib/${TRIPLE}"57cp -v * "${RUNTIME}"58cd ../../5960# libstdc++61cd "usr/lib/${TRIPLE}"62cp -v * "${RUNTIME}" || true63cd ../../..6465# done with temps now66cd ..67rm -fr temp6869# Not risking mixing resolvers...70cd "${RUNTIME}"71rm -vf libnss_*7273# Move ld-linux.so.2 into the binary directory so we can preserve arg0's directory74mv -v "ld-linux-"*.so.* "${APPDIR}/usr/bin/ld-linux"7576# Set up the replacement apprun script77cd "${APPDIR}"78rm -f AppRun.wrapped79cp "${this_dir}/inject-libc-apprun.sh" AppRun.wrapped80sed -i -e "s/__APPNAME__/${APPNAME}/" AppRun.wrapped81sed -i -e "s/__REQ_GLIBC_VERSION__/${GLIBC_VERSION}/" AppRun.wrapped8283echo Done.84858687