Skip to content

Commit

Permalink
add generate tarballs script for jx
Browse files Browse the repository at this point in the history
  • Loading branch information
mbykhovtsev-ms committed Jan 30, 2025
1 parent 32428ae commit 3ccb887
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 21 deletions.
107 changes: 107 additions & 0 deletions SPECS/jx/generate_source_tarball.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Quit on failure
set -e

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

# --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

pushd $tmpdir > /dev/null

NAME="jx"
NAME_VER="$NAME-$PKG_VERSION"
VENDOR_TARBALL="$OUT_FOLDER/$NAME_VER-govendor-v$VENDOR_VERSION.tar.gz"

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

cd "$NAME_VER"
echo "Get vendored modules"
go mod vendor

echo "Tar vendored modules"
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 \
-cf "$VENDOR_TARBALL" vendor

popd > /dev/null
echo "$NAME vendored modules are available at $VENDOR_TARBALL"
2 changes: 1 addition & 1 deletion SPECS/jx/jx.signatures.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Signatures": {
"jx-3.10.116-vendor.tar.gz": "9e0cc830222cc289a928b684201c6cd3793f60637a4e47a7cbde00076792c94d",
"jx-3.10.116-govendor-v1.tar.gz": "9e0cc830222cc289a928b684201c6cd3793f60637a4e47a7cbde00076792c94d",
"jx-3.10.116.tar.gz": "55b14b4f4189f91f481387f8ad9617c37deb859d824c246e817040b740de7d76"
}
}
25 changes: 5 additions & 20 deletions SPECS/jx/jx.spec
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
Summary: Command line tool for working with Jenkins X.
Name: jx
Version: 3.10.116
Release: 2%{?dist}
Release: 3%{?dist}
License: Apache-2.0
Vendor: Microsoft Corporation
Distribution: Azure Linux
Group: Applications/Tools
URL: https://github.com/jenkins-x/jx
Source0: https://github.com/jenkins-x/jx/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Below is a manually created tarball, no download link.
# We're using pre-populated Go modules from this tarball, since network is disabled during build time.
# How to re-build this file:
# 1. wget https://github.com/jenkins-x/jx/archive/v%{version}.tar.gz -O %%{name}-%%{version}.tar.gz
# 2. tar -xf %%{name}-%%{version}.tar.gz
# 3. cd %%{name}-%%{version}
# 4. go mod vendor
# 5. 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 \
# -cf %%{name}-%%{version}-vendor.tar.gz vendor
#
# NOTES:
# - You require GNU tar version 1.28+.
# - The additional options enable generation of a tarball with the same hash every time regardless of the environment.
# See: https://reproducible-builds.org/docs/archives/
# - For the value of "--mtime" use the date "2021-04-26 00:00Z" to simplify future updates.
Source1: %{name}-%{version}-vendor.tar.gz
Source1: %{name}-%{version}-govendor-v1.tar.gz
Patch0: CVE-2023-45288.patch

BuildRequires: golang >= 1.17.1
Expand Down Expand Up @@ -63,6 +45,9 @@ install -p -m 755 -t %{buildroot}%{_bindir} ./build/jx
%{_bindir}/jx

%changelog
* Thu Jan 30 2025 Mykhailo Bykhovtsev <[email protected]> - 3.10.116-3
- Change vendor naming convention to match other go packages.

* Thu Aug 22 2024 Sumedh Sharma <[email protected]> - 3.10.116-2
- Add patch to resolve CVE-2023-45288

Expand Down

0 comments on commit 3ccb887

Please sign in to comment.