Last active
January 17, 2022 04:05
-
-
Save ilobmirt/eb1ad581df7de237d97018e8678e6901 to your computer and use it in GitHub Desktop.
get_pkg64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#=================================================================================================# | |
#get_pkg.sh | |
#---------- | |
#by: ilobmirt @ 2022_JAN_16 | |
# | |
#Uses apt to download librarys of a specific architecture and install them to a custom directory | |
#I use this to download arm64 libraries that will be used for applications running under box64 | |
#Learn more about box64 at the project's github page - https://github.com/ptitSeb/box64 | |
#=================================================================================================# | |
cmd_type=$1 | |
get_pkg=$2 | |
install_target="$HOME/x64_lib/" | |
install_architecture="amd64" | |
held_dir=$(pwd) | |
temp_dir="$HOME/Downloads/tmp_$get_pkg" | |
call_help(){ | |
message=" | |
How to use get_pkg: | |
\n------------------- | |
\nsh get_pkg.sh [list|install] (package name) (Target directory) | |
\n | |
\nThis script is designed to find *.so* files from within a | |
\ndebian $install_architecture package and copy them to a specified library | |
\nlocation. This over going to | |
\nhttps://www.debian.org/distrib/packages and then downloading | |
\nand extracting the librarys by hand. | |
\n | |
\n\tlist\t- | |
\n\t\tLists all packages matching package name | |
\n | |
\n\tinstall\t- | |
\n\t\tDownloads the packages and extracts them to | |
\n\t\tTarget directory. (DEFAULT:$install_target) | |
\n\t\tYou can overrite this by specifying this after | |
\n\t\tspecifying the package name." | |
echo $message | |
} | |
#Verify architecture is set up in system | |
if [ -z $(dpkg --print-foreign-architectures | grep $install_architecture) ]; then | |
echo "Adding $install_architecture to system's package lists" | |
dpkg --add-architecture $install_architecture | |
sudo apt-get update | |
fi | |
if [ "$cmd_type" = "list" ];then | |
if [ -z "$getpkg" ];then | |
call_help | |
exit 1 | |
fi | |
sudo apt list *$get_pkg* | grep $install_architecture | |
elif [ "$cmd_type" = "install" ]; then | |
if [ -z "$getpkg" ];then | |
call_help | |
exit 1 | |
fi | |
if [ -n $3 ];then | |
install_target=$3 | |
echo "Changed install target to $install_target" | |
fi | |
mkdir $temp_dir | |
cd $temp_dir | |
apt-get download $get_pkg:$install_architecture | |
dpkg-deb -xv *.deb extracted | |
found_libraries=$(find . -name *.so*) | |
for found_library in $found_libraries | |
do | |
cp -a $found_library $install_target | |
done | |
cd $held_dir | |
rm -rf $temp_dir | |
else | |
call_help | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment