From 80af587865f7d67c61e6c57525fe4719af26c291 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 7 Feb 2021 23:03:19 +0100 Subject: pkgs: Split nvchecker configs bin/pkgs: Split nvchecker configs into per-repo configs so it gets easier to track. The nvchecker repo config is created if it does not exist yet (currently only if a package is created as "new"). Automatically remove AUR package directories so no manual cleanup is necessary. --- bin/pkgs | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/pkgs b/bin/pkgs index 253ca91..700fb43 100755 --- a/bin/pkgs +++ b/bin/pkgs @@ -8,7 +8,7 @@ set -eu [ -f "${HOME}/.makepkg.conf" ] && . "${HOME}/.makepkg.conf" package_dir_base="${HOME}/packages/" -nvchecker_config="${HOME}/.config/nvchecker/nvchecker.toml" +nvchecker_dir_base="${HOME}/.config/nvchecker/" repo="" package="" mode="" @@ -39,7 +39,7 @@ check_dependencies() { local _command for _command in "${_commands[@]}"; do - if ! command -v s > /dev/null; then + if ! command -v "${_command}" > /dev/null; then printf "The required command %s can not be found. Exiting...\n" "$_command" exit 1 fi @@ -66,6 +66,16 @@ add_package() { rm "$tmp_file" } +create_nvchecker_config() { + if [[ ! -d "${nvchecker_dir_base}" ]]; then + mkdir -p "${nvchecker_dir_base}" + fi + if [[ ! -f "${nvchecker_dir_base}${repo}.toml" ]]; then + printf "[__config__]\noldver = \"%s.old.txt\"\nnewver = \"%s.new.txt\"\n" "${repo}" "${repo}" \ + > "${nvchecker_dir_base}${repo}.toml" + fi +} + create_package() { local name="$1" local pkgbuild="" @@ -75,22 +85,23 @@ create_package() { git clone "${upstreams[$repo]}:${name}" pkgbuild="${name}/PKGBUILD" else - mkdir -p "${name}"/{trunk,repos} - pkgbuild="${name}/trunk/PKGBUILD" + svn update "${name}" + if [[ ! -d "${name}" ]]; then + mkdir -p "${name}"/{trunk,repos} + pkgbuild="${name}/trunk/PKGBUILD" + fi fi - if [ ! -f "${pkgbuild}" ]; then + if [[ -n "${pkgbuild}" ]] && [[ ! -f "${pkgbuild}" ]]; then cp /usr/share/pacman/PKGBUILD.proto "${pkgbuild}" sed -e "s/NAME/$name/g" \ -e "1i# Maintainer: ${PACKAGER:-}" \ -e '/#/d' \ -i "${pkgbuild}" fi - if [ ! -f "${nvchecker_config}" ]; then - mkdir -p "$(dirname "${nvchecker_config}")" - touch "${nvchecker_config}" - fi - if ! grep -q "\[$name\]" "${nvchecker_config}"; then - printf '\n[%s]\n\n' "${name}" >> "$nvchecker_config" + + create_nvchecker_config + if ! grep -q "\[$name\]" "${nvchecker_dir_base}${repo}.toml"; then + printf '\n[%s]\n\n' "${name}" >> "${nvchecker_dir_base}${repo}.toml" fi } @@ -102,6 +113,17 @@ remove_package() { cat "${package_lists[$repo]}" |grep -vE "^$name$" |uniq |sort > "$tmp_file" cat "$tmp_file" > "${package_lists[$repo]}" rm "$tmp_file" + + if [[ "$repo" == aur ]]; then + rm -rf "${package_dirs[$repo]:?}/$name" + fi + # TODO: remove package dirs from svn + + # remove entry from nvchecker config + if grep -q "\[$name\]" "${nvchecker_dir_base}${repo}.toml"; then + sed -e "/^\[$name\]/,/^\[/{/^\[/!d};/^\[$name\]/d" \ + -i "${nvchecker_dir_base}${repo}.toml" + fi } check_mode_set(){ @@ -110,6 +132,7 @@ check_mode_set(){ exit 1 fi } + check_repo_set(){ if [ -n "$repo" ]; then echo "Error: A repo can only be set once." -- cgit v1.2.3-70-g09d2