Verified Commit 67c03adf authored by Dan Johansen's avatar Dan Johansen
Browse files

update makepkg script to pacman 6 version


Signed-off-by: Dan Johansen's avatarDan Johansen <strit@manjaro.org>
parent 80dcfcf2
#!/usr/bin/bash
#
# makepkg - make packages compatible for use with pacman
# Generated from makepkg.sh.in; do not edit by hand.
#
# Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2006-2021 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
# Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
......@@ -41,7 +40,7 @@ unset CDPATH
# Ensure GREP_OPTIONS doesn't screw with our grep calls
unset GREP_OPTIONS
declare -r makepkg_version='5.2.0'
declare -r makepkg_version='6.0.0'
declare -r confdir='/etc'
declare -r BUILDSCRIPT='PKGBUILD'
declare -r startdir="$(pwd -P)"
......@@ -133,7 +132,7 @@ clean_up() {
rm "$logpipe"
fi
if (( (EXIT_CODE == E_OK || EXIT_CODE == E_INSTALL_FAILED) && CLEANUP )); then
if (( (EXIT_CODE == E_OK || EXIT_CODE == E_INSTALL_FAILED) && BUILDPKG && CLEANUP )); then
local pkg file
# If it's a clean exit and -c/--clean has been passed...
......@@ -199,13 +198,15 @@ update_pkgver() {
fi
if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
if ! /usr/bin/sed --follow-symlinks -i "s:^pkgver=[^ ]*:pkgver=$newpkgver:" "$BUILDFILE"; then
if [[ -w $BUILDFILE ]]; then
mapfile -t buildfile < "$BUILDFILE"
buildfile=("${buildfile[@]/#pkgver=*([^ ])/pkgver=$newpkgver}")
buildfile=("${buildfile[@]/#pkgrel=*([^ ])/pkgrel=1}")
if ! printf '%s\n' "${buildfile[@]}" > "$BUILDFILE"; then
error "$(gettext "Failed to update %s from %s to %s")" \
"pkgver" "$pkgver" "$newpkgver"
exit $E_PKGBUILD_ERROR
fi
/usr/bin/sed --follow-symlinks -i "s:^pkgrel=[^ ]*:pkgrel=1:" "$BUILDFILE"
source_safe "$BUILDFILE"
local fullver=$(get_full_version)
msg "$(gettext "Updated version: %s")" "$pkgbase $fullver"
......@@ -219,20 +220,27 @@ update_pkgver() {
# Print 'source not found' error message and exit makepkg
missing_source_file() {
error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_MISSING_FILE
}
run_pacman() {
local cmd
local cmd cmdescape
if [[ $1 = -@(T|Q)*([[:alpha:]]) ]]; then
cmd=("$PACMAN_PATH" "$@")
else
cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
if type -p sudo >/dev/null; then
cmdescape="$(printf '%q ' "${cmd[@]}")"
if (( ${#PACMAN_AUTH[@]} )); then
if in_array '%c' "${PACMAN_AUTH[@]}"; then
cmd=("${PACMAN_AUTH[@]/\%c/$cmdescape}")
else
cmd=("${PACMAN_AUTH[@]}" "${cmd[@]}")
fi
elif type -p sudo >/dev/null; then
cmd=(sudo "${cmd[@]}")
else
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
cmd=(su root -c "$cmdescape")
fi
local lockfile="$(pacman-conf DBPath)/db.lck"
while [[ -f $lockfile ]]; do
......@@ -354,7 +362,7 @@ error_function() {
# first exit all subshells, then print the error
if (( ! BASH_SUBSHELL )); then
error "$(gettext "A failure occurred in %s().")" "$1"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
fi
exit $E_USER_FUNCTION_FAILED
}
......@@ -474,7 +482,7 @@ find_libdepends() {
local libdeps filename soarch sofile soname soversion
declare -A libdeps
while read -r filename; do
while IFS= read -rd '' filename; do
# get architecture of the file; if soarch is empty it's not an ELF binary
soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
[[ -n "$soarch" ]] || continue
......@@ -495,7 +503,7 @@ find_libdepends() {
libdeps[$soname]="${soversion}-${soarch}"
fi
done
done < <(find "$pkgdir" -type f -perm -u+x)
done < <(find "$pkgdir" -type f -perm -u+x -print0)
local libdepends v
for d in "${depends[@]}"; do
......@@ -521,12 +529,13 @@ find_libdepends() {
find_libprovides() {
local p libprovides missing
local p versioned_provides libprovides missing
for p in "${provides[@]}"; do
missing=0
versioned_provides=()
case "$p" in
*.so)
mapfile -t filename < <(find "$pkgdir" -type f -name $p\*)
mapfile -t filename < <(find "$pkgdir" -type f -name $p\* | LC_ALL=C sort)
if [[ $filename ]]; then
# packages may provide multiple versions of the same library
for fn in "${filename[@]}"; do
......@@ -536,7 +545,6 @@ find_libprovides() {
local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
if [[ -z "$sofile" ]]; then
warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
libprovides+=("$p")
continue
fi
......@@ -546,25 +554,25 @@ find_libprovides() {
# extract the library major version
local soversion="${sofile##*\.so\.}"
libprovides+=("${p}=${soversion}-${soarch}")
versioned_provides+=("${p}=${soversion}-${soarch}")
else
warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
libprovides+=("$p")
fi
done
else
libprovides+=("$p")
missing=1
fi
;;
*)
libprovides+=("$p")
;;
esac
if (( missing )); then
warning "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$p"
fi
if (( ${#versioned_provides[@]} > 0 )); then
libprovides+=("${versioned_provides[@]}")
else
libprovides+=("$p")
fi
done
(( ${#libprovides[@]} )) && printf '%s\n' "${libprovides[@]}"
......@@ -584,7 +592,7 @@ write_kv_pair() {
}
write_pkginfo() {
local size="$(find . -type f -exec cat {} + 2>/dev/null | wc -c)"
local size=$(dirsize)
merge_arch_attrs
......@@ -625,7 +633,7 @@ write_pkginfo() {
}
write_buildinfo() {
write_kv_pair "format" "1"
write_kv_pair "format" "2"
write_kv_pair "pkgname" "$pkgname"
write_kv_pair "pkgbase" "$pkgbase"
......@@ -642,6 +650,9 @@ write_buildinfo() {
write_kv_pair "packager" "${PACKAGER}"
write_kv_pair "builddate" "${SOURCE_DATE_EPOCH}"
write_kv_pair "builddir" "${BUILDDIR}"
write_kv_pair "startdir" "${startdir}"
write_kv_pair "buildtool" "${BUILDTOOL:-makepkg}"
write_kv_pair "buildtoolver" "${BUILDTOOLVER:-$makepkg_version}"
write_kv_pair "buildenv" "${BUILDENV[@]}"
write_kv_pair "options" "${OPTIONS[@]}"
......@@ -672,7 +683,7 @@ create_package() {
if [[ ! -d $pkgdir ]]; then
error "$(gettext "Missing %s directory.")" "\$pkgdir/"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_MISSING_PKGDIR
fi
......@@ -782,13 +793,16 @@ create_srcpackage() {
fi
done
local i
# set pkgname the same way we do for running package(), this way we get
# the right value in extract_function_variable
local pkgname_backup=(${pkgname[@]})
local i pkgname
for i in 'changelog' 'install'; do
local file files
[[ ${!i} ]] && files+=("${!i}")
for name in "${pkgname[@]}"; do
if extract_function_variable "package_$name" "$i" 0 file; then
for pkgname in "${pkgname_backup[@]}"; do
if extract_function_variable "package_$pkgname" "$i" 0 file; then
files+=("$file")
fi
done
......@@ -800,6 +814,7 @@ create_srcpackage() {
fi
done
done
pkgname=(${pkgname_backup[@]})
local fullver=$(get_full_version)
local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
......@@ -856,22 +871,22 @@ install_package() {
}
check_build_status() {
# if (( ! SPLITPKG )); then
# fullver=$(get_full_version)
# pkgarch=$(get_pkg_arch)
# if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \
# && ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then
# if (( INSTALL )); then
# warning "$(gettext "A package has already been built, installing existing package...")"
# install_package
# exit $?
# else
# error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f"
# exit $E_ALREADY_BUILT
# fi
# fi
# else
if (( SPLITPKG )); then
local fullver pkgarch allpkgbuilt somepkgbuilt
if (( ! SPLITPKG )); then
fullver=$(get_full_version)
pkgarch=$(get_pkg_arch)
if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \
&& ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then
if (( INSTALL )); then
warning "$(gettext "A package has already been built, installing existing package...")"
install_package
exit $?
else
error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f"
exit $E_ALREADY_BUILT
fi
fi
else
allpkgbuilt=1
somepkgbuilt=0
for pkg in ${pkgname[@]}; do
......@@ -899,7 +914,6 @@ check_build_status() {
exit $E_ALREADY_BUILT
fi
fi
unset allpkgbuilt somepkgbuilt
fi
}
......@@ -1000,7 +1014,7 @@ usage() {
version() {
printf "makepkg (pacman) %s\n" "$makepkg_version"
printf -- "Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>.\n"
printf -- "Copyright (c) 2006-2021 Pacman Development Team <pacman-dev@archlinux.org>.\n"
printf -- "Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n"
printf '\n'
printf -- "$(gettext "\
......@@ -1142,23 +1156,23 @@ lint_config || exit $E_CONFIG_ERROR
# check that all settings directories are user-writable
if ! ensure_writable_dir "BUILDDIR" "$BUILDDIR"; then
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
if (( ! (NOBUILD || GENINTEG) )) && ! ensure_writable_dir "PKGDEST" "$PKGDEST"; then
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
if ! ensure_writable_dir "SRCDEST" "$SRCDEST" ; then
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
if (( SOURCEONLY )); then
if ! ensure_writable_dir "SRCPKGDEST" "$SRCPKGDEST"; then
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
......@@ -1168,7 +1182,7 @@ if (( SOURCEONLY )); then
fi
if (( LOGGING )) && ! ensure_writable_dir "LOGDEST" "$LOGDEST"; then
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
......@@ -1190,8 +1204,8 @@ unset "${known_hash_algos[@]/%/sums}"
unset -f pkgver prepare build check package "${!package_@}"
unset "${!makedepends_@}" "${!depends_@}" "${!source_@}" "${!checkdepends_@}"
unset "${!optdepends_@}" "${!conflicts_@}" "${!provides_@}" "${!replaces_@}"
unset "${!md5sums_@}" "${!sha1sums_@}" "${!sha224sums_@}" "${!sha256sums_@}"
unset "${!sha384sums_@}" "${!sha512sums_@}" "${!b2sums_@}"
unset "${!cksums_@}" "${!md5sums_@}" "${!sha1sums_@}" "${!sha224sums_@}"
unset "${!sha256sums_@}" "${!sha384sums_@}" "${!sha512sums_@}" "${!b2sums_@}"
BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
if [[ ! -f $BUILDFILE ]]; then
......@@ -1281,7 +1295,7 @@ fi
# check if gpg signature is to be created and if signing key is valid
if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; then
SIGNPKG='y'
if ! gpg --list-key ${GPGKEY} &>/dev/null; then
if ! gpg --list-secret-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
if [[ ! -z $GPGKEY ]]; then
error "$(gettext "The key %s does not exist in your keyring.")" "${GPGKEY}"
else
......@@ -1321,7 +1335,7 @@ if (( INFAKEROOT )); then
else
run_split_packaging
fi
create_debug_package
msg "$(gettext "Leaving %s environment.")" "fakeroot"
......@@ -1355,7 +1369,7 @@ if (( SOURCEONLY )); then
if [[ $SIGNPKG = 'y' ]]; then
msg "$(gettext "Signing package...")"
create_signature "$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
create_signature "$SRCPKGDEST/${pkgbase}-$(get_full_version)${SRCEXT}"
fi
msg "$(gettext "Source package created: %s")" "$pkgbase ($(date +%c))"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment