summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-06-23 08:49:52 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2023-12-14 17:13:11 -0500
commitf01dd2eb72bb2d8b4d2fd15dc044a4ac76e5895b (patch)
treee01f85a6c025e8aa611276614d45c626c9e07378
parenta403d7fd1b207952e5536e15d0e7ef0484b8c9ed (diff)
[meld-pkgbuilds]: wip
-rwxr-xr-xmeld-pkgbuilds39
1 files changed, 24 insertions, 15 deletions
diff --git a/meld-pkgbuilds b/meld-pkgbuilds
index 9f72a0d..ee420ef 100755
--- a/meld-pkgbuilds
+++ b/meld-pkgbuilds
@@ -6,11 +6,16 @@ readonly ABSLIBRE_DIR=/packages/abslibre
readonly ARCH_URL=https://gitlab.archlinux.org/archlinux/packaging
readonly AUR_URL=https://aur.archlinux.org
+readonly CYELLOW='\033[01;33m'
+readonly CEND='\033[00m'
+
readonly DEBUG=0
-meld_pkgbuilds() # (pkgname [--reverse])
+MeldPkgbuilds() # (pkgname [--reverse])
{
+ WARN() { echo -e "${CYELLOW}WARNING: $@${CEND}" >&2 ; }
+
verify_writable_pkgbuild_dir()
{
[[ -w "$1" || -z "$1" ]] || mkdir "$1" || ! echo "lacking write permission for $1 - quitting"
@@ -28,14 +33,15 @@ meld_pkgbuilds() # (pkgname [--reverse])
# local target_dir="$2"/${repo_or_pkgname}
local target_dir="$2"
-if (( DEBUG )) ; then [[ ! -d "${target_dir}"/.git ]] &&
- echo "git clone ${git_url} \"${target_dir}\"" ||
- echo "(cd \"${target_dir}\" ; git pull ;)" ; fi
+if (( DEBUG )) ; then (echo -n "clone_or_pull() "
+ [[ ! -d "${target_dir}"/.git ]] &&
+ echo "git clone ${git_url} \"${target_dir}\"" ||
+ echo "(cd \"${target_dir}\" ; git pull ;)" ) >&2 ; fi
if [[ ! -d "${target_dir}"/.git ]]
then git clone ${git_url}.git "${target_dir}"
else (cd "${target_dir}" ; git pull ;)
- fi
+ fi &> /dev/null
}
find_statefile()
@@ -68,6 +74,7 @@ if (( DEBUG )) ; then [[ ! -d "${target_dir}"/.git ]] &&
local source_dir="${arch_dir}"
local statefile
local repo
+ local arch
# local is_writable=$(touch "${abslibre_dir}"/PKGBUILD &> /dev/null ; echo $((!$?)))
# local repo=$(echo $(LANG=C pacman -Si ${pkgname} | grep ^Repository | cut -d : -f 2))
@@ -77,9 +84,9 @@ if (( DEBUG )) ; then [[ ! -d "${target_dir}"/.git ]] &&
[[ -n "${abslibre_dir}" ]] && find_pkgbuild ${ABSLIBRE_DIR} | sed 's|^| |'
# warnings
- (( $(find_pkgbuild ${ARCH_DIR} | wc -l) > 1 )) && echo "multiple arch PKGBUILDs found (use --reverse if necessary)"
- (( $(find_pkgbuild ${ABSLIBRE_DIR} | wc -l) > 1 )) && echo "multiple abslibre PKGBUILDs found (use --reverse if necessary)"
- [[ -n "${arch_dir}" && -n "${aur_dir}" ]] && echo "multiple upstream PKGBUILDs found (arch and AUR)"
+ (( $(find_pkgbuild ${ARCH_DIR} | wc -l) > 1 )) && WARN "multiple arch PKGBUILDs found (use --reverse if necessary)"
+ (( $(find_pkgbuild ${ABSLIBRE_DIR} | wc -l) > 1 )) && WARN "multiple abslibre PKGBUILDs found (use --reverse if necessary)"
+ [[ -n "${arch_dir}" && -n "${aur_dir}" ]] && WARN "multiple upstream PKGBUILDs found (arch and AUR)"
# sanity checks
verify_writable_pkgbuild_dir "${source_dir}" || exit 1
@@ -99,13 +106,16 @@ if (( DEBUG )) ; then [[ ! -d "${target_dir}"/.git ]] &&
# consult the arch 'state' repo first
if [[ -z "$source_dir" ]]
then echo "PKGBUILD not found in arch cache ... trying arch ...."
- clone_or_pull ${ARCH_URL}/state "${ARCH_DIR}"/state
+ (clone_or_pull ${ARCH_URL}/state "${ARCH_DIR}"/state || :) | grep -E 'Fast-forward|up to date' > /dev/null
+ ((! $?)) && echo "synchronized state repo" || WARN "failed to synchronize state repo"
+
if statefile="$(find_statefile)"
then repo=$(basename $(dirname "${statefile}"))
+ repo=${repo%-*} ; arch=${repo##*-} ;
source_dir="${ARCH_DIR}"/${pkgname}
# eg: 'qutebrowser' (extra/any)
- echo "found statefile for '${pkgname}' (${repo%-*}/${repo##*-})"
+ echo "found statefile for '${pkgname}' (${repo}/${arch})"
fi
fi
@@ -126,18 +136,17 @@ if (( DEBUG )) ; then [[ ! -d "${target_dir}"/.git ]] &&
source_dir="${AUR_DIR}"/${pkgname} # posibbly same as $aur_dir
[[ -f ${source_dir}/PKGBUILD ]] && echo "PKGBUILD found in AUR cache"
-
clone_or_pull ${AUR_URL}/${pkgname} "${source_dir}"
[[ -f "${source_dir}"/PKGBUILD ]] ||
clone_or_pull ${AUR_URL}/${pkgname}-git "${source_dir}"
-
- [[ -f ${source_dir}/PKGBUILD ]] || echo "PKGBUILD found in AUR"
+ [[ -f "${source_dir}"/PKGBUILD ]] && echo "PKGBUILD found in AUR" ||
+ [[ -d "${source_dir}"/.git ]] && WARN "VCS is empty: ${source_dir}"
fi
[[ -f ${source_dir}/PKGBUILD ]] || ! echo "PKGBUILD not found - quitting" || return 1
if [[ -z "${abslibre_dir}" ]]
- then echo "no such parabola PKGBUILD"
+ then echo "no such parabola PKGBUILD - seeding from upstrean"
abslibre_dir="${testing_dir}"
# copy upstream recipe files and recurse
@@ -155,4 +164,4 @@ if (( DEBUG )) ; then [[ ! -d "${target_dir}"/.git ]] &&
}
-meld_pkgbuilds $@
+MeldPkgbuilds $@