summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-10-23 14:35:03 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2023-12-14 17:13:11 -0500
commit71f9208dcd0af27a6f8876ea714dd9bd82d1e58e (patch)
tree96d8182e11c8e9c2afc88f249bca24097799667b
parent5b2e6e23c969613a91158f5cbf6ef874c145f685 (diff)
[meld-pkgbuilds]: WIP
-rwxr-xr-xmeld-pkgbuilds104
1 files changed, 68 insertions, 36 deletions
diff --git a/meld-pkgbuilds b/meld-pkgbuilds
index 0c3bd5e..3f1d5fb 100755
--- a/meld-pkgbuilds
+++ b/meld-pkgbuilds
@@ -14,6 +14,8 @@ readonly CAQUA='\033[00;36m'
readonly CYELLOW='\033[01;33m'
readonly CEND='\033[00m'
+readonly CLONE_MSG="attempting to clone from"
+
PKGNAME_RX= # deferred
SORT= # deferred
PKGNAME= # deferred
@@ -26,14 +28,15 @@ MeldPkgbuilds()
get_repo()
{
- LANG=C sudo pacman --config /etc/pacman-all.conf -Syi ${PKGNAME} | \
+ LANG=C sudo pacman --config /etc/pacman-all.conf -Syi ${PKGNAME} 2>/dev/null | \
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})"
+ local statefile="$(find "${state_dir}"/{core,extra,multilib}-{any,$(uname -m)} \
+ -maxdepth 2 -type f -name ${PKGNAME} 2> /dev/null )"
echo "${statefile}"
[[ -n "${statefile}" ]]
@@ -42,7 +45,7 @@ MeldPkgbuilds()
verify_writable_dir() # ("target_dir")
{
local target_dir="$1"
- local param_err_msg="invalid target_dir '${target_dir}' - quitting"
+ local param_err_msg="invalid targ# NOTE: you should install 'pacman-all.conf'et_dir '${target_dir}' - quitting"
local perms_err_msg="lacking write permission for '${target_dir}' - quitting"
[[ -n "${target_dir}" ]] || ! echo "${param_err_msg}" || return 1
@@ -70,12 +73,12 @@ 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 ; git pull ;)
+ else (cd "${target_dir}" ; git fetch --all > /dev/null ; git pull ;)
# fi &> /dev/null
fi | grep -E 'Cloning|Fast-forward|Already up to date.'
}
- find_pkgbuild() # (pkgbuilds_dir)
+ find_pkgbuilds() # ("pkgbuilds_dir")
{
local pkgbuilds_dir="$1"
local depth=$([[ "${pkgbuilds_dir}/" =~ ^"${ABSLIBRE_DIR}" ]] && echo 2 || echo 1)
@@ -83,11 +86,17 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
find ${pkgbuilds_dir}/ -maxdepth ${depth} -type d -name ${PKGNAME} | sort ${SORT}
}
+ find_pkgbuild() # ("pkgbuilds_dir")
+ {
+ find_pkgbuilds "$1" | head -n 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 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)?$ ]] ; \
@@ -107,23 +116,18 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
(( DEBUG )) && DBG "abslibre_dir='$abslibre_dir'"
- blacklist_entry=$(libreblacklist get ${PKGNAME} 2> /dev/null)
- if [[ -n "${blacklist_entry}" ]]
+ if [[ -n "${blacklist_entry}" ]]
then echo "blacklist reason: $(libreblacklist get-reason <<<${blacklist_entry})"
- else echo "pkgname: ${PKGNAME} is not blacklisted"
+ 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|^| |'
+ 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 ))
@@ -151,11 +155,10 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
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 "upstream='$upstream' upstream_url='$upstream_url'"
(( DEBUG )) && DBG "source_dir(init)='${source_dir}'"
@@ -163,11 +166,40 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
# (( DEBUG )) && source_dir=''
+ # set abslibre target directory
+ is_nonsystemd=$( [[ "${abslibre_dir}" =~ /nonsystemd(-testing)?/[^/]*$ || \
+ "$(get_repo ${PKGNAME})" =~ ^nonsystemd(-testing)?$ ]] ; \
+ echo $((! $?)) ; )
+ cached_dir="${abslibre_dir}"
+ if [[ -z "${abslibre_dir}" ]]
+ then if [[ -n "${statefile}" ]]
+ then if (( is_nonsystemd ))
+ then abslibre_dir="${ABSLIBRE_DIR}"/nonsystemd/${PKGNAME}
+ else abslibre_dir="${ABSLIBRE_DIR}"/libre/${PKGNAME}
+ fi
+ else if (( is_nonsystemd ))
+ then abslibre_dir="${ABSLIBRE_DIR}"/nonsystemd/${PKGNAME}
+ else abslibre_dir="${ABSLIBRE_DIR}"/pcr/${PKGNAME}
+ fi
+ fi
+ 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}
+ fi
+
# 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)"
+ [[ -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)"
# sanity checks
verify_writable_dir "${source_dir}" || exit 1
@@ -176,7 +208,8 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
# 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} ...."
+ then [[ -f "${source_dir}"/PKGBUILD ]] && echo "syncronizing ${upstream} ...." ||
+ echo "${CLONE_MSG} ${upstream} ...."
clone_or_pull ${upstream_url} "${source_dir}"
else WARN "${upstream} repo not found for '${PKGNAME}'"
fi
@@ -184,8 +217,9 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
# search AUR VCS for PKGBUILD
if [[ -f "${source_dir}"/PKGBUILD ]]
then echo "PKGBUILD found in ${upstream}"
- else echo "PKGBUILD not found in ${upstream} ... trying AUR ...."
+ else echo "PKGBUILD not found in ${upstream} ... ${CLONE_MSG} AUR ...."
source_dir="${AUR_DIR}"/${PKGNAME} # posibbly same as $aur_dir
+ verify_writable_dir "${source_dir}" || exit 1
[[ -f "${source_dir}"/PKGBUILD ]] && echo "PKGBUILD found in AUR cache"
clone_or_pull ${AUR_URL}/${PKGNAME}.git "${source_dir}"
@@ -193,10 +227,6 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
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}"
-
- [[ "${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
@@ -217,7 +247,7 @@ if (( DEBUG )) ; then ([[ ! -d "${target_dir}"/.git ]] &&
(( DEBUG )) && DBG "DEBUG done - set DEBUG=0 to launch meld" && return
- echo -e "\nlaunching meld\n"
+ echo -e "\nlaunching meld on:\n"
ls -l "${source_dir}"/ "${abslibre_dir}"/ ; echo ;
(set -x ; meld "${source_dir}"/ "${abslibre_dir}"/)
@@ -228,6 +258,8 @@ 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