2021-10-28 04:54:18 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# makepkg wrapper that calls customizepkg first
|
2023-01-21 10:26:30 +00:00
|
|
|
# NOTE - not setting -u here since pkgname detection runs into undefined variables a lot
|
|
|
|
set -ef -o pipefail +o history
|
2021-10-28 04:54:18 +00:00
|
|
|
|
|
|
|
CURRENT_DIR_PATH="$(readlink -f "$(realpath -e "$(pwd)")")"
|
|
|
|
GLOBAL_CONF_DIR_PATH='/etc/customizepkg.d'
|
|
|
|
USER_CONF_DIR_PATH="${HOME}/.customizepkg"
|
|
|
|
|
|
|
|
pkgbuild_path="${CURRENT_DIR_PATH}/PKGBUILD"
|
|
|
|
pkgbuild_copy_path="${pkgbuild_path}.original"
|
|
|
|
|
2023-08-14 09:09:37 +00:00
|
|
|
args=("$@")
|
|
|
|
|
2021-10-28 04:54:18 +00:00
|
|
|
function is_readable_file {
|
|
|
|
local file_path="${1:-''}"
|
|
|
|
local ret=1
|
|
|
|
if [[ (-n "$file_path") && (-f "$file_path") && (-r "$file_path") ]];then
|
|
|
|
ret=0
|
|
|
|
fi
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
if is_readable_file "$pkgbuild_path" &&
|
2023-08-14 09:09:37 +00:00
|
|
|
[ $(git status --porcelain --no-renames PKGBUILD | wc -l) -lt 1 ]; then
|
|
|
|
# ! is_readable_file "$pkgbuild_copy_path";then
|
|
|
|
|
|
|
|
#eval $(grep -Pazo '[^[:print:]][[:blank:]]*_?(pkg.*|name)=(\((.|\n)*?\)|[^#]*?(?= *#|\x0a))' ./PKGBUILD | grep -Eva '\$\(|`|pkgdesc')
|
|
|
|
|
|
|
|
#if [[ -n "${pkgname:-''}" ]];then
|
|
|
|
# global_conf_path="${GLOBAL_CONF_DIR_PATH}/${pkgname}"
|
|
|
|
# user_conf_path="${USER_CONF_DIR_PATH}/${pkgname}"
|
|
|
|
# if is_readable_file "$global_conf_path" ||
|
|
|
|
# is_readable_file "$user_conf_path";then
|
|
|
|
git checkout HEAD PKGBUILD
|
|
|
|
customizepkg --modify >&2
|
|
|
|
#touch "${was_already_patched_path}"
|
|
|
|
# fi
|
|
|
|
#fi
|
2021-10-28 04:54:18 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-14 09:09:37 +00:00
|
|
|
exec makepkg "${args[@]}"
|