Skip to content

Instantly share code, notes, and snippets.

@matchaniat
Last active March 17, 2019 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matchaniat/9dc8f4f8e1919c981b3c4feea9e4dd37 to your computer and use it in GitHub Desktop.
Save matchaniat/9dc8f4f8e1919c981b3c4feea9e4dd37 to your computer and use it in GitHub Desktop.
#!/bin/bash
ARCH=armhf
DIST=stretch
download-install () {
wget -q http://ftp.debian.org/debian/$1
ar x ${1##*/} data.tar.xz
ar x ${1##*/} data.tar.gz
tar xf data.tar.xz -C $2
tar xf data.tar.gz -C $2
rm -f ${1##*/}
rm -f data.tar.xz
rm -f data.tar.gz
echo "Package was successfully installed"
exit 0
}
if [ -z $1 ] || [ -z $2 ]
then echo "Usage : $0 package_name sysroot_path"
exit 1
fi
if [ ! -d $2 ] ; then echo "sysroot path $2 doesn't exist" ; exit 2 ; fi
p=`curl -s http://ftp.debian.org/debian/dists/$DIST/main/binary-$ARCH/Packages.xz | xzcat | grep -A 15 -e "Package: $1$" | grep Filename | cut -f 2 -d " "`
if [ $p ] ; then download-install $p $2 ; fi
p=`curl -s http://ftp.debian.org/debian/dists/$DIST/main/binary-all/Packages.xz | xzcat | grep -A 15 -e "Package: $1$" | grep Filename | cut -f 2 -d " "`
if [ $p ] ; then download-install $p $2 ; fi
p=`curl -s http://ftp.debian.org/debian/dists/$DIST/contrib/binary-$ARCH/Packages.xz | xzcat | grep -A 15 -e "Package: $1$" | grep Filename | cut -f 2 -d " "`
if [ $p ] ; then download-install $p $2 ; fi
p=`curl -s http://ftp.debian.org/debian/dists/$DIST/main/binary-all/Packages.xz | xzcat | grep -A 15 -e "Package: $1$" | grep Filename | cut -f 2 -d " "`
if [ $p ] ; then download-install $p $2 ; fi
p=`curl -s http://ftp.debian.org/debian/dists/$DIST/non-free/binary-$ARCH/Packages.xz | xzcat | grep -A 15 -e "Package: $1$" | grep Filename | cut -f 2 -d " "`
if [ $p ] ; then download-install $p $2 ; fi
p=`curl -s http://ftp.debian.org/debian/dists/$DIST/non-free/binary-all/Packages.xz | xzcat | grep -A 15 -e "Package: $1$" | grep Filename | cut -f 2 -d " "`
if [ $p ] ; then download-install $p $2 ; fi
echo "No matching package"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment