You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

72 lines
2.4 KiB

#!/bin/sh
# Get custom templates and display them on project README
update_readme() {
local_pkgs="$(git diff --name-only upstream/master master srcpkgs/ | awk -F "/" '{print $2}' | sort | uniq)"
for pkg in $local_pkgs; do
new_pkgs="$new_pkgs* [$pkg](srcpkgs/$pkg)
"
done
cat <<EOF > README.md
This fork contains templates for the following list of packages:
${new_pkgs}
If you'd like to build and install all the custom templates, run \`./deploy --install\`. Else, if you only want a specific package, manually run (make sure to have [\`xtools\`](https:/github.com/leahneukirchen/xtools) installed):
\`\`\`sh
./xbps-src binary-bootstrap
./xbps-src pkg pkgname
xi pkgname
\`\`\`
EOF
}
# Check whether the package in our pkglist belongs to the main repo
# or if it's not found build it locally and install it
install() {
built_pkgs=
# Synchronize remote packages
doas xbps-install -Suvy
# Initialise the binary bootstrap for our local void-packages build
./xbps-src binary-bootstrap
if [ -f pkglist.txt ]; then
while IFS= read -r pkg || [ -n "$pkg" ]; do
# We need to strip the version number from the package name
pkgname="$(echo $pkg | rev | cut -d- -f 2- | rev)"
# Check if the package has already been installed
if xbps-query -l | grep -q "$pkgname"; then
echo "Package "$pkgname" already installed"
# Check if package is installed in the remote repository
elif [ $(xbps-query --regex -Rs "^$pkgname" | wc -l) -ne 0 ]; then
doas xbps-install -Sy "$pkgname"
# Check if the package is installed in the local repository
elif [ $(xpkg -L | grep -q "$pkgname") ]; then
# Check if package has already been built
if ! ls -a hostdir/binpkgs | grep -q "$pkgname"; then
./xbps-src pkg "$pkgname"
built_pkgs="$built_pkgs $pkgname"
fi
built_pkgs="$built_pkgs $pkgname"
echo "Package "$pkgname" has already been locally installed"
# Check if the package exists in the local Void repository
elif [ "$(find srcpkgs -maxdepth 1 -name "$pkgname" -type d | wc -l)" -ne 0 ]; then
built_pkgs="$built_pkgs $pkgname"
else
echo "Package "$pkgname" does not exist neither in local nor remote Void repositories"
fi
done < pkglist.txt
# Install locally built packages
[ "$built_pkgs" ] && doas xi -fy "$built_pkgs"
backup
update_readme
fi
}
case "$1" in
--install) install;;
--update) update_readme;;
esac