Files
MSYS2-packages/pacman/0010-Set-fixed-paths-for-various-tools.patch
2023-03-02 07:16:50 +01:00

164 lines
5.0 KiB
Diff

From 43fb1e0846ebe66de66984f2b4a0457e1a861b5e Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 28 Feb 2023 20:39:11 +0100
Subject: [PATCH 10/N] Set fixed paths for various tools
So that we call the right tools even if mingw variants are in PATH
---
scripts/libmakepkg/meson.build | 1 +
scripts/libmakepkg/utils_fixed_path.sh.in | 34 +++++++++++++++++++++++
scripts/pacman-db-upgrade.sh.in | 10 +++++--
scripts/pacman-key.sh.in | 13 ++++++---
scripts/repo-add.sh.in | 9 ++++--
5 files changed, 58 insertions(+), 9 deletions(-)
create mode 100644 scripts/libmakepkg/utils_fixed_path.sh.in
diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build
index 50eb905..9396923 100644
--- a/scripts/libmakepkg/meson.build
+++ b/scripts/libmakepkg/meson.build
@@ -8,6 +8,7 @@ libmakepkg_modules = [
{ 'name' : 'reproducible', 'has_subdir' : true },
{ 'name' : 'source', 'has_subdir' : true },
{ 'name' : 'srcinfo', },
+ { 'name' : 'utils_fixed_path', },
{ 'name' : 'tidy', 'has_subdir' : true },
{ 'name' : 'util', 'has_subdir' : true },
]
diff --git a/scripts/libmakepkg/utils_fixed_path.sh.in b/scripts/libmakepkg/utils_fixed_path.sh.in
new file mode 100644
index 0000000..e3a06bc
--- /dev/null
+++ b/scripts/libmakepkg/utils_fixed_path.sh.in
@@ -0,0 +1,34 @@
+if [[ -n "$MSYSTEM" ]]; then
+ readonly -a UTILS_NAME=('bsdtar'
+ 'bzip2'
+ 'bzr'
+ 'cat'
+ 'ccache'
+ 'distcc'
+ 'git'
+ 'gpg'
+ 'gzip'
+ 'hg'
+ 'lzip'
+ 'lzop'
+ 'openssl'
+ 'svn'
+ 'tput'
+ 'uncompress'
+ 'xargs'
+ 'xz'
+ 'zstd'
+ )
+
+ for wrapper in ${UTILS_NAME[@]}; do
+ eval "
+ ${wrapper}"'() {
+ local UTILS_PATH="/usr/bin/"
+ if ! type -p ${UTILS_PATH}${FUNCNAME[0]} >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for makepkg.")" "${UTILS_PATH}${FUNCNAME[0]}"
+ exit 1
+ fi
+ ${UTILS_PATH}${FUNCNAME[0]} "$@"
+ }'
+ done
+fi
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index eec54cb..c1cb200 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -78,9 +78,13 @@ resolve_dir() {
# PROGRAM START
# determine whether we have gettext; make it a no-op if we do not
-if ! type gettext &>/dev/null; then
+if ! type -p gettext >/dev/null; then
gettext() {
- echo "$@"
+ printf "%s\n" "$@"
+ }
+else
+ gettext() {
+ /usr/bin/gettext "$@"
}
fi
@@ -137,7 +141,7 @@ lockfile="${dbroot}/db.lck"
# make sure pacman isn't running
if [[ -f $lockfile ]]; then
- die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")"
+ die "$(/bin/gettext "Pacman lock file was found. Cannot run while pacman is running.")"
fi
# do not let pacman run while we do this
touch "$lockfile"
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index d5144f9..c667006 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -30,6 +30,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
# Import libmakepkg
source "$LIBRARY"/util/message.sh
source "$LIBRARY"/util/parseopts.sh
+source "$LIBRARY"/utils_fixed_path.sh
# Options
ADD=0
@@ -433,7 +434,7 @@ import_trustdb() {
local ret=0
for importdir in "$@"; do
if [[ -f "${importdir}/trustdb.gpg" ]]; then
- gpg --homedir "${importdir}" --export-ownertrust | \
+ /bin/gpg --homedir "${importdir}" --export-ownertrust | \
"${GPG_PACMAN[@]}" --import-ownertrust -
if (( PIPESTATUS )); then
error "$(gettext "%s could not be imported.")" "${importdir}/trustdb.gpg"
@@ -605,10 +606,14 @@ updatedb() {
fi
}
-# PROGRAM START
-if ! type gettext &>/dev/null; then
+# determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
gettext() {
- echo "$@"
+ printf "%s\n" "$@"
+ }
+else
+ gettext() {
+ /usr/bin/gettext "$@"
}
fi
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 2f69488..a231699 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -46,6 +46,7 @@ PREVENT_DOWNGRADE=0
# Import libmakepkg
source "$LIBRARY"/util/compress.sh
source "$LIBRARY"/util/message.sh
+source "$LIBRARY"/utils_fixed_path.sh
# ensure we have a sane umask set
umask 0022
@@ -562,9 +563,13 @@ clean_up() {
# PROGRAM START
# determine whether we have gettext; make it a no-op if we do not
-if ! type gettext &>/dev/null; then
+if ! type -p gettext &>/dev/null; then
gettext() {
- echo "$@"
+ printf "%s\n" "$@"
+ }
+else
+ gettext() {
+ /usr/bin/gettext "$@"
}
fi