Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding generate_source_tarball.sh and vendor tarball to docker-buildx #12113

Draft
wants to merge 4 commits into
base: 3.0-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
1 change: 1 addition & 0 deletions SPECS/docker-buildx/docker-buildx.signatures.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Signatures": {
"docker-buildx-0.14.0-govendor-v1.tar.gz": "49d195b123d9857dc0530cbd797d290e3106e11a158d92fbb30720875626b42d",
"docker-buildx-0.14.0.tar.gz": "9ed27d47b728288500ba2535366792d9b006354e02178688360919663f92b63e"
}
}
8 changes: 7 additions & 1 deletion SPECS/docker-buildx/docker-buildx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ Summary: A Docker CLI plugin for extended build capabilities with BuildKi
Name: docker-buildx
# update "commit_hash" above when upgrading version
Version: 0.14.0
Release: 2%{?dist}
Release: 3%{?dist}
License: ASL 2.0
Group: Tools/Container
Vendor: Microsoft Corporation
Distribution: Azure Linux
URL: https://www.github.com/docker/buildx
Source0: https://github.com/docker/buildx/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: %{name}-%{version}-govendor-v1.tar.gz
Patch0: CVE-2024-45337.patch

BuildRequires: bash
Expand All @@ -28,6 +29,8 @@ A Docker CLI plugin for extended build capabilities with BuildKit

%prep
%autosetup -p1 -n buildx-%{version}
rm -rf vendor
tar -xf %{SOURCE1}

%build
export CGO_ENABLED=0
Expand All @@ -45,6 +48,9 @@ install -m 755 buildx "%{buildroot}%{_libexecdir}/docker/cli-plugins/docker-buil
%{_libexecdir}/docker/cli-plugins/docker-buildx

%changelog
* Mon Jan 27 2025 Osama Esmail <[email protected]> - 0.14.0-3
- Added "generate_source_tarball.sh" and vendor tarball

* Fri Dec 20 2024 Aurelien Bombo <[email protected]> - 0.14.0-2
- Add patch for CVE-2024-45337

Expand Down
118 changes: 118 additions & 0 deletions SPECS/docker-buildx/generate_source_tarball.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Quit on failure
set -e

PKG_VERSION=""
SRC_TARBALL=""
VENDOR_VERSION="1"
OUT_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# parameters:
#
# --srcTarball : src tarball file
# this file contains the 'initial' source code of the component
# and should be replaced with the new/modified src code
# --outFolder : folder where to copy the new tarball(s)
# --pkgVersion : package version
# --vendorVersion : vendor version
#
PARAMS=""
while (( "$#" )); do
case "$1" in
--srcTarball)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
SRC_TARBALL=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--outFolder)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
OUT_FOLDER=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--pkgVersion)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
PKG_VERSION=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--vendorVersion)
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
VENDOR_VERSION=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done

echo "--srcTarball -> $SRC_TARBALL"
echo "--outFolder -> $OUT_FOLDER"
echo "--pkgVersion -> $PKG_VERSION"
echo "--vendorVersion -> $VENDOR_VERSION"

if [ -z "$PKG_VERSION" ]; then
echo "--pkgVersion parameter cannot be empty"
exit 1
fi

echo "-- create temp folder"
tmpdir=$(mktemp -d)
function cleanup {
echo "+++ cleanup -> remove $tmpdir"
rm -rf $tmpdir
}
trap cleanup EXIT

TARBALL_FOLDER="$tmpdir/tarballFolder"
mkdir -p $TARBALL_FOLDER
cp $SRC_TARBALL $tmpdir

pushd $tmpdir > /dev/null

PKG_NAME="docker-buildx"
NAME_VER="$PKG_NAME-$PKG_VERSION"
VENDOR_TARBALL="$OUT_FOLDER/$NAME_VER-govendor-v$VENDOR_VERSION.tar.gz"

echo "Unpacking source tarball..."
tar -xf $SRC_TARBALL

echo "Vendor go modules..."
cd "buildx-$PKG_VERSION"
go mod tidy
go mod vendor

echo ""
echo "========================="
echo "Tar vendored tarball"
tar --sort=name \
--mtime="2021-04-26 00:00Z" \
--owner=0 --group=0 --numeric-owner \
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
-czf "$VENDOR_TARBALL" vendor

popd > /dev/null
echo "$PKG_NAME vendored modules are available at $VENDOR_TARBALL"