From 83407c4bc6acb35cd290bb9723fb8aa288ba3c5d Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Fri, 9 Jun 2023 08:46:13 +0300 Subject: [PATCH 1/2] handle realpath in makerootfs.sh sanely Signed-off-by: Avi Deitcher --- tools/makerootfs.sh | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/tools/makerootfs.sh b/tools/makerootfs.sh index 93063c719d..796c8f730e 100755 --- a/tools/makerootfs.sh +++ b/tools/makerootfs.sh @@ -56,6 +56,33 @@ do_imagefromtar() { cat "${tarfile}" | docker run -i --rm -v /dev:/dev --privileged -v "$IMAGE:/rootfs.img" "${MKROOTFS_TAG}" } +abspath() { + local target + local dir + local filename + local absolute_dir + + target="$1" + if [ -z "$target" ]; then + echo "Error: Unable to find file '$target'" >&2 + return 1 + fi + # we have two problems here: + # First, we want to realpath a file that may not exist yet. + # on some OSes, it is fine; on others, it returns an error. + # a prerequisite is that the directory exists, so we can realpath that, + # and just append the filename after. + # Second, we want to use realpath, but it is not available on all OSes. + dir=$(dirname "$target") + filename=$(basename "$target") + if [ ! -d "$dir" ]; then + echo "Error: Unable to find directory '$dir'" >&2 + return 1 + fi + absolute_dir=$(cd "$dir"; pwd -P) + echo "${absolute_dir}/${filename}" +} + bail() { echo "$@" >&2 help @@ -89,10 +116,10 @@ while getopts "t:i:a:f:y:d:h" o do case $o in t) - tarfile=$(realpath "$OPTARG") + tarfile=$(abspath "$OPTARG") ;; i) - imgfile=$(realpath "$OPTARG") + imgfile=$(abspath "$OPTARG") ;; a) arch="$OPTARG" @@ -101,10 +128,10 @@ do format="$OPTARG" ;; y) - ymlfile=$(realpath "$OPTARG") + ymlfile=$(abspath "$OPTARG") ;; d) - execdir=$(realpath "$OPTARG") + execdir=$(abspath "$OPTARG") ;; h) help From 524f452100ecd2120f5520fffac385cf166fe8e5 Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Sun, 11 Jun 2023 11:25:33 +0300 Subject: [PATCH 2/2] Revert "Add coreutils package as prereq for MAC" This reverts commit bbce62550ec90a366c9828e6a5cc74ba71b1d7a9. Signed-off-by: Avi Deitcher --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 53cf0cd268..6bf8e82ec7 100644 --- a/README.md +++ b/README.md @@ -113,18 +113,18 @@ Make sure that Docker is up and running on your system. On MacOS just start a do docker version ``` -#### Get system dependencies (git, make, qemu, jq, gnu-sed, coreutils) +#### Get system dependencies (git, make, qemu, jq, gnu-sed) ##### On OSX (using [Brew](https://brew.sh/)) ```sh -$ brew install git make jq qemu gnu-sed coreutils +$ brew install git make jq qemu gnu-sed ``` > **_NOTE:_** (M1 Macs) `qemu` may also require `python3 nettle ninja` to install properly, that is: > > ```sh -> $ brew install git make jq python3 nettle ninja qemu gnu-sed coreutils +> $ brew install git make jq python3 nettle ninja qemu gnu-sed > ``` ##### On Ubuntu Linux