Skip to content

Commit

Permalink
Fix podman_tooling script
Browse files Browse the repository at this point in the history
This script is needed by both podman and buildah CI.  However a bug in
the line `export GOPATH="${GOPATH:/var/tmp/go}"` was causing it to
silently exit before doing it's job.  Fortunately the downstream build
systems are somewhat tolerant, so the problem wasn't noticed at image
build time.

Simplify the script by requiring it to be called under $SUDO, this
allows moving a bunch of golang variable definitions into the script and
also making it `set -e` so failures are noticed sooner.

Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed May 31, 2022
1 parent 358bdbb commit d5f024b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
7 changes: 1 addition & 6 deletions cache_images/fedora_packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,5 @@ fi
# It was observed in F33, dnf install doesn't always get you the latest/greatest
lilto $SUDO dnf update -y

echo "Configuring Go environment"
export GOPATH=/var/tmp/go
mkdir -p "$GOPATH"
eval $(go env | tee /dev/stderr)
export PATH="$GOPATH/bin:$PATH"
# shellcheck source=./podman_tooling.sh
source $SCRIPT_DIRPATH/podman_tooling.sh
$SUDO bash $SCRIPT_DIRPATH/podman_tooling.sh
34 changes: 21 additions & 13 deletions cache_images/podman_tooling.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@

# This script is sourced from *_packaging.sh script to install common/shared
# This script is executed from *_packaging.sh script to install common/shared
# tooling from the containers/podman repository. It expects
# a go 1.13+ environment has already been setup. The script should
# not be used for any other purpose or from any other context.
# a go 1.16+ environment has already been setup, and should be called
# as root or through sudo. The script should not be used for any other
# purpose or from any other context.

set -e

echo "Configuring Go environment"
export GOPATH="${GOPATH:-/var/tmp/go}"
mkdir -p "$GOPATH"
export GOSRC=${GOPATH}/src/github.com/containers/podman
export GOCACHE="${GOCACHE:-$GOPATH/cache}"
eval $(go env | tee /dev/stderr)
export PATH="$GOPATH/bin:$PATH"

echo "Installing runtime tooling"
export GOPATH="${GOPATH:/var/tmp/go}"
export GOSRC=/var/tmp/go/src/github.com/containers/podman
export GOCACHE="${GOCACHE:-/root/.cache/go-build}"
lilto git clone --quiet https://github.com/containers/podman.git "$GOSRC"

cd "$GOSRC" || die "Podman repo. not cloned to expected directory: '$GOSRC'"
# Calling script already loaded lib.sh
# shellcheck disable=SC2154
lilto $SUDO ./hack/install_catatonit.sh
bigto $SUDO make install.tools
lilto ./hack/install_catatonit.sh
bigto make install.tools

# shellcheck disable=SC2154
if [[ "$OS_RELEASE_ID" == "fedora" ]]; then
msg "Installing swagger binary"
download_url=$(\
curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
jq -r '.assets[] | select(.name | contains("linux_amd64")) | .browser_download_url')
$SUDO curl --fail -s -o /usr/local/bin/swagger -L'#' "$download_url"
$SUDO chmod +x /usr/local/bin/swagger
curl --fail -s -o /usr/local/bin/swagger -L'#' "$download_url"
chmod +x /usr/local/bin/swagger
/usr/local/bin/swagger version

# This is needed for rootless testing
$SUDO make install.modules-load
make install.modules-load
fi

# Make pristine for other runtime usage/expectations also save a bit
# of space in the images.
$SUDO rm -rf "$GOPATH/src" "$GOCACHE"
$SUDO chown -R root.root /var/tmp/go
rm -rf "$GOPATH/src" "$GOCACHE"
chown -R root.root /var/tmp/go
7 changes: 1 addition & 6 deletions cache_images/ubuntu_packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,5 @@ curl -s -L https://golang.org/dl/go1.17.3.linux-amd64.tar.gz | \
# Now linking to upstream golang until ubuntu performance issues are resolved
$SUDO ln -sf /usr/local/go/bin/* /usr/bin/

export GOPATH=/var/tmp/go
mkdir -p "$GOPATH"
eval $(go env | tee /dev/stderr)
export PATH="$GOPATH/bin:$PATH"

# shellcheck source=./podman_tooling.sh
source $SCRIPT_DIRPATH/podman_tooling.sh
$SUDO bash $SCRIPT_DIRPATH/podman_tooling.sh

0 comments on commit d5f024b

Please sign in to comment.