Skip to content

Instantly share code, notes, and snippets.

@agustik
Created July 31, 2020 17:37
Show Gist options
  • Save agustik/3ed7beb5b5351a1998cf8ecef353bb04 to your computer and use it in GitHub Desktop.
Save agustik/3ed7beb5b5351a1998cf8ecef353bb04 to your computer and use it in GitHub Desktop.
Finding Freebsd package in repo. Works on pfsense 11
#!/bin/bash
#
# usage bash find-pkg.sh <pkg name>
#
cachedir=/tmp/freebsd/pkc/cache
version=11
repo="http://pkg.freebsd.org/FreeBSD:${version}:amd64/latest/"
metdata="${repo}/packagesite.txz"
if [ ! -d $cachedir ]; then
echo "${cachedir} does not exists, creating"
mkdir -p $cachedir
fi
if [ ! -f $cachedir/packagesite.txz ]; then
echo "${cachedir}/packagesite.txz does not exists, downloading from ${metdata}"
curl $metdata -o $cachedir/packagesite.txz
fi
if [ ! -f $cachedir/packagesite.tar ]; then
echo "${cachedir}/packagesite.tar does not exists, extracting from ${cachedir}/packagesite.txz"
xz -d $cachedir/packagesite.txz
tar -xf $cachedir/packagesite.tar -C $cachedir
fi
cat $cachedir/packagesite.yaml | jq -r .path | grep $1 | while read line; do
echo "${repo}/${line}";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment