update: copy PKGBUILD into tracedir

This commit is contained in:
2025-12-25 03:44:55 -05:00
parent 64fbd9fc01
commit 12ddfa6820

25
leaf
View File

@@ -48,9 +48,17 @@ main() {
prepare|build|install|force-install|remove|pack|dirct-install) prepare|build|install|force-install|remove|pack|dirct-install)
leaf_check_permission leaf_check_permission
for _item in "${@:2}"; do for _item in "${@:2}"; do
leaf_find_pkgbuild "${_item}" if [[ x"$1" == x"remove" ]]; then
leaf_find_remove_pkgbuild "${_item}"
else
leaf_find_pkgbuild "${_item}"
fi
leaf_reset_state leaf_reset_state
source "${PKGBUILD_DIR}/${PKG_PREFIX}/${PKG_NAME}".PKGBUILD if [[ x"$1" == x"remove" ]]; then
source "${TRACE_DIR}/${PKG_PREFIX}/${PKG_NAME}/PKGBUILD"
else
source "${PKGBUILD_DIR}/${PKG_PREFIX}/${PKG_NAME}".PKGBUILD
fi
leaf_parse_options leaf_parse_options
srcdir="${BUILD_DIR}/${PKG_PREFIX}/${PKG_NAME}" srcdir="${BUILD_DIR}/${PKG_PREFIX}/${PKG_NAME}"
pkgdir="${srcdir}"/__pkgdir__ pkgdir="${srcdir}"/__pkgdir__
@@ -177,6 +185,18 @@ leaf_find_pkgbuild() {
fi fi
} }
leaf_find_remove_pkgbuild() {
local _location="$(find "${TRACE_DIR}" -type d -wholename "*$1*" -printf "%P\n")"
if [ -z "${_location}" ]; then
leaf_error "Package $1 does NOT exist"
elif [[ $(echo "${_location}" | wc -l) == 1 ]]; then
PKG_PREFIX="$(echo "${_location}" | awk -F'/' '{print $1}')"
PKG_NAME="$(echo "${_location%.PKGBUILD}" | awk -F'/' '{print $2}')"
else
leaf_error "Ambiguous packages, the prefix or version of package must be specified"
fi
}
leaf_invoke_hooks() { leaf_invoke_hooks() {
local _hook _target _hook_dir local _hook _target _hook_dir
local _trace_dir="${TRACE_DIR}/${PKG_PREFIX}/${PKG_NAME}" local _trace_dir="${TRACE_DIR}/${PKG_PREFIX}/${PKG_NAME}"
@@ -362,6 +382,7 @@ leaf_trace_package() {
find . -type f | sort > "${_trace_dir}"/FILES find . -type f | sort > "${_trace_dir}"/FILES
find . -type l | sort > "${_trace_dir}"/LINKS find . -type l | sort > "${_trace_dir}"/LINKS
sed -i "s/.//" "${_trace_dir}"/{DIRS,FILES,LINKS} sed -i "s/.//" "${_trace_dir}"/{DIRS,FILES,LINKS}
install -vm644 "${PKGBUILD_DIR}/${PKG_PREFIX}/${PKG_NAME}.PKGBUILD" "${_trace_dir}/PKGBUILD"
popd > /dev/null 2>&1 popd > /dev/null 2>&1
} }