Added tlrepobuild to automate the building of packages, and adding them to my remote repo

This commit is contained in:
David Thurstenson 2020-08-10 01:21:06 -05:00
parent ac5af0678f
commit e41f9e5ab2
1 changed files with 71 additions and 1 deletions

View File

@ -105,8 +105,78 @@ tldirtyaurbuild() {
# in the pushd dir.
# Do the thing!
pushd "$dest"
makepkg "${makepkg_opts[@]}"
if makepkg "${makepkg_opts[@]}"; then
return 0
else
return 1
fi
popd
)
fi
}
tlrepobuild() {
local hostcheck="thurstylark-vps"
local remotehost="vps"
local remote_repo_path="/var/cache/pacman/tl/"
local reponame="tl"
local pkg="$1"
local -a aur_sync_opts
aur_sync_opts+=('--no-confirm' '--no-view')
local resultdir="$HOME/repos/aur"
local full_pkgname
local remote_pkg_path
case "$(uname -n)" in
"$hostcheck") aur sync "${aur_sync_opts[@]}" "$pkg";;
*)
while true; do
read -p "Build [L]ocally, or [R]emotely on $hostcheck? [l/R]" yn
case $yn in
[Ll]* )
if tldirtyaurbuild -s "$pkg"; then
tldaecho "Success, uploading to $hostcheck..."
else
tldaecho -t e "Unable to build $pkg. Exiting."
return 1
fi
if full_pkgname="$(find $resultdir/$pkg/$pkg*.pkg.tar.xz -printf '%f')"; then
tldaecho "Resulting Package: $full_pkgname"
else
tldaecho -t e "Unable to find resulting package file. Exiting."
return 1
fi
if scp "$resultdir/$pkg/$full_pkgname" "$remotehost":"$remote_repo_path"; then
tldaecho "Success. Adding $full_pkgname to $reponame..."
else
tldaecho -t e "Unable to upload package to $hostcheck. Exiting."
return 1
fi
if remote_pkg_path="$(ssh $remotehost find $remote_repo_path/$full_pkgname)"; then
tldaecho "Package's path within repo: $remote_pkg_path"
else
tldaecho -t e "Unable to find package in $hostcheck:$remote_repo_path Exiting."
return 1
fi
if ssh "$remotehost" repo-add -n "$remote_repo_path/$reponame.db.tar" "$remote_pkg_path"; then
tldaecho "Done. Package built, and added to remote repo."
return 0
else
tldaecho -t e "Unable to add package to remote repo. Exiting."
return 1
fi
;;
* )
if ssh "$remotehost" aur sync --no-ver "${aur_sync_opts[@]}" "$pkg"; then
tldaecho "Done."
return 0
else
tldaecho -t e "Unknown error. Exiting"
return 1
fi
;;
esac
done
;;
esac
}