All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Ross Lagerwall <ross.lagerwall@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 1/3] livepatch-build-tools: do not use readlink -m option
Date: Tue, 28 Nov 2023 10:21:50 +0100	[thread overview]
Message-ID: <20231128092152.35039-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20231128092152.35039-1-roger.pau@citrix.com>

Busybox readlink implementation only supports the -f option to follow symlinks,
so adjust the logic in order to keep the same behaviour without using the -m
option.

Singed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 livepatch-build | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/livepatch-build b/livepatch-build
index 91d203bda0eb..305644037ee7 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -336,8 +336,8 @@ while [[ $# -gt 0 ]]; do
             ;;
         --xen-syms)
             shift
-            XENSYMS="$(readlink -m -- "$1")"
-            [ -f "$XENSYMS" ] || die "xen-syms file does not exist"
+            [ -f "$1" ] || die "xen-syms file does not exist"
+            XENSYMS="$(readlink -f -- "$1")"
             shift
             ;;
         --depends)
@@ -366,22 +366,20 @@ while [[ $# -gt 0 ]]; do
 done
 
 [ -z "$srcarg" ] && die "Xen directory not given"
+[ -d "$srcarg" ] || die "Xen directory does not exist"
 [ -z "$patcharg" ] && die "Patchfile not given"
+[ -f "$patcharg" ] || die "Patchfile does not exist"
 [ -z "$configarg" ] && die ".config not given"
+[ -f "$configarg" ] || die ".config does not exist"
 [ -z "$outputarg" ] && die "Output directory not given"
 [ -z "$DEPENDS" ] && die "Build-id dependency not given"
 [ -z "$XEN_DEPENDS" ] && die "Xen Build-id dependency not given"
 
-SRCDIR="$(readlink -m -- "$srcarg")"
+SRCDIR="$(readlink -f -- "$srcarg")"
 # We need an absolute path because we move around, but we need to
 # retain the name of the symlink (= realpath -s)
 PATCHFILE="$(readlink -f "$(dirname "$patcharg")")/$(basename "$patcharg")"
-CONFIGFILE="$(readlink -m -- "$configarg")"
-OUTPUT="$(readlink -m -- "$outputarg")"
-
-[ -d "${SRCDIR}" ] || die "Xen directory does not exist"
-[ -f "${PATCHFILE}" ] || die "Patchfile does not exist"
-[ -f "${CONFIGFILE}" ] || die ".config does not exist"
+CONFIGFILE="$(readlink -f -- "$configarg")"
 
 PATCHNAME=$(make_patch_name "${PATCHFILE}")
 
@@ -390,17 +388,20 @@ echo
 echo "Xen directory: ${SRCDIR}"
 echo "Patch file: ${PATCHFILE}"
 echo ".config file: ${CONFIGFILE}"
-echo "Output directory: ${OUTPUT}"
+echo "Output directory: $outputarg"
 echo "================================================"
 echo
 
 if [ "${SKIP}" != "build" ]; then
-    [ -e "${OUTPUT}" ] && die "Output directory exists"
+    # Make sure output directory doesn't exist, and create it.
+    [ -e "$outputarg" ] && die "Output directory exists"
+    mkdir -p "$outputarg" || die
+    OUTPUT="$(readlink -f -- "$outputarg")"
+
     grep -q 'CONFIG_LIVEPATCH=y' "${CONFIGFILE}" || die "CONFIG_LIVEPATCH must be enabled"
     cd "$SRCDIR" || die
     patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply"
 
-    mkdir -p "${OUTPUT}" || die
     cp -f "${CONFIGFILE}" "${OUTPUT}/.config"
     cp -f "${OUTPUT}/.config" "xen/.config"
 
@@ -453,7 +454,9 @@ if [ "${SKIP}" != "build" ]; then
 fi
 
 if [ "${SKIP}" != "diff" ]; then
-    [ -d "${OUTPUT}" ] || die "Output directory does not exist"
+    cd "${SCRIPTDIR}" || die
+    [ -d "$outputarg" ] || die "Output directory does not exist"
+    OUTPUT="$(readlink -f -- "$outputarg")"
 
     cd "${OUTPUT}" || die
     create_patch

base-commit: e588b7914e7afa3abb64b15a32fc2fdb57ded341
-- 
2.43.0



  reply	other threads:[~2023-11-28  9:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28  9:21 [PATCH v2 0/3] livepatch-build-tools: fixes for non GNU tools and alignment Roger Pau Monne
2023-11-28  9:21 ` Roger Pau Monne [this message]
2023-11-28  9:21 ` [PATCH v2 2/3] livepatch-build-tools: remove usage of gawk Roger Pau Monne
2023-11-28  9:21 ` [PATCH v2 3/3] livepatch-build-tools: account for section alignment when calculating function size Roger Pau Monne
2023-12-06 14:46 ` [PATCH v2 0/3] livepatch-build-tools: fixes for non GNU tools and alignment Ross Lagerwall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231128092152.35039-2-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=ross.lagerwall@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.