Skip to content

Commit

Permalink
fix: update Oracle Linux 7 build scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Avi Miller <me@dje.li>
  • Loading branch information
Djelibeybi committed Jan 30, 2024
1 parent 2902122 commit c265399
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
4 changes: 2 additions & 2 deletions oraclelinux7/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) 2021 Avi Miller
# Copyright (c) 2021, 2024 Avi Miller
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

FROM oraclelinux:7-slim

RUN yum -y install oracle-epel-release-el7 oracle-nodejs-release-el7 \
&& yum -y --enablerepo=ol7_optional_latest install @buildsys-build tito rpm-build rpm-sign nodejs which expect \
&& yum -y --enablerepo=ol7_optional_latest install @buildsys-build tito rpm-build rpm-sign nodejs npm which expect \
&& rm -rf /var/cache/yum \
&& npm install -g yarn \
&& rpmdev-setuptree
Expand Down
12 changes: 7 additions & 5 deletions oraclelinux7/build-rhsm-ol7.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2021 Avi Miller
# Copyright (c) 2021, 2024 Avi Miller
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
#
# find the latest upstream version of the subscription-manager RPM
Expand All @@ -9,20 +9,22 @@ RHSM_VERSION=$(echo "$RHSM_NVR" | cut -d: -f1)
RHSM_REL=$(echo "$RHSM_NVR" | cut -d: -f2)
RHSM_RELEASE=$(echo "$RHSM_REL" | cut -d. -f1)
RHSM_DIST=$(echo "$RHSM_REL" | cut -d. -f2)
IMG_VER=$(git rev-parse --short=12 HEAD)

# build image if necessary
{
docker image inspect build-rhsm:ol7 &>/dev/null
docker image inspect "build-rhsm:ol7-$IMG_VER" &>/dev/null
} || {
docker build -t build-rhsm:ol7 .
docker build -t "build-rhsm:ol7-$IMG_VER" .
}

# build the packages in a container which will delete itself once it's done
docker run --rm -it --name build-rhsm7 \
docker run --rm -it \
--name build-rhsm-ol7 \
-v "$PWD/gpg:/gpg" \
-v "$PWD/output:/output" \
-e RHSM_VERSION="$RHSM_VERSION" \
-e RHSM_RELEASE="$RHSM_RELEASE" \
-e RHSM_DIST="$RHSM_DIST" \
-e GPG_NAME_EMAIL \
build-rhsm:ol7
"build-rhsm:ol7-$IMG_VER"
20 changes: 13 additions & 7 deletions oraclelinux7/scripts/build-rhsm.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/bin/bash
#
# Copyright (c) 2021 Avi Miller
# Copyright (c) 2021, 2024 Avi Miller
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

# Import GPG key and trust it
gpg --import --passphrase-file /gpg/passphrase < /gpg/key.asc
(echo 5; echo y; echo save) | gpg --command-fd 0 --no-tty --no-greeting -q --edit-key "$(gpg --list-packets < /gpg/key.asc | awk '$1=="keyid:"{print$2;exit}')" trust

# Clone the git repo
cd /root || exit
git clone https://github.com/candlepin/subscription-manager.git

# Build the SRPM using tito then install it
cd subscription-manager || exit
# Checkout the release tag
cd /root/subscription-manager || exit
git checkout "subscription-manager-$RHSM_VERSION-$RHSM_RELEASE"

# Use tito to build the source RPM
tito build --tag="subscription-manager-$RHSM_VERSION-$RHSM_RELEASE" --srpm --dist=".$RHSM_DIST" --offline
cp "/tmp/tito/subscription-manager-$RHSM_VERSION-$RHSM_RELEASE.$RHSM_DIST.src.rpm" /root/rpmbuild/SRPMS/
rpm -ivh "/root/rpmbuild/SRPMS/subscription-manager-$RHSM_VERSION-$RHSM_RELEASE.$RHSM_DIST.src.rpm"


# Patch the subscription-manager.spec file
rpm -ivh "/root/rpmbuild/SRPMS/subscription-manager-$RHSM_VERSION-$RHSM_RELEASE.$RHSM_DIST.src.rpm"
cd /root/rpmbuild/SPECS || exit
patch -p0 < /obsolete-rhn-rpms.diff

Expand All @@ -28,6 +29,11 @@ rpmbuild -ba SPECS/subscription-manager.spec

# Sign the binary RPMs if the required files and envvar are provided.
if [ -f /gpg/key.asc ] && [ -f /gpg/passphrase ] && [ "$GPG_NAME_EMAIL" ]; then

# Import GPG key and trust it
gpg --import --passphrase-file /gpg/passphrase < /gpg/key.asc
(echo 5; echo y; echo save) | gpg --command-fd 0 --no-tty --no-greeting -q --edit-key "$(gpg --list-packets < /gpg/key.asc | awk '$1=="keyid:"{print$2;exit}')" trust

