generated from demus/basic-rpm-template
Split repos into source and rpm build
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
name: Build and provide rpm of demus-packaging
|
|
||||||
run-name: Build demus-packaging from ${{ gitea.repository }} on COPR
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
fedoraversion:
|
|
||||||
type: choice
|
|
||||||
description: "Choose a fedora release"
|
|
||||||
required: true
|
|
||||||
options: [ f43, f44, rawhide ]
|
|
||||||
coprproject:
|
|
||||||
type: choice
|
|
||||||
description: "Which repo"
|
|
||||||
required: true
|
|
||||||
options: [ packages, packages-test ]
|
|
||||||
jobs:
|
|
||||||
coprbuild:
|
|
||||||
name: "Start build on COPR"
|
|
||||||
runs-on: ${{ inputs.fedoraversion }}-minimal-copr
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: https://git.demus.dk/actions/git-clone@main
|
|
||||||
- name: Build src.rpm and send to COPR
|
|
||||||
uses: https://git.demus.dk/actions/copr-build@main
|
|
||||||
with:
|
|
||||||
copr_config: ${{ secrets.COPR_API_CONFIG }}
|
|
||||||
copr_project: ${{ inputs.coprproject }}
|
|
||||||
fedora_release: ${{ inputs.fedoraversion }}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
name: Build and provide rpm of demus-packaging
|
|
||||||
run-name: Build demus-packaging from ${{ gitea.repository }} on COPR
|
|
||||||
on: [release]
|
|
||||||
jobs:
|
|
||||||
coprbuild:
|
|
||||||
name: "Start build on COPR"
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
fedoraversion: [ f43, f44, rawhide ]
|
|
||||||
runs-on: ${{ matrix.fedoraversion }}-minimal-copr
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: https://git.demus.dk/actions/git-clone@main
|
|
||||||
- name: Build src.rpm and send to COPR
|
|
||||||
uses: https://git.demus.dk/actions/copr-build@main
|
|
||||||
with:
|
|
||||||
copr_config: ${{ secrets.COPR_API_CONFIG }}
|
|
||||||
copr_project: packages
|
|
||||||
fedora_release: ${{ matrix.fedoraversion }}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
name: Build and provide rpm of demus-packaging-utils
|
|
||||||
run-name: Rpmbuild demus-packaging-utils at ${{ gitea.repository }}
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
fedoraversion:
|
|
||||||
type: choice
|
|
||||||
description: "Choose a fedora version"
|
|
||||||
required: true
|
|
||||||
options: [ f44, rawhide ]
|
|
||||||
jobs:
|
|
||||||
rpmbuild:
|
|
||||||
name: Build and deploy an rpm to the demus.dk repo
|
|
||||||
runs-on: ${{ inputs.fedoraversion }}-minimal-rpmbuild
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: https://git.demus.dk/actions/git-clone@main
|
|
||||||
- name: Build the rpms
|
|
||||||
uses: https://git.demus.dk/actions/rpmbuild@main
|
|
||||||
- name: Deploy to packages
|
|
||||||
uses: https://git.demus.dk/actions/rpm-deploy@main
|
|
||||||
with:
|
|
||||||
pat: ${{ secrets.RPM_REPO_WRITE }}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
name: Build and provide rpm of demus-packaging-utils
|
|
||||||
run-name: Rpmbuild demus-packaging-utils by ${{ github.actor }}
|
|
||||||
on: [ release ]
|
|
||||||
jobs:
|
|
||||||
rpmbuild:
|
|
||||||
name: Build and deploy an rpm to the demus.dk repo
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
fedoraversion: [ f44, rawhide ]
|
|
||||||
runs-on: ${{ matrix.fedoraversion }}-minimal-rpmbuild
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: https://git.demus.dk/actions/git-clone@main
|
|
||||||
- name: Build the rpms
|
|
||||||
uses: https://git.demus.dk/actions/rpmbuild@main
|
|
||||||
- name: Deploy to packages
|
|
||||||
uses: https://git.demus.dk/actions/rpm-deploy@main
|
|
||||||
with:
|
|
||||||
pat: ${{ secrets.RPM_REPO_WRITE }}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
# demus-packaging-utils
|
# Packaging tooling
|
||||||
|
|
||||||
Aliases, scripts and rpm macros to assist in rpm packaging workflows
|
Aliases, scripts and rpm macros to assist in rpm packaging workflows
|
||||||
|
|
||||||
* regenerate-from-spec: Regenerate tool-generated sources referred to in a spec file
|
* spec-update-artifacts: Regenerate tool-generated sources referred to in a spec file
|
||||||
* go-vendor-update: An alias that replicates the parameters used by go2rpm to generate the vendor archive and configuration. It is used in the above regenerate script.
|
|
||||||
* verify_source_checksum rpm macro: Validate that the checksums in a sources file included in a spec matches the unpacked files.
|
* verify_source_checksum rpm macro: Validate that the checksums in a sources file included in a spec matches the unpacked files.
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
%global major 1
|
|
||||||
%global minor 0
|
|
||||||
%global release 5
|
|
||||||
|
|
||||||
Name: demus-packaging
|
|
||||||
Version: %{major}.%{minor}.%{release}
|
|
||||||
Release: %autorelease
|
|
||||||
Summary: Macros and scripts to assist in rpm packaging workflows
|
|
||||||
URL: https://git.demus.dk/demus/demus-packaging
|
|
||||||
License: GPL-3.0-or-later
|
|
||||||
|
|
||||||
Source: go2rpm-vendor-update.sh
|
|
||||||
Source: regenerate-from-spec.sh
|
|
||||||
Source: macros.demus-packaging
|
|
||||||
Source: LICENSE
|
|
||||||
Source: README.md
|
|
||||||
|
|
||||||
Requires: bash go-vendor-tools+all rpmdevtools askalono-cli
|
|
||||||
Obsoletes: demus-packaging-utils < 1.0.0
|
|
||||||
Provides: demus-packaging-utils = %{version}
|
|
||||||
|
|
||||||
BuildArch: noarch
|
|
||||||
|
|
||||||
%description
|
|
||||||
* regenerate-from-spec: Regenerate tool-generated sources
|
|
||||||
referred to in a spec file
|
|
||||||
* go-vendor-update: An script that replicates the parameters
|
|
||||||
used by go2rpm to generate the vendor archive, license
|
|
||||||
expression and configuration. It is used in the above
|
|
||||||
regenerate script.
|
|
||||||
* verify_source_checksum rpm macro: Validate that the
|
|
||||||
checksums in a sources file included in a spec matches the
|
|
||||||
unpacked files.
|
|
||||||
* stripped_basename macro: Adds the extension stripping
|
|
||||||
positional parameter to %stripped_basename
|
|
||||||
* binshellname macro: Produce the stripped name of a .sh script
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%if %{exists:%{S:2}}
|
|
||||||
%{load:%{S:2}}
|
|
||||||
%endif
|
|
||||||
%?verify_source_checksum
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
%install
|
|
||||||
%{__install} -m 0755 -d %{buildroot}%{_bindir}
|
|
||||||
%{__install} -m 0755 -d %{buildroot}%{_rpmmacrodir}
|
|
||||||
|
|
||||||
%{__install} -p -m 755 %{S:0} %{buildroot}%{_bindir}/%{binshellname:%{S:0}}
|
|
||||||
%{__install} -p -m 755 %{S:1} %{buildroot}%{_bindir}/%{binshellname:%{S:1}}
|
|
||||||
%{__install} -p -m 644 %{S:2} %{buildroot}%{_rpmmacrodir}/
|
|
||||||
%{__install} -p -m 644 %{S:3} %{S:4} %{_builddir}
|
|
||||||
|
|
||||||
%files
|
|
||||||
%doc README.md
|
|
||||||
%license LICENSE
|
|
||||||
%{_bindir}//%{binshellname:%{S:0}}
|
|
||||||
%{_bindir}//%{binshellname:%{S:1}}
|
|
||||||
%{_rpmmacrodir}/*
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
%autochangelog
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Update go vendor archive and config using the options go2rpm uses
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "Usage: $0 [OPTION]... <SPEC_FILE>"
|
|
||||||
echo "Update go vendor archive and config for the <SPEC_FILE> using the options go2rpm."
|
|
||||||
echo
|
|
||||||
echo "Options:"
|
|
||||||
echo " -u Ignore unlicensed mods"
|
|
||||||
echo " -h Print this message and exit"
|
|
||||||
exit ${1:0}
|
|
||||||
}
|
|
||||||
|
|
||||||
while getopts "uh" flag; do
|
|
||||||
case "$flag" in
|
|
||||||
u) IGNORE_UNLICENSED_ARG=" --ignore-unlicensed-mods";;
|
|
||||||
h) usage;;
|
|
||||||
*) echo "Option $flag is unrecognized"; usage 1;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
SPEC_FILE="${@:$OPTIND:1}"
|
|
||||||
|
|
||||||
if [ "$SPEC_FILE" == "" ] || ! [[ "$SPEC_FILE" =~ .*.\.spec$ ]] || [ ! -f "$SPEC_FILE" ]; then
|
|
||||||
echo "Required spec parameter missing or not a readable file ending in .spec"
|
|
||||||
usage 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
go_vendor_archive create --config go-vendor-tools.toml --write-config "$SPEC_FILE"
|
|
||||||
go_vendor_license --config go-vendor-tools.toml --path "$SPEC_FILE" report --write-config --prompt --autofill auto --update-spec$IGNORE_UNLICENSED_ARG
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Update various generated artifacts in rpm packages.
|
|
||||||
# This should be run in the directory containing the spec file.
|
|
||||||
# * Go vendor archive and config
|
|
||||||
# * COPR source file
|
|
||||||
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "Usage: $0 [OPTION]... <SPEC_FILE>"
|
|
||||||
echo "Update generated artifacts belonging to the <SPEC_FILE>."
|
|
||||||
echo
|
|
||||||
echo "Options:"
|
|
||||||
echo " -u Ignore unlicensed mods"
|
|
||||||
echo " -h Print this message and exit"
|
|
||||||
exit ${1:0}
|
|
||||||
}
|
|
||||||
|
|
||||||
while getopts ":uh" flag; do
|
|
||||||
case "$flag" in
|
|
||||||
u) IGNORE_UNLICENSED_ARG="-u ";;
|
|
||||||
h) usage;;
|
|
||||||
*) echo "Option $flag is unrecognized"; usage 1;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
SPEC_FILE="${@:$OPTIND:1}"
|
|
||||||
|
|
||||||
if [ "$SPEC_FILE" == "" ] || ! [[ "$SPEC_FILE" =~ .*.\.spec$ ]] || [ ! -f "$SPEC_FILE" ]; then
|
|
||||||
echo "Required spec parameter missing or not a readable file ending in .spec"
|
|
||||||
echo
|
|
||||||
usage 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure remote sources are downloaded
|
|
||||||
spectool -g "$SPEC_FILE"
|
|
||||||
|
|
||||||
# go2rpm creates a go-vendor-tools.toml file when using the vendor profile
|
|
||||||
if grep -q go-vendor-tools.toml "$SPEC_FILE"; then
|
|
||||||
echo Updating go vendor archive
|
|
||||||
go2rpm-vendor-update "$IGNORE_UNLICENSED_ARG""$SPEC_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update the sources checksums
|
|
||||||
# We assume all files are lowercase except README and LICENSE files
|
|
||||||
# The spec file itself is excluded
|
|
||||||
echo Calculating checksums
|
|
||||||
cksum -a sha512 !(sources|*.spec|RPMS|SRPMS|BUILD) > sources
|
|
||||||
echo Done
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
SHA512 (go2rpm-vendor-update.sh) = 4613c52afe45075cf696247fa641a6a9849ff3a2b0b821317ec21e7fe26c7974dddf610f775d664869d39844e0dbab198073661817a9941a36db12a9091a936d
|
|
||||||
SHA512 (LICENSE) = ccb0f3b838dff6254510f19c2bd6f5c48e38b8c40a5bf93d38482f4fb31015823741d3f160b6836ec99bd8f4e6c5fa9a5c9196ecdd7775b793f3ada50467aabd
|
|
||||||
SHA512 (macros.demus-packaging) = 8c1218425b20da00e6e67c15d1cf09a5913f74f5b2c14a9fda90d28db228ebc87c85bc2e73018638f94a272c71d310a025dc6893f0c69481126602db5e64ff53
|
|
||||||
SHA512 (README.md) = 72a6f0085fea6d2b5736c4fa98f31db8fb42462db6fe65d44de7e99405982cc2330e270f6fb042d598d4136bd2a933e226ae85fb99828e07af6ab2b74a5c89f2
|
|
||||||
SHA512 (regenerate-from-spec.sh) = af71f4a958d3a5e0fd1b79a0b2305a1bdf893bd5a2647bb054a4e02fe6787f704e4699ce62cda3965f99835e417cb0f331a160fe922cbd689cd79693aa7caaf2
|
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# Update various generated artifacts in rpm packages.
|
||||||
|
# This should be run in the directory containing the spec file.
|
||||||
|
# * Go vendor archive and config
|
||||||
|
# * COPR source file
|
||||||
|
set +e
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $(basename "$0") [OPTION]... <SPEC_FILE>"
|
||||||
|
echo "Update generated artifacts belonging to the <SPEC_FILE>."
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -a Update archive"
|
||||||
|
echo " -l Update licenses"
|
||||||
|
echo " -s Update sources file"
|
||||||
|
echo " -u Ignore unlicensed mods"
|
||||||
|
echo " -h Print this message and exit"
|
||||||
|
echo
|
||||||
|
echo "If none of the update operations are specified, all of them will be performed."
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
while getopts ":alsuh" flag; do
|
||||||
|
case "$flag" in
|
||||||
|
a)
|
||||||
|
UPDATE_ARCHIVE=1
|
||||||
|
;;
|
||||||
|
l)
|
||||||
|
UPDATE_LICENSES=1
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
UPDATE_SOURCES=1
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
IGNORE_UNLICENSED_ARG="-u "
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Option -$OPTARG is invalid"
|
||||||
|
echo
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[ "$UPDATE_ARCHIVE" == "" ] && [ "$UPDATE_LICENSES" == "" ] && [ "$UPDATE_SOURCES" == "" ]
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
UPDATE_ARCHIVE=1
|
||||||
|
UPDATE_LICENSES=1
|
||||||
|
UPDATE_SOURCES=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SPEC_FILE="${@:$OPTIND:1}"
|
||||||
|
if [ "$SPEC_FILE" == "" ]; then
|
||||||
|
echo "The required spec parameter is missing"
|
||||||
|
echo
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [[ "$SPEC_FILE" =~ .*.\.spec$ ]]; then
|
||||||
|
echo "The spec file $SPEC_FILE doesn't have a .spec extension"
|
||||||
|
echo
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [ ! -f "$SPEC_FILE" ]; then
|
||||||
|
echo "The spec file $SPEC_FILE is not readable"
|
||||||
|
echo
|
||||||
|
usage
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
download_sources() {
|
||||||
|
if [ ! -v SPEC_FILE ]; then
|
||||||
|
echo ERROR: Variable SPEC_FILE in not set
|
||||||
|
exit 10
|
||||||
|
fi
|
||||||
|
# Ensure remote sources are downloaded
|
||||||
|
spectool -g "$SPEC_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
parse_args "$@"
|
||||||
|
download_sources
|
||||||
|
|
||||||
|
# go2rpm creates a go-vendor-tools.toml file when using the vendor profile
|
||||||
|
if [[ "$UPDATE_ARCHIVE" -eq 1 || "$UPDATE_LICENSES" -eq 1 ]] && ! grep -q go-vendor-tools.toml "$SPEC_FILE"; then
|
||||||
|
echo The spec file is not go-vendor-tools enabled
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update the go vendors archive
|
||||||
|
if [ "$UPDATE_ARCHIVE" -eq 1 ]; then
|
||||||
|
echo Updating go vendor archive
|
||||||
|
if ! go_vendor_archive create --config go-vendor-tools.toml --write-config "$SPEC_FILE"; then
|
||||||
|
echo Archive update failed
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update the go vendors license config if it has changed
|
||||||
|
if [ "$UPDATE_ARCHIVE" -eq 1 ]; then
|
||||||
|
echo Updating go vendor licenses
|
||||||
|
if ! go_vendor_license --config go-vendor-tools.toml --path "$SPEC_FILE" report --write-config --prompt --autofill auto --update-spec$IGNORE_UNLICENSED_ARG; then
|
||||||
|
echo License update failed
|
||||||
|
exit 6
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update the sources checksums
|
||||||
|
if [ "$UPDATE_ARCHIVE" -eq 1 ]; then
|
||||||
|
# The spec file and rpm build directories are excluded
|
||||||
|
echo Calculating checksums
|
||||||
|
# shellcheck disable=SC2094
|
||||||
|
if ! cksum -a sha512 !(sources|*.spec|RPMS|SRPMS|BUILD) > sources; then
|
||||||
|
echo Sources checksum update failed
|
||||||
|
exit 7
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the script is being run directly, not sourced
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
main "$@"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user