github.com/containers/podman/v4@v4.9.4/.packit.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # This script handles any custom processing of the spec file using the `fix-spec-file`
     4  # action in .packit.yaml. These steps only work on copr builds, not on official
     5  # Fedora builds.
     6  
     7  set -eox pipefail
     8  
     9  PACKAGE=podman
    10  
    11  # Set path to rpm spec file
    12  SPEC_FILE=rpm/$PACKAGE.spec
    13  
    14  # Get short sha
    15  SHORT_SHA=$(git rev-parse --short HEAD)
    16  
    17  # Get Version from HEAD
    18  VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)
    19  
    20  # RPM Version can't take "-"
    21  RPM_VERSION=$(echo $VERSION | sed -e 's/-/~/')
    22  
    23  # Generate source tarball from HEAD
    24  git-archive-all -C $(git rev-parse --show-toplevel) --prefix=$PACKAGE-$VERSION/ rpm/$PACKAGE-$VERSION.tar.gz
    25  
    26  # RPM Spec modifications
    27  
    28  # Use the Version from HEAD in rpm spec
    29  sed -i "s/^Version:.*/Version: $RPM_VERSION/" $SPEC_FILE
    30  
    31  # Use Packit's supplied variable in the Release field in rpm spec.
    32  sed -i "s/^Release:.*/Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/" $SPEC_FILE
    33  
    34  # Ensure last part of the release string is the git shortcommit without a
    35  # prepended "g"
    36  sed -i "/^Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/ s/\(.*\)g/\1/" $SPEC_FILE
    37  
    38  # Use above generated tarball as Source in rpm spec
    39  sed -i "s/^Source0:.*.tar.gz/Source0: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE
    40  
    41  # Update setup macro to use the correct build dir
    42  sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
    43  
    44  # Update relevant sed entries in spec file with the actual VERSION and SHORT_SHA
    45  # This allows podman --version to also show the SHORT_SHA along with the
    46  # VERSION
    47  sed -i "s/##VERSION##/$VERSION/" $SPEC_FILE
    48  sed -i "s/##SHORT_SHA##/$SHORT_SHA/" $SPEC_FILE