echo "%_gpg_name $GPG_NAME_EMAIL" >> /root/.rpmmacros
find /root/rpmbuild/RPMS -name '*.rpm' -exec /rpm-sign.exp {} \;
fi
Expand Down
28 changes: 14 additions & 14 deletions oraclelinux7/scripts/obsolete-rhn-rpms.diff
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
--- subscription-manager.spec.orig 2021-04-16 03:21:49.000000000 +1000
+++ subscription-manager.spec 2021-09-01 11:46:07.000000000 +1000
--- subscription-manager.spec.orig 2023-09-22 09:53:19.000000000 +0000
+++ subscription-manager.spec 2024-01-30 22:57:48.877132099 +0000
@@ -1,3 +1,4 @@
+%global _name subscription-manager
# Prefer systemd over sysv on Fedora and RHEL 7+
%global use_systemd 0%{?fedora} || (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} && 0%{?suse_version} >= 1315)
# For optional building of ostree-plugin sub package. Unrelated to systemd
@@ -131,7 +132,7 @@
@@ -132,7 +133,7 @@

%global subpackages SUBPACKAGES="%{?include_syspurpose:syspurpose}"

-Name: subscription-manager
+Name: subscription-manager-el7
Version: 1.24.48
Version: 1.24.53
Release: 1%{?dist}
Summary: Tools and libraries for subscription and repository management
@@ -144,18 +145,18 @@
@@ -145,18 +146,18 @@
# git clone https://github.com/candlepin/subscription-manager.git
# yum install tito
# tito build --tag subscription-manager-$VERSION-$RELEASE --tgz
Expand All @@ -36,7 +36,7 @@
%endif

# The following macro examples are preceeded by '%' to stop macro expansion
@@ -264,6 +265,19 @@
@@ -265,6 +266,19 @@
BuildRequires: systemd
%endif

Expand All @@ -56,7 +56,7 @@
%description
The Subscription Manager package provides programs and libraries to allow users
to manage subscriptions and yum repositories from the Red Hat entitlement
@@ -282,7 +296,7 @@
@@ -283,7 +297,7 @@
%package -n subscription-manager-plugin-container
Summary: A plugin for handling container content
Group: System Environment/Base
Expand All @@ -65,7 +65,7 @@

%description -n subscription-manager-plugin-container
Enables handling of content of type 'containerImage' in any certificates
@@ -320,15 +334,15 @@
@@ -321,15 +335,15 @@
%package -n subscription-manager-gui
Summary: A GUI interface to manage Red Hat product subscriptions
Group: System Environment/Base
Expand All @@ -84,7 +84,7 @@

%description -n subscription-manager-gui
This package contains a GTK+ graphical interface for configuring and
@@ -340,7 +354,7 @@
@@ -341,7 +355,7 @@
%package -n subscription-manager-migration
Summary: Migration scripts for moving to certificate based subscriptions
Group: System Environment/Base
Expand All @@ -93,7 +93,7 @@
Requires: rhnlib

# Since the migration data package is not in Fedora, we can only require it
@@ -368,7 +382,7 @@
@@ -369,7 +383,7 @@
%endif
# See BZ 1581410 - avoid a circular dependency
%if (0%{?rhel} < 8)
Expand All @@ -102,7 +102,7 @@
%endif
%if %{with python3}
Requires: python3-dnf-plugins-core
@@ -429,7 +443,7 @@
@@ -430,7 +444,7 @@
Requires: %{py_package_prefix}-gobject-base
# plugin needs a slightly newer version of python-iniparse for 'tidy'
Requires: %{py_package_prefix}-iniparse >= 0.4
Expand All @@ -111,7 +111,7 @@

%description -n subscription-manager-plugin-ostree
Enables handling of content of type 'ostree' in any certificates
@@ -523,7 +537,7 @@
@@ -524,7 +538,7 @@
%endif

%prep
Expand All @@ -120,7 +120,7 @@

%build
make -f Makefile VERSION=%{version}-%{release} CFLAGS="%{optflags}" \
@@ -831,7 +845,7 @@
@@ -840,7 +854,7 @@
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/com.redhat.*.conf
%if %use_systemd
%attr(644,root,root) %{_unitdir}/*.service
Expand All @@ -129,7 +129,7 @@
%else
%attr(755,root,root) %{_initrddir}/rhsmcertd
%endif
@@ -1116,7 +1130,7 @@
@@ -1125,7 +1139,7 @@
%post -n subscription-manager-gui
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
%if !0%{?suse_version}
Expand Down

0 comments on commit c265399

Please sign in to comment.