Skip to content

Commit

Permalink
- re-add lost %dir %{_datadir}/%{name}
Browse files Browse the repository at this point in the history
- merge openSUSE and Red Hat build scripts as well as their spec files and
  only build a single rpm
- merge openSUSE and Red Hat publish scripts for a common rpm repository
  and a common web page
- always gpg sign repomd.xml and set repo_gpgcheck for the common repo file
- set releasever from 1.1 to 1
- (gitignore test-webroot)
  • Loading branch information
philfry committed Sep 28, 2023
1 parent a1bd916 commit cd7d47d
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 784 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ generated

msi/build
venv/

pkg.jenkins.io/
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ podTemplate(yaml: readTrusted('KubernetesPod.yaml'), workingDir: '/home/jenkins/
stage('Build') {
sh 'make package && python3 -m pytest bin --junitxml target/junit.xml'
junit 'target/junit.xml'
def results = '*.war, target/debian/*.deb, target/rpm/*.rpm, target/suse/*.rpm'
def results = '*.war, target/debian/*.deb, target/rpm/*.rpm'
stash includes: results, name: 'results'
archiveArtifacts results
}
Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ clean:
setup:
bash -ex -c 'for f in */setup.sh; do $$f; done'

package: war deb rpm suse
package: war deb rpm

publish: war.publish deb.publish rpm.publish suse.publish
publish: war.publish deb.publish rpm.publish

test: deb.test rpm.test suse.test
test: deb.test rpm.test

war: ${WAR}
war.publish: ${WAR}
Expand All @@ -49,12 +49,6 @@ ${RPM}: ${WAR} $(shell find rpm/build -type f)
rpm.publish: ${RPM} $(shell find rpm/publish -type f)
./rpm/publish/publish.sh

suse: ${SUSE}
${SUSE}: ${WAR} $(shell find suse/build -type f)
./suse/build/build.sh
suse.publish: ${SUSE} $(shell find suse/publish -type f)
./suse/publish/publish.sh

msi.publish:
./msi/publish/publish.sh

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ This repository contains scripts for packaging `jenkins.war` into various platfo
The following platforms are currently supported:

* Windows MSI: `msi/`
* RedHat/CentOS RPM: `rpm/`
* RedHat/CentOS/openSUSE RPM: `rpm/`
* Debian/Ubuntu DEB: `deb/`
* OpenSUSE RPM: `suse/`

# Pre-requisites
Running the main package script requires a Linux environment (currently Ubuntu, see [JENKINS-27744](https://issues.jenkins-ci.org/browse/JENKINS-27744).)
Expand Down
1 change: 0 additions & 1 deletion bin/branding.list
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ORGANIZATION
----------------------------------
RELEASELINE
RPM_URL
SUSE_URL
DEB_URL
LICENSE_TEXT
LICENSE_TEXT_DEB
Expand Down
11 changes: 3 additions & 8 deletions bin/indexGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ class IndexGenerator:
"template": "header.debian.html",
"web_url": os.getenv("DEB_URL"),
},
"redhat": {
"rpm": {
"extension": ".rpm",
"template": "header.redhat.html",
"template": "header.rpm.html",
"web_url": os.getenv("RPM_URL"),
},
"opensuse": {
"extension": ".rpm",
"template": "header.opensuse.html",
"web_url": os.getenv("SUSE_URL"),
},
"war": {"extension": ".war", "template": "header.war.html", "web_url": "unset"},
"windows": {
"extension": ".msi",
Expand All @@ -38,7 +33,7 @@ class IndexGenerator:

HELP_MESSAGE = """
Generate header.html for package distribution site
It supports debian, redhat and opensuse packages
It supports debian and rpm packages
indexGenerator.py
-d <distribution>: Which package distribution to target
Expand Down
2 changes: 0 additions & 2 deletions bin/test_branding.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
CHANGELOG_PAGE
----------------------------------
SUSE_URL
# INVALID
DEB_URL
LICENSE_TEXT
Expand Down Expand Up @@ -56,7 +55,6 @@ def test_clean_lines(self):
"LICENSE",
"HOMEPAGE",
"CHANGELOG_PAGE",
"SUSE_URL",
"DEB_URL",
"LICENSE_TEXT",
}
Expand Down
9 changes: 3 additions & 6 deletions env/azure.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ export SCP_OPTS=-P 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/nul
export WARDIR=/srv/releases/jenkins/war${RELEASELINE}
export MSIDIR=/srv/releases/jenkins/windows${RELEASELINE}
export DEBDIR=/srv/releases/jenkins/debian${RELEASELINE}/binary
export RPMDIR=/srv/releases/jenkins/redhat${RELEASELINE}
export SUSEDIR=/srv/releases/jenkins/opensuse${RELEASELINE}
export RPMDIR=/srv/releases/jenkins/rpm${RELEASELINE}

# where to put repository index and other web contents
export RPM_WEBDIR=/srv/releases/jenkins/redhat${RELEASELINE}
export RPM_WEBDIR=/srv/releases/jenkins/rpm${RELEASELINE}
export MSI_WEBDIR=/srv/releases/jenkins/windows${RELEASELINE}
export SUSE_WEBDIR=/srv/releases/jenkins/opensuse${RELEASELINE}
export DEB_WEBDIR=/srv/releases/jenkins/debian${RELEASELINE}
export WAR_WEBDIR=/srv/releases/jenkins/war${RELEASELINE}

# URL to the aforementioned webdir.
WEBSERVER=pkg.jenkins.io
export RPM_URL=https://${WEBSERVER}/redhat${RELEASELINE}
export SUSE_URL=https://${WEBSERVER}/opensuse${RELEASELINE}
export RPM_URL=https://${WEBSERVER}/rpm${RELEASELINE}
export DEB_URL=https://${WEBSERVER}/debian${RELEASELINE}
9 changes: 3 additions & 6 deletions env/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ export SCP_OPTS=-P 22
export WARDIR=/srv/releases/jenkins/war${RELEASELINE}
export MSIDIR=/srv/releases/jenkins/windows${RELEASELINE}
export DEBDIR=/srv/releases/jenkins/debian${RELEASELINE}
export RPMDIR=/srv/releases/jenkins/redhat${RELEASELINE}
export SUSEDIR=/srv/releases/jenkins/opensuse${RELEASELINE}
export RPMDIR=/srv/releases/jenkins/rpm${RELEASELINE}

# where to put repository index and other web contents
export RPM_WEBDIR=/var/www/pkg.jenkins.io.staging/redhat${RELEASELINE}
export SUSE_WEBDIR=/var/www/pkg.jenkins.io.staging/opensuse${RELEASELINE}
export RPM_WEBDIR=/var/www/pkg.jenkins.io.staging/rpm${RELEASELINE}
export DEB_WEBDIR=/var/www/pkg.jenkins.io.staging/debian${RELEASELINE}
export WAR_WEBDIR=/var/www/pkg.jenkins.io.staging/war${RELEASELINE}
export MSI_WEBDIR=/var/www/pkg.jenkins.io.staging/windows${RELEASELINE}

# URL to the aforementioned webdir
export RPM_URL=https://pkg.jenkins.io/redhat${RELEASELINE}
export SUSE_URL=https://pkg.jenkins.io/opensuse${RELEASELINE}
export RPM_URL=https://pkg.jenkins.io/rpm${RELEASELINE}
export DEB_URL=https://pkg.jenkins.io/debian${RELEASELINE}
9 changes: 3 additions & 6 deletions env/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ export TESTDIR=$(realpath .)/pkg.jenkins.io
export WARDIR=${TESTDIR}/war${RELEASELINE}
export MSIDIR=${TESTDIR}/windows${RELEASELINE}
export DEBDIR=${TESTDIR}/debian${RELEASELINE}/binary
export RPMDIR=${TESTDIR}/redhat${RELEASELINE}
export SUSEDIR=${TESTDIR}/opensuse${RELEASELINE}
export RPMDIR=${TESTDIR}/rpm${RELEASELINE}

# where to put repository index and other web contents
export RPM_WEBDIR=${TESTDIR}/redhat${RELEASELINE}
export SUSE_WEBDIR=${TESTDIR}/opensuse${RELEASELINE}
export RPM_WEBDIR=${TESTDIR}/rpm${RELEASELINE}
export DEB_WEBDIR=${TESTDIR}/debian${RELEASELINE}
export WAR_WEBDIR=${TESTDIR}/war${RELEASELINE}
export MSI_WEBDIR=${TESTDIR}/windows${RELEASELINE}

# URL to the aforementioned webdir.
WEBSERVER=pkg.jenkins.io
export RPM_URL=https://${WEBSERVER}/redhat${RELEASELINE}
export SUSE_URL=https://${WEBSERVER}/opensuse${RELEASELINE}
export RPM_URL=https://${WEBSERVER}/rpm${RELEASELINE}
export DEB_URL=https://${WEBSERVER}/debian${RELEASELINE}
2 changes: 1 addition & 1 deletion molecule/default/install-suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
state: present
key: /var/tmp/target/credentials/test.ascii.key
- find:
paths: /var/tmp/target/suse
paths: /var/tmp/target/rpm
file_type: file
patterns: "*.rpm"
register: package_list
Expand Down
2 changes: 2 additions & 0 deletions rpm/build/SOURCES/jenkins.repo
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[@@ARTIFACTNAME@@]
name=@@PRODUCTNAME@@
baseurl=@@RPM_URL@@
# TODO 'jenkins.io' {{ web_url }}/{{organization}}-2023.key
gpgkey=@@RPM_URL@@/jenkins.io-2023.key
gpgcheck=1
3 changes: 2 additions & 1 deletion rpm/build/SPECS/jenkins.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Name: @@ARTIFACTNAME@@
Version: %{ver}
Release: 1.1
Release: 1
Summary: @@SUMMARY@@
Source: jenkins.war
Source1: jenkins.service
Expand Down Expand Up @@ -73,6 +73,7 @@ fi
%ghost %{_localstatedir}/cache/%{name}
%{_unitdir}/%{name}.service
%{_bindir}/%{name}
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/migrate

%changelog
Expand Down
46 changes: 21 additions & 25 deletions rpm/publish/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euxo pipefail
: "${RPM_WEBDIR:?Require where to put index and other web contents}"
: "${RPM_URL:?Require rpm repository url}"
: "${RELEASELINE?Require rpm release line}"
: "${BASE:? Required base directory}"
: "${BASE:?Require base directory}"

# $$ Contains current pid
D="$AGENT_WORKDIR/$$"
Expand All @@ -21,10 +21,10 @@ function clean() {

function generateSite() {
gpg --export -a --output "$D/${ORGANIZATION}.key" "${GPG_KEYNAME}"
echo "$(gpg --import-options show-only --import $D/${ORGANIZATION}.key)" >"$D/${ORGANIZATION}.key.info"
gpg --import-options show-only --import "$D/${ORGANIZATION}.key" >"$D/${ORGANIZATION}.key.info"

"$BASE/bin/indexGenerator.py" \
--distribution redhat \
--distribution rpm \
--gpg-key-info-file "${D}/${ORGANIZATION}.key.info" \
--targetDir "$D"

Expand All @@ -36,16 +36,10 @@ function generateSite() {
[${ARTIFACTNAME}]
name=${PRODUCTNAME}${RELEASELINE}
baseurl=${RPM_URL}
gpgkey=${RPM_URL}/${ORGANIZATION}-2023.key
gpgcheck=1
repo_gpgcheck=1
EOF

# generate index
# locally
# disable this for now, as it's currently now used and generate errors
# createrepo --update -o "$RPM_WEBDIR" "$RPMDIR/"
# on the server
# shellcheck disable=SC2029
ssh "${SSH_OPTS[@]}" "$PKGSERVER" createrepo --update -o "'$RPM_WEBDIR'" "'$RPMDIR/'"
}

function skipIfAlreadyPublished() {
Expand All @@ -60,7 +54,6 @@ function init() {
mkdir -p "$D/RPMS/noarch"

mkdir -p "$RPMDIR/"
# mkdir -p "$RPM_WEBDIR/" # May not be necessary
# shellcheck disable=SC2029
ssh "${SSH_OPTS[@]}" "$PKGSERVER" mkdir -p "'$RPMDIR/'"
}
Expand All @@ -83,7 +76,7 @@ function uploadPackage() {
-e "ssh ${SSH_OPTS[*]}" \
--ignore-existing \
--progress \
"$RPM" "$PKGSERVER:${RPMDIR// /\\ }/"
"${RPM}" "$PKGSERVER:${RPMDIR// /\\ }/"
}

function show() {
Expand All @@ -99,17 +92,6 @@ function show() {

function uploadSite() {
pushd "$D"
# Disable copy on local network storage
#rsync \
# --compress \
# --recursive \
# --verbose \
# --exclude RPMS \
# --exclude "HEADER.html" \
# --exclude "FOOTER.html" \
# --progress \
# . "$RPM_WEBDIR/"

rsync \
--archive \
--compress \
Expand All @@ -121,6 +103,20 @@ function uploadSite() {
--progress \
. "$PKGSERVER:${RPM_WEBDIR// /\\ }/"

# generate index on the server
ssh "${SSH_OPTS[@]}" "$PKGSERVER" createrepo --update -o "'$RPM_WEBDIR'" "'$RPMDIR/'"

ssh "${SSH_OPTS[@]}" "$PKGSERVER" "cat $RPMDIR/repodata/repomd.xml" | \
gpg \
--batch \
--pinentry-mode loopback \
-u "$GPG_KEYNAME" \
-a \
--detach-sign \
--passphrase-file "$GPG_PASSPHRASE_FILE" \
--yes | \
ssh "${SSH_OPTS[@]}" "$PKGSERVER" "cat > $RPMDIR/repodata/repomd.xml.asc"

# Following html need to be located inside the binary directory
rsync \
--compress \
Expand All @@ -146,7 +142,7 @@ function uploadSite() {
}

show
## Disabling this function allow us to recreate and sign the RedHat repository.
## Disabling this function allow us to recreate and sign the rpm repository.
# the rpm package won't be overrided as we use the parameter '--ignore-existing' when we upload it
#skipIfAlreadyPublished
init
Expand Down
5 changes: 1 addition & 4 deletions setup.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export MSI_SHASUM:=${MSI}.sha256
export DEB=${TARGET}/debian/${ARTIFACTNAME}_${VERSION}_all.deb

# where to generate RHEL/CentOS RPM file?
export RPM=${TARGET}/rpm/${ARTIFACTNAME}-${VERSION}-1.1.noarch.rpm

# where to generate SUSE RPM file?
export SUSE=${TARGET}/suse/${ARTIFACTNAME}-${VERSION}-1.2.noarch.rpm
export RPM=${TARGET}/rpm/${ARTIFACTNAME}-${VERSION}-1.noarch.rpm

# anchored to the root of the repository
export BASE:=$(CURDIR)
Expand Down
Loading

0 comments on commit cd7d47d

Please sign in to comment.