mirror of
https://gitee.com/spark-store-project/additional-base-lib
synced 2025-07-29 01:02:21 +08:00
pack script introduced and several bugs fix.
This commit is contained in:
parent
68f230d82e
commit
6b519e0bc3
105
make-deb.sh
Executable file
105
make-deb.sh
Executable file
@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
LIBC6_DOWNLOAD_URL=http://ftp.cn.debian.org/debian/pool/main/g/glibc/libc6_2.36-9+deb12u1_amd64.deb
|
||||
LIBC_BIN_DOWNLOAD_URL=http://ftp.cn.debian.org/debian/pool/main/g/glibc/libc-bin_2.36-9+deb12u1_amd64.deb
|
||||
LIBSTDCxx6_DOWNLOAD_URL=http://ftp.cn.debian.org/debian/pool/main/g/gcc-12/libstdc++6_12.2.0-14_amd64.deb
|
||||
|
||||
ABL_VERSION=7
|
||||
|
||||
check(){
|
||||
if [ "$1" != 0 ]
|
||||
then
|
||||
echo "Error"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
echo "download packages:"
|
||||
mkdir ./downloads
|
||||
echo "download libc6"
|
||||
wget "$LIBC6_DOWNLOAD_URL" -c -O ./downloads/libc6.deb
|
||||
check $?
|
||||
echo "download libc_bin"
|
||||
wget "$LIBC_BIN_DOWNLOAD_URL" -c -O ./downloads/libc-bin.deb
|
||||
check $?
|
||||
echo "download libstdc++6"
|
||||
wget "$LIBSTDCxx6_DOWNLOAD_URL" -c -O ./downloads/libstdc++6.deb
|
||||
check $?
|
||||
|
||||
echo "extract packages:"
|
||||
dpkg -x ./downloads/libc6.deb ./downloads/libc6
|
||||
dpkg -e ./downloads/libc6.deb ./downloads/libc6/DEBIAN
|
||||
dpkg -x ./downloads/libc-bin.deb ./downloads/libc-bin
|
||||
dpkg -e ./downloads/libc-bin.deb ./downloads/libc-bin/DEBIAN
|
||||
dpkg -x ./downloads/libstdc++6.deb ./downloads/libstdc++6
|
||||
dpkg -e ./downloads/libstdc++6.deb ./downloads/libstdc++6/DEBIAN
|
||||
|
||||
echo "check packages:"
|
||||
LIBC6_VERSION=`cat ./downloads/libc6/DEBIAN/control | grep "^Version: .*"`
|
||||
LIBC6_VERSION=${LIBC6_VERSION:9}
|
||||
LIBC_BIN_VERSION=`cat ./downloads/libc-bin/DEBIAN/control | grep "^Version: .*"`
|
||||
LIBC_BIN_VERSION=${LIBC_BIN_VERSION:9}
|
||||
LIBSTDCxx6_VERSION=`cat ./downloads/libstdc++6/DEBIAN/control | grep "^Version: .*"`
|
||||
LIBSTDCxx6_VERSION=${LIBSTDCxx6_VERSION:9}
|
||||
|
||||
LIBC6_ARCH=`cat ./downloads/libc6/DEBIAN/control | grep "^Architecture: .*"`
|
||||
LIBC6_ARCH=${LIBC6_ARCH:14}
|
||||
LIBC_BIN_ARCH=`cat ./downloads/libc-bin/DEBIAN/control | grep "^Architecture: .*"`
|
||||
LIBC_BIN_ARCH=${LIBC_BIN_ARCH:14}
|
||||
LIBSTDCxx6_ARCH=`cat ./downloads/libstdc++6/DEBIAN/control | grep "^Architecture: .*"`
|
||||
LIBSTDCxx6_ARCH=${LIBSTDCxx6_ARCH:14}
|
||||
|
||||
echo "check arch libc6==libc_bin $LIBC6_ARCH==$LIBC_BIN_ARCH"
|
||||
[ "$LIBC6_ARCH" = "$LIBC_BIN_ARCH" ]
|
||||
check $?
|
||||
echo "check arch libc6==libstdc++6 $LIBC6_ARCH==$LIBSTDCxx6_ARCH"
|
||||
[ "$LIBC6_ARCH" = "$LIBSTDCxx6_ARCH" ]
|
||||
check $?
|
||||
echo "check version libc6==lib_bin $LIBC6_VERSION==$LIBC_BIN_VERSION"
|
||||
check $?
|
||||
|
||||
|
||||
GLIBC_VERSION=$LIBC6_VERSION
|
||||
DEBIAN_DEB_ARCH=$LIBC6_ARCH
|
||||
DEBIAN_MULTIARCH=`dpkg-architecture -A "$DEBIAN_DEB_ARCH" | grep "^DEB_TARGET_MULTIARCH=.*"`
|
||||
DEBIAN_MULTIARCH=${DEBIAN_MULTIARCH:21}
|
||||
LD_SO_LOCATION=`patchelf --print-interpreter "./downloads/libc6/lib/${DEBIAN_MULTIARCH}/libc.so.6"`
|
||||
LIBC_SO_LOCATION="/lib/$DEBIAN_MULTIARCH/libc.so.6"
|
||||
echo "$GLIBC_VERSION,$DEBIAN_DEB_ARCH,$DEBIAN_MULTIARCH,$LD_SO_LOCATION,$LIBC_SO_LOCATION"
|
||||
|
||||
mkdir ./deb-contents
|
||||
mkdir ./deb-contents/DEBIAN
|
||||
mkdir ./deb-contents/usr
|
||||
mkdir ./deb-contents/usr/bin
|
||||
mkdir ./deb-contents/usr/lib
|
||||
mkdir "./deb-contents/usr/lib/$DEBIAN_MULTIARCH"
|
||||
|
||||
echo "Package: additional-base-lib" >> ./deb-contents/DEBIAN/control
|
||||
echo "Version: $GLIBC_VERSION-$ABL_VERSION" >> ./deb-contents/DEBIAN/control
|
||||
echo "Section: utils" >> ./deb-contents/DEBIAN/control
|
||||
echo "Priority: optional" >> ./deb-contents/DEBIAN/control
|
||||
echo "Architecture: $DEBIAN_DEB_ARCH" >> ./deb-contents/DEBIAN/control
|
||||
echo "Maintainer: CongTianKong (gitee.com/CongTianKong)" >> ./deb-contents/DEBIAN/control
|
||||
echo "Depends: bubblewrap, bash, coreutils, shared-mime-info, xdg-utils" >> ./deb-contents/DEBIAN/control
|
||||
echo "Description: A script to run programs with newer libc." >> ./deb-contents/DEBIAN/control
|
||||
echo " package built with make-deb.sh." >> ./deb-contents/DEBIAN/control
|
||||
|
||||
echo >> ./deb-contents/DEBIAN/control
|
||||
|
||||
cp ./scripts/ablrun ./deb-contents/usr/bin/ablrun
|
||||
cp ./scripts/ablrun-appimage ./deb-contents/usr/bin/ablrun-appimage
|
||||
echo "#!/bin/bash" > ./deb-contents/usr/bin/ablrun-normal
|
||||
echo "ABL_TARGET_LD_SO_PATH=$LD_SO_LOCATION" >> ./deb-contents/usr/bin/ablrun-normal
|
||||
echo "ABL_ARCH_DIR=$DEBIAN_MULTIARCH" >> ./deb-contents/usr/bin/ablrun-normal
|
||||
cat ./scripts/ablrun-normal.1 >> ./deb-contents/usr/bin/ablrun-normal
|
||||
chmod a+x ./deb-contents/usr/bin/*
|
||||
|
||||
cp -r "./downloads/libc6/lib/${DEBIAN_MULTIARCH}/" "./deb-contents/usr/lib/${DEBIAN_MULTIARCH}/additional-base-lib"
|
||||
mkdir --parents "./deb-contents/usr/lib/${DEBIAN_MULTIARCH}/additional-base-lib/$LD_SO_LOCATION"
|
||||
rm -d "./deb-contents/usr/lib/${DEBIAN_MULTIARCH}/additional-base-lib/$LD_SO_LOCATION"
|
||||
cp ./downloads/libc6/`readlink "./downloads/libc6/$LD_SO_LOCATION"` "./deb-contents/usr/lib/${DEBIAN_MULTIARCH}/additional-base-lib/$LD_SO_LOCATION"
|
||||
cp "./downloads/libc-bin/usr/bin/ldd" "./deb-contents/usr/lib/${DEBIAN_MULTIARCH}/additional-base-lib/ldd"
|
||||
cp `readlink -e ./downloads/libstdc++6/usr/lib/${DEBIAN_MULTIARCH}/libstdc++.so.6` "./deb-contents/usr/lib/${DEBIAN_MULTIARCH}/additional-base-lib/libstdc++.so.6"
|
||||
|
||||
dpkg -b ./deb-contents "./additional-base-lib_${GLIBC_VERSION}-${ABL_VERSION}_${DEBIAN_DEB_ARCH}.deb"
|
48
scripts/ablrun
Executable file
48
scripts/ablrun
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$*" = "" ]
|
||||
then
|
||||
echo "usage: $0 [command [arguments ...]]"
|
||||
echo " The script is part of additional-base-lib. The package provides a"
|
||||
echo " simple way to solve the compatible problem between application and"
|
||||
echo " glibc, powered by bubblewrap."
|
||||
echo " All the library files, which distributed with additional-base-lib,"
|
||||
echo " are taken from debian bookworm. The script itself create by enforcee"
|
||||
echo " from deepin forum <https://bbs.deepin.org/>. There's no lisence"
|
||||
echo " nor copyright restriction with The script. Feel free to deal with."
|
||||
echo
|
||||
echo " This script auto-detects normal executable and appimage, and then"
|
||||
echo " uses specified script to run either. If you experienced issues,"
|
||||
echo " you may want to use them directly."
|
||||
echo " for appimage, you need ablrun-appimage."
|
||||
echo " for normal executable, you need ablrun-normal."
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ `whoami` = "root" ]
|
||||
then
|
||||
exec ablrun-normal "$@"
|
||||
fi
|
||||
|
||||
if [ -e "$1" ]
|
||||
then
|
||||
ABL_FILENAME="$1"
|
||||
else
|
||||
ABL_FILENAME=`which $1`
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
echo "File not exists."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ABL_FILETYPE=`xdg-mime query filetype "$ABL_FILENAME"`
|
||||
if [ "$ABL_FILETYPE" != "application/vnd.appimage" ]
|
||||
then
|
||||
if [ "$ABL_FILETYPE" != "application/x-iso9660-appimage" ]
|
||||
then
|
||||
exec ablrun-normal "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec ablrun-appimage "$@"
|
38
scripts/ablrun-appimage
Executable file
38
scripts/ablrun-appimage
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$*" = "" ]
|
||||
then
|
||||
echo "usage: $0 [appimage-file [arguments ...]]"
|
||||
echo " This is helper script to run appimages for additional-base-lib."
|
||||
echo
|
||||
echo " You have to ensure input file IS an appimage, for this script"
|
||||
echo " does not check. If you input other files, It will become"
|
||||
echo " unpredictable."
|
||||
exit
|
||||
fi
|
||||
|
||||
ABLIMAGE_PARAMETERS=("$@")
|
||||
|
||||
coproc "$1" --appimage-mount
|
||||
|
||||
ABLIMAGE_PID=$!
|
||||
|
||||
cleanup() {
|
||||
kill $ABLIMAGE_PID
|
||||
exit
|
||||
}
|
||||
trap cleanup SIGHUP
|
||||
trap cleanup SIGINT
|
||||
trap cleanup SIGTERM
|
||||
|
||||
if [ ! -e /proc/$! ]
|
||||
then
|
||||
echo "Child process failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -u ${COPROC[0]} ABLIMAGE_DIR
|
||||
|
||||
ablrun-normal "$ABLIMAGE_DIR/AppRun" ${ABLIMAGE_PARAMETERS[@]:1}
|
||||
|
||||
cleanup
|
37
scripts/ablrun-normal.1
Executable file
37
scripts/ablrun-normal.1
Executable file
@ -0,0 +1,37 @@
|
||||
#some contents is generated when build package
|
||||
|
||||
if [ "$*" = "" ]
|
||||
then
|
||||
echo "usage: $0 [command [arguments ...]]"
|
||||
echo " The script is part of additional-base-lib. The package provides a"
|
||||
echo " simple way to solve the compatible problem between application and"
|
||||
echo " glibc, powered by bubblewrap."
|
||||
echo " All the library files, which distributed with additional-base-lib,"
|
||||
echo " are taken from debian bookworm. The script itself create by enforcee"
|
||||
echo " from deepin forum <https://bbs.deepin.org/>. There's no lisence"
|
||||
echo " nor copyright restriction with The script. Feel free to deal with."
|
||||
echo
|
||||
echo " If you're going to run appimage with additional-base-lib, you may"
|
||||
echo " need ablrun-appimage."
|
||||
echo " There is a simpler script to handle both normal executable and"
|
||||
echo " appimage, called ablrun. usage: ablrun [command [arguments ...]]"
|
||||
exit
|
||||
fi
|
||||
|
||||
ABL_LD_SO_PATH=`readlink -e $ABL_TARGET_LD_SO_PATH`
|
||||
ABL_LIBC_SO_PATH=`readlink -e /lib/${ABL_ARCH_DIR}/libc.so.6`
|
||||
|
||||
if [ "$LD_LIBRARY_PATH" = "" ]
|
||||
then
|
||||
ABL_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/additional-base-lib/"
|
||||
else
|
||||
ABL_LIBRARY_PATH="$LD_LIBRARY_PATH;/usr/lib/x86_64-linux-gnu/additional-base-lib"
|
||||
fi
|
||||
|
||||
exec bwrap \
|
||||
--dev-bind / / \
|
||||
--bind /usr/lib/${ABL_ARCH_DIR}/additional-base-lib/"$ABL_TARGET_LD_SO_PATH" "$ABL_LD_SO_PATH" \
|
||||
--bind /usr/lib/${ABL_ARCH_DIR}/additional-base-lib/libc.so.6 "$ABL_LIBC_SO_PATH" \
|
||||
--bind /usr/lib/${ABL_ARCH_DIR}/additional-base-lib/ldd /usr/bin/ldd \
|
||||
--setenv LD_LIBRARY_PATH "$ABL_LIBRARY_PATH" \
|
||||
-- "$@"
|
Loading…
x
Reference in New Issue
Block a user