diff options
author | David Runge <dave@sleepmap.de> | 2021-02-07 23:03:19 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2021-02-07 23:03:19 +0100 |
commit | 80af587865f7d67c61e6c57525fe4719af26c291 (patch) | |
tree | 25696a2b8cb2f5862db9bee822ee63e913d0bb18 /bin/pkgs | |
parent | 9d8caa469ebd39199d4508a4ba649619b136a214 (diff) | |
download | dotfiles-80af587865f7d67c61e6c57525fe4719af26c291.tar.gz dotfiles-80af587865f7d67c61e6c57525fe4719af26c291.tar.bz2 dotfiles-80af587865f7d67c61e6c57525fe4719af26c291.tar.xz dotfiles-80af587865f7d67c61e6c57525fe4719af26c291.zip |
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.
Diffstat (limited to 'bin/pkgs')
-rwxr-xr-x | bin/pkgs | 45 |
1 files changed, 34 insertions, 11 deletions
@@ -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." |