summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-07-14 02:35:54 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2023-12-14 17:13:11 -0500
commit5b2e6e23c969613a91158f5cbf6ef874c145f685 (patch)
treef306ce3ecc003a059baf4a87565b8e4163793f62
parentf01dd2eb72bb2d8b4d2fd15dc044a4ac76e5895b (diff)
[meld-pkgbuilds]: wip
-rwxr-xr-xmeld-pkgbuilds242
1 files changed, 155 insertions, 87 deletions
diff --git a/meld-pkgbuilds b/meld-pkgbuilds
index ee420ef..0c3bd5e 100755
--- a/meld-pkgbuilds
+++ b/meld-pkgbuilds
@@ -1,29 +1,60 @@
#!/bin/bash
+readonly DEBUG=0
+
readonly ARCH_DIR=/packages/arch
+readonly ARTIX_DIR=/packages/artix
readonly AUR_DIR=/packages/aur
readonly ABSLIBRE_DIR=/packages/abslibre
readonly ARCH_URL=https://gitlab.archlinux.org/archlinux/packaging
+readonly ARTIX_URL=https://gitea.artixlinux.org
readonly AUR_URL=https://aur.archlinux.org
+readonly CAQUA='\033[00;36m'
readonly CYELLOW='\033[01;33m'
readonly CEND='\033[00m'
-readonly DEBUG=0
+PKGNAME_RX= # deferred
+SORT= # deferred
+PKGNAME= # deferred
-MeldPkgbuilds() # (pkgname [--reverse])
+MeldPkgbuilds()
{
+ DBG() { echo -e "${CAQUA}DEBUG: $@${CEND}" >&2 ; }
WARN() { echo -e "${CYELLOW}WARNING: $@${CEND}" >&2 ; }
- verify_writable_pkgbuild_dir()
+ get_repo()
+ {
+ LANG=C sudo pacman --config /etc/pacman-all.conf -Syi ${PKGNAME} | \
+ grep ^Repository | sort ${SORT} | head -n 1 | cut -d : -f 2 | tr -d ' '
+ }
+
+ find_statefile()
+ {
+ local state_dir="${ARCH_DIR}"/state
+ local statefile="$(find "${state_dir}" -maxdepth 2 -type f -name ${PKGNAME})"
+
+ echo "${statefile}"
+ [[ -n "${statefile}" ]]
+ }
+
+ verify_writable_dir() # ("target_dir")
{
- [[ -w "$1" || -z "$1" ]] || mkdir "$1" || ! echo "lacking write permission for $1 - quitting"
+ local target_dir="$1"
+ local param_err_msg="invalid target_dir '${target_dir}' - quitting"
+ local perms_err_msg="lacking write permission for '${target_dir}' - quitting"
+
+ [[ -n "${target_dir}" ]] || ! echo "${param_err_msg}" || return 1
+ mkdir -p "${target_dir}" || ! echo "${perms_err_msg}" || return 1
+# [[ -d "${target_dir}" && -w "${target_dir}" ]] ||
+# mkdir "$1" || ! echo "lacking write permission for '${target_dir}' - quitting"
+# [[ -n "${target_dir}" && -w "${target_dir}" ]]
}
clone_or_pull() # (git_url "target_dir")
{
- # eg: | ${ARCH_URL} | | pkgname |
+ # eg: | $ARCH_URL | | $PKGNAME |
# eg: https://gitlab.archlinux.org/archlinux/packaging/packages/qutebrowser.git
local git_url=$1
@@ -33,24 +64,15 @@ MeldPkgbuilds() # (pkgname [--reverse])
# local target_dir="$2"/${repo_or_pkgname}
local target_dir="$2"
-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 (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
+ DBG "git clone ${git_url} \"${target_dir}\"" ||
+ DBG "(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 &> /dev/null
- }
-
- find_statefile()
- {
- local state_dir="${ARCH_DIR}"/state
- local statefile="$(find "${state_dir}" -maxdepth 2 -type f -name ${pkgname})"
-
- echo "${statefile}"
- [[ -n "${statefile}" ]]
+ then git clone ${git_url} "${target_dir}" 2>&1
+ else (cd "${target_dir}" ; git fetch --all ; git pull ;)
+# fi &> /dev/null
+ fi | grep -E 'Cloning|Fast-forward|Already up to date.'
}
find_pkgbuild() # (pkgbuilds_dir)
@@ -58,105 +80,144 @@ if (( DEBUG )) ; then (echo -n "clone_or_pull() "
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_order}
+ find ${pkgbuilds_dir}/ -maxdepth ${depth} -type d -name ${PKGNAME} | sort ${SORT}
}
- local pkgname_rx='^[-@\._\+0-9a-z]+$' ;
- local pkgname=$( [[ "$1" =~ ${pkgname_rx} ]] && echo "$1" )
- local sort_order=$( [[ "$2" == '--reverse' ]] && echo "$2" )
- [[ -z "${pkgname}" ]] && echo "invalid pkgname: '$1'" && return 1
-
local arch_dir="$( find_pkgbuild ${ARCH_DIR} | head -n 1)"
+ local artix_dir="$( find_pkgbuild ${ARTIX_DIR} | head -n 1)"
local aur_dir="$( find_pkgbuild ${AUR_DIR} | head -n 1)"
local abslibre_dir="$(find_pkgbuild ${ABSLIBRE_DIR} | head -n 1)"
- local testing_dir="${ABSLIBRE_DIR}"/libre-testing/${pkgname}
- local source_dir="${arch_dir}"
+ local repo=$(get_repo ${PKGNAME})
+ local is_nonsystemd=$( [[ "${abslibre_dir}" =~ /nonsystemd(-testing)?/[^/]*$ || \
+ "${repo}" =~ ^nonsystemd(-testing)?$ ]] ; \
+ echo $((! $?)) ; )
+ local upstream
+ local upstream_url
+ local source_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))
+ local pkgver
- [[ -n "${arch_dir}" || -n "${aur_dir}" || -n "${abslibre_dir}" ]] && echo "PKGBUILDs found:"
- [[ -n "${arch_dir}" ]] && find_pkgbuild ${ARCH_DIR} | sed 's|^| |'
- [[ -n "${aur_dir}" ]] && find_pkgbuild ${AUR_DIR} | sed 's|^| |'
- [[ -n "${abslibre_dir}" ]] && find_pkgbuild ${ABSLIBRE_DIR} | sed 's|^| |'
- # warnings
- (( $(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)"
+(( DEBUG )) && DBG "PKGNAME='$PKGNAME'"
+(( DEBUG )) && DBG "arch_dir='$arch_dir'"
+(( DEBUG )) && DBG "artix_dir='$artix_dir'"
+(( DEBUG )) && DBG "aur_dir='$aur_dir'"
+(( DEBUG )) && DBG "abslibre_dir='$abslibre_dir'"
- # sanity checks
- verify_writable_pkgbuild_dir "${source_dir}" || exit 1
- verify_writable_pkgbuild_dir "${abslibre_dir}" || exit 1
- verify_writable_pkgbuild_dir "${testing_dir}" || exit 1
-
-(( DEBUG )) && echo "pkgname='$pkgname'"
-(( DEBUG )) && echo "arch_dir='$arch_dir'"
-(( DEBUG )) && echo "aur_dir='$aur_dir'"
-(( DEBUG )) && echo "abslibre_dir='$abslibre_dir'"
-(( DEBUG )) && echo "testing_dir='$testing_dir'"
-(( DEBUG )) && echo "source_dir='$source_dir'"
-# (( DEBUG )) && exit 0
-# (( DEBUG )) && source_dir=''
+ blacklist_entry=$(libreblacklist get ${PKGNAME} 2> /dev/null)
+ if [[ -n "${blacklist_entry}" ]]
+ then echo "blacklist reason: $(libreblacklist get-reason <<<${blacklist_entry})"
+ else echo "pkgname: ${PKGNAME} is not blacklisted"
+ fi
+
+ [[ -n "${arch_dir}" || -n "${artix_dir}" ||
+ -n "${aur_dir}" || -n "${abslibre_dir}" ]] && echo "cached PKGBUILDs:"
+# [[ -n "${arch_dir}" ]] && find_pkgbuild ${ARCH_DIR} | sed 's|^| |'
+# [[ -n "${artix_dir}" ]] && find_pkgbuild ${ARTIX_DIR} | sed 's|^| |'
+# [[ -n "${aur_dir}" ]] && find_pkgbuild ${AUR_DIR} | sed 's|^| |'
+# [[ -n "${abslibre_dir}" ]] && find_pkgbuild ${ABSLIBRE_DIR} | sed 's|^| |'
+# (( $(find_pkgbuild ${ABSLIBRE_DIR} | wc -l) )) && find_pkgbuild ${ABSLIBRE_DIR} | sed 's|^| |'
+ find_pkgbuild ${ARCH_DIR} | sed 's|^| |'
+ find_pkgbuild ${ARTIX_DIR} | sed 's|^| |'
+ find_pkgbuild ${AUR_DIR} | sed 's|^| |'
+ find_pkgbuild ${ABSLIBRE_DIR} | sed 's|^| |'
+
+ # 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}
+ fi
# 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 || :) | 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}/${arch})"
+ echo "consulting arch state repo ...."
+ clone_or_pull ${ARCH_URL}/state.git "${ARCH_DIR}"/state
+ ((! $?)) && echo "synchronized state repo" || WARN "failed to synchronize state repo"
+ if statefile="$(find_statefile)"
+ then repo=$(basename $(dirname "${statefile}"))
+ arch=${repo##*-} ; repo=${repo%-*} ;
+ pkgver=$(cut -d ' ' -f 2 ${statefile}) # [pkgbase pkgver git-tag checksum]
+
+ # 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}'"
fi
-(( DEBUG )) && echo "source_dir='$source_dir'"
- # search arch VCS for PKGBUILD
- if [[ -n "${source_dir}" ]]
- then echo "cloning from arch ...."
- clone_or_pull ${ARCH_URL}/packages/${pkgname} "${source_dir}"
- fi
+(( DEBUG )) && DBG "abslibre_dir='$abslibre_dir'"
+(( DEBUG )) && DBG "upstream='$upstream' upstream_url='$upstream_url'"
+(( DEBUG )) && DBG "source_dir(init)='${source_dir}'"
+# (( DEBUG )) && exit 0
+# (( DEBUG )) && source_dir=''
+
+
+ # warnings
+ (( $(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)"
+ [[ -n "${artix_dir}" && -n "${aur_dir}" ]] && WARN "multiple upstream PKGBUILDs found (artix and AUR)"
+
+ # sanity checks
+ verify_writable_dir "${source_dir}" || exit 1
+ verify_writable_dir "${abslibre_dir}" || exit 1
-(( DEBUG )) && echo "source_dir='$source_dir'"
+
+ # search arch or artix VCS for PKGBUILD
+ if [[ "$(curl -s -w '%{http_code}' -o /dev/null ${upstream_url%.git})" == 200 ]]
+ then [[ -f "${source_dir}"/PKGBUILD ]] || echo "attempting to clone from ${upstream} ...."
+ clone_or_pull ${upstream_url} "${source_dir}"
+ else WARN "${upstream} repo not found for '${PKGNAME}'"
+ fi
# search AUR VCS for PKGBUILD
if [[ -f "${source_dir}"/PKGBUILD ]]
- then echo "PKGBUILD found in arch"
- else echo "PKGBUILD not found in arch ... trying AUR ...."
- source_dir="${AUR_DIR}"/${pkgname} # posibbly same as $aur_dir
+ then echo "PKGBUILD found in ${upstream}"
+ else echo "PKGBUILD not found in ${upstream} ... trying AUR ...."
+ 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 ]] && echo "PKGBUILD found in AUR cache"
+ clone_or_pull ${AUR_URL}/${PKGNAME}.git "${source_dir}"
[[ -f "${source_dir}"/PKGBUILD ]] ||
- clone_or_pull ${AUR_URL}/${pkgname}-git "${source_dir}"
+ clone_or_pull ${AUR_URL}/${PKGNAME}-git.git "${source_dir}"
[[ -f "${source_dir}"/PKGBUILD ]] && echo "PKGBUILD found in AUR" ||
- [[ -d "${source_dir}"/.git ]] && WARN "VCS is empty: ${source_dir}"
+ [[ ! -d "${source_dir}"/.git ]] || WARN "VCS is empty: ${source_dir}"
+
+ [[ "${abslibre_dir}" == "${ABSLIBRE_DIR}"/pcr/${PKGNAME} ]] ||
+ WARN "abslibre_dir mismatch: '${abslibre_dir}' != '${ABSLIBRE_DIR}/pcr/${PKGNAME}'"
+ abslibre_dir="${ABSLIBRE_DIR}"/pcr/${PKGNAME}
fi
[[ -f ${source_dir}/PKGBUILD ]] || ! echo "PKGBUILD not found - quitting" || return 1
- if [[ -z "${abslibre_dir}" ]]
- then echo "no such parabola PKGBUILD - seeding from upstrean"
- abslibre_dir="${testing_dir}"
+
+(( DEBUG )) && DBG "source_dir(final)='${source_dir}'"
+
+
+ if [[ ! -f "${abslibre_dir}"/PKGBUILD ]]
+ then echo "no such parabola PKGBUILD - seeding from upstream"
# copy upstream recipe files and recurse
- mkdir "${abslibre_dir}"
- cp "${source_dir}"/* "${abslibre_dir}"/
- meld-pkgbuilds "$@" ; return $? ;
+ mkdir -p "${abslibre_dir}"
+ cp -a "${source_dir}"/* "${abslibre_dir}"/
fi
-(( DEBUG )) && echo out && return
+(( DEBUG )) && DBG "DEBUG done - set DEBUG=0 to launch meld" && return
+
+
+ echo -e "\nlaunching meld\n"
ls -l "${source_dir}"/ "${abslibre_dir}"/ ; echo ;
(set -x ; meld "${source_dir}"/ "${abslibre_dir}"/)
@@ -164,4 +225,11 @@ if (( DEBUG )) ; then (echo -n "clone_or_pull() "
}
-MeldPkgbuilds $@
+readonly PKGNAME_RX='^[-@\._\+0-9a-z]+$' ;
+readonly SORT=$( [[ "$1" == '--reverse' ]] && echo "$1" ) ; [[ -z "${SORT}" ]] || shift ;
+readonly PKGNAME=$( [[ "$1" =~ ${PKGNAME_RX} ]] && echo "$1" )
+(( $# == 1 )) || ! echo "invalid params" || exit 1
+[[ -n "${PKGNAME}" ]] || ! echo "invalid pkgname: '$1'" || exit 1
+
+
+MeldPkgbuilds