diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2023-10-23 14:54:20 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2023-12-14 17:13:11 -0500 |
commit | 3e91f623dfeccda372fc55efbba501c9a30049a3 (patch) | |
tree | fb0051d57897ff7524eff0a217c73697c5132289 | |
parent | 71f9208dcd0af27a6f8876ea714dd9bd82d1e58e (diff) |
[meld-pkgbuilds]: handle unknown packages better
-rwxr-xr-x | meld-pkgbuilds | 64 |
1 files changed, 23 insertions, 41 deletions
diff --git a/meld-pkgbuilds b/meld-pkgbuilds index 3f1d5fb..e2eeae2 100755 --- a/meld-pkgbuilds +++ b/meld-pkgbuilds @@ -73,34 +73,31 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] && if [[ ! -d "${target_dir}"/.git ]] then git clone ${git_url} "${target_dir}" 2>&1 - else (cd "${target_dir}" ; git fetch --all > /dev/null ; git pull ;) + else (cd "${target_dir}" ; git fetch &> /dev/null ; git pull ;) # fi &> /dev/null fi | grep -E 'Cloning|Fast-forward|Already up to date.' } - find_pkgbuilds() # ("pkgbuilds_dir") + find_pkgbuild_dirs() # ("pkgbuilds_dir") { local pkgbuilds_dir="$1" - local depth=$([[ "${pkgbuilds_dir}/" =~ ^"${ABSLIBRE_DIR}" ]] && echo 2 || echo 1) - find ${pkgbuilds_dir}/ -maxdepth ${depth} -type d -name ${PKGNAME} | sort ${SORT} + dirname $(find "${pkgbuilds_dir}" -path "*/${PKGNAME}/PKGBUILD" | sort ${SORT}) 2> /dev/null } - find_pkgbuild() # ("pkgbuilds_dir") + find_pkgbuild_dir() # ("pkgbuilds_dir") { - find_pkgbuilds "$1" | head -n 1 + find_pkgbuild_dirs "$1" | head -n 1 } local blacklist_entry=$(libreblacklist get ${PKGNAME} 2> /dev/null) - local arch_dir="$( find_pkgbuild ${ARCH_DIR} )" - local artix_dir="$( find_pkgbuild ${ARTIX_DIR} )" - local aur_dir="$( find_pkgbuild ${AUR_DIR} )" - local abslibre_dir="$(find_pkgbuild ${ABSLIBRE_DIR})" - local repo=$(get_repo ${PKGNAME}) - local is_nonsystemd=$( [[ "${abslibre_dir}" =~ /nonsystemd(-testing)?/[^/]*$ || \ - "${repo}" =~ ^nonsystemd(-testing)?$ ]] ; \ - echo $((! $?)) ; ) + local arch_dir="$( find_pkgbuild_dir ${ARCH_DIR} )" + local artix_dir="$( find_pkgbuild_dir ${ARTIX_DIR} )" + local aur_dir="$( find_pkgbuild_dir ${AUR_DIR} )" + local abslibre_dir="$(find_pkgbuild_dir ${ABSLIBRE_DIR})" + local is_nonsystemd + local cached_dir local upstream local upstream_url local source_dir @@ -123,20 +120,10 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] && if [[ -n "${arch_dir}${artix_dir}${aur_dir}${abslibre_dir}" ]] then echo "cached PKGBUILDs:" - find_pkgbuilds ${ARCH_DIR} | sed 's|^| |' - find_pkgbuilds ${ARTIX_DIR} | sed 's|^| |' - find_pkgbuilds ${AUR_DIR} | sed 's|^| |' - find_pkgbuilds ${ABSLIBRE_DIR} | sed 's|^| |' - fi - - # set upstream source - if (( is_nonsystemd )) - then [[ -z "${artix_dir}" ]] && echo "PKGBUILD not found in artix cache" - upstream=artix ; upstream_url=${ARTIX_URL}/packages/${PKGNAME}.git ; - source_dir="${ARTIX_DIR}"/${PKGNAME} - else [[ -z "${arch_dir}" ]] && echo "PKGBUILD not found in arch cache" - upstream=arch ; upstream_url=${ARCH_URL}/packages/${PKGNAME}.git ; - source_dir="${ARCH_DIR}"/${PKGNAME} + find_pkgbuild_dirs ${ARCH_DIR} | sed 's|^| |' + find_pkgbuild_dirs ${ARTIX_DIR} | sed 's|^| |' + find_pkgbuild_dirs ${AUR_DIR} | sed 's|^| |' + find_pkgbuild_dirs ${ABSLIBRE_DIR} | sed 's|^| |' fi # consult the arch 'state' repo first @@ -150,16 +137,12 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] && # eg: 'qutebrowser' (extra/any) echo "found statefile for '${PKGNAME}' (${arch}/${repo} ${pkgver})" - - if [[ -z "${abslibre_dir}" ]] - then repo=$((( is_nonsystemd )) && echo 'nonsystemd' || echo 'libre') - abslibre_dir="${ABSLIBRE_DIR}"/${repo}/${PKGNAME} - fi else WARN "statefile not found for '${PKGNAME}'" - [[ -n "${abslibre_dir}" ]] || abslibre_dir="${DEF_ABSLIBRE_DIR}" fi + (( DEBUG )) && DBG "abslibre_dir='$abslibre_dir'" +(( DEBUG )) && DBG "pkgbuild='$pkgbuild'" (( DEBUG )) && DBG "upstream='$upstream' upstream_url='$upstream_url'" (( DEBUG )) && DBG "source_dir(init)='${source_dir}'" # (( DEBUG )) && exit 0 @@ -168,7 +151,8 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] && # set abslibre target directory is_nonsystemd=$( [[ "${abslibre_dir}" =~ /nonsystemd(-testing)?/[^/]*$ || \ - "$(get_repo ${PKGNAME})" =~ ^nonsystemd(-testing)?$ ]] ; \ + "$(get_repo ${PKGNAME})" =~ ^nonsystemd(-testing)?$ || \ + -z "${statefile}" ]] ; \ echo $((! $?)) ; ) cached_dir="${abslibre_dir}" if [[ -z "${abslibre_dir}" ]] @@ -195,11 +179,10 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] && fi # warnings - [[ -n "${arch_dir}" && -n "${aur_dir}" ]] && WARN "multiple upstream PKGBUILDs found (arch and AUR)" - [[ -n "${artix_dir}" && -n "${aur_dir}" ]] && WARN "multiple upstream PKGBUILDs found (artix and AUR)" - (( $(find_pkgbuilds ${ABSLIBRE_DIR} | wc -l) > 1 )) && WARN "multiple abslibre PKGBUILDs found (use --reverse if necessary)" - [[ "${abslibre_dir}" == "$(find_pkgbuild ${ABSLIBRE_DIR})" ]] || - WARN "orphaned abslibre_dir: '$(find_pkgbuild ${ABSLIBRE_DIR})' (cleanup manually)" + [[ -z "${arch_dir}" || -z "${aur_dir}" ]] || WARN "multiple upstream PKGBUILDs found (arch and AUR)" + [[ -z "${artix_dir}" || -z "${aur_dir}" ]] || WARN "multiple upstream PKGBUILDs found (artix and AUR)" + (( $(find_pkgbuild_dirs ${ABSLIBRE_DIR} | wc -l) < 2 )) || WARN "multiple abslibre PKGBUILDs found (use --reverse if necessary)" + [[ -z "${cached_dir}" || "${abslibre_dir}" == "${cached_dir}" ]] || WARN "orphaned abslibre_dir: '${pkgbuild}' (cleanup manually)" # sanity checks verify_writable_dir "${source_dir}" || exit 1 @@ -258,7 +241,6 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] && readonly PKGNAME_RX='^[-@\._\+0-9a-z]+$' ; readonly SORT=$( [[ "$1" == '--reverse' ]] && echo "$1" ) ; [[ -z "${SORT}" ]] || shift ; readonly PKGNAME=$( [[ "$1" =~ ${PKGNAME_RX} ]] && echo "$1" ) -readonly DEF_ABSLIBRE_DIR="${ABSLIBRE_DIR}"/pcr/${PKGNAME} (( $# == 1 )) || ! echo "invalid params" || exit 1 [[ -n "${PKGNAME}" ]] || ! echo "invalid pkgname: '$1'" || exit 1 |