From 31adcf80599dae30a3769c5f3957f0ac0683b994 Mon Sep 17 00:00:00 2001 From: Kevin Mittman <kmittman@nvidia.com> Date: Mon, 15 Aug 2022 11:28:27 -0700 Subject: [PATCH] Add RPM package example Signed-off-by: Kevin Mittman <kmittman@nvidia.com> --- rpm/Makefile | 40 ++++++++++++++++++++++++++++++++++ rpm/example/SPECS/example.spec | 16 ++++++++++++++ rpm/meta/stubrepo-rpm.sh | 19 ++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 rpm/Makefile create mode 100644 rpm/example/SPECS/example.spec create mode 100755 rpm/meta/stubrepo-rpm.sh diff --git a/rpm/Makefile b/rpm/Makefile new file mode 100644 index 0000000..8b85814 --- /dev/null +++ b/rpm/Makefile @@ -0,0 +1,40 @@ +PWD = $(shell pwd) +VERSION = 1.0-1 +GPG_HEADLESS = --openpgp --decrypt --no-auto-check-trustdb --batch --no-tty --status-fd 1 + +RPM_ROOT = example +RPM_ARCH = noarch +SPEC_FILES = $(wildcard $(RPM_ROOT)/SPECS/*.spec) +RPM_PACKAGE = $(join $(addsuffix ../RPMS/$(RPM_ARCH)/, $(dir $(SPEC_FILES))), $(notdir $(SPEC_FILES:.spec=-$(VERSION).$(RPM_ARCH).rpm))) + +META_ROOT = meta + +default: all + +$(RPM_PACKAGE): $(SPEC_FILES) + cd $(RPM_ROOT); rpmbuild --define "%_topdir $(PWD)/$(RPM_ROOT)" -v -ba SPECS/$(shell basename $<) + +all: $(RPM_PACKAGE) repodata/repomd.xml trash + @for rpm in $(RPM_PACKAGE); do rpm -Kv "$(RPM_PACKAGE)" 2>&1 | grep -q "NOKEY" || echo "UNSIGNED `basename $(RPM_PACKAGE)`"; done + @#ls -1 $(META_DATA) + +rpm: $(RPM_PACKAGE) + +repodata/repomd.xml: $(RPM_PACKAGE) + @for pkg in $(RPM_PACKAGE); do rpm=`readlink -m $$pkg`; ln -s -f $$rpm $(META_ROOT)/`basename $$rpm`; done + cd $(META_ROOT); ./stubrepo-rpm.sh *.rpm + +meta: repodata/repomd.xml + +trash: + cd $(RPM_ROOT)/; rm -rf BUILD BUILDROOT SRPMS + cd $(META_ROOT)/; rm -f repodata/*sqlite.bz2 repodata/*.xml.gz + +clean: trash + rm -f $(META_ROOT)/Packages $(META_ROOT)/Packages.gz + rm -f $(META_ROOT)/repodata/repomd.xml + rm -f $(META_ROOT)/repodata/repomd.xml.asc $(META_ROOT)/repodata/repomd.xml.key + rm -f $(META_ROOT)/*.rpm + rm -f $(RPM_ROOT)/RPMS/*/*.rpm + +.PHONY: all default rpm meta trash clean diff --git a/rpm/example/SPECS/example.spec b/rpm/example/SPECS/example.spec new file mode 100644 index 0000000..5462320 --- /dev/null +++ b/rpm/example/SPECS/example.spec @@ -0,0 +1,16 @@ +%global _enable_debug_package 0 +%global debug_package %{nil} +%global __os_install_post /usr/lib/rpm/brp-compress %{nil} + +Name: example +Version: 1.0 +Release: 1 +License: None +BuildArch: noarch +Summary: Unit test for RPM packaging +AutoReq: 0 + +%description +Example package for test of RPM package signing + +%files diff --git a/rpm/meta/stubrepo-rpm.sh b/rpm/meta/stubrepo-rpm.sh new file mode 100755 index 0000000..89504a7 --- /dev/null +++ b/rpm/meta/stubrepo-rpm.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +err() { echo "ERROR: $*"; exit 1; } + +rpm_metadata() { + repomd="repodata/repomd.xml" + echo ">>> createrepo_c -v --database $PWD" + createrepo_c -v --database "$PWD" +} + +if [[ -z $1 ]] || [[ ! -f $1 ]]; then + err "USAGE: $0 [*.rpm]" +fi + +if [[ ! -f "repodata/repomd.xml" ]]; then + rpm_metadata +fi + +### END ### -- GitLab