diff options
author | Oliver Smith <osmith@sysmocom.de> | 2024-04-25 13:42:15 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2024-04-25 14:13:45 +0200 |
commit | b2e128511d5aeae1eb27a7465197012fac643da2 (patch) | |
tree | 570317c505e5ee618f4f5a830db1966ac79812d0 | |
parent | ec9efbf6494a1bad8a16f0c5b33f878a62822500 (diff) |
As I'm preparing slides for a OsmoDevCon talk, I'm realizing that it is
quite cumbersome for users to build debian packages from Osmocom git
repositories (the same way gerrit does it, to reproduce errors locally).
Move the logic from the gerrit-binpkgs job to a separate script that can
be run from an Osmocom git repository, will figure out the repository
name from there and only needs the target distribution as argument.
Usage example:
$ git clone https://gitea.osmocom.org/osmocom/osmo-ci
$ cd libosmocore
$ ../osmo-ci/scripts/obs/gerrit_binpkgs.sh debian:12 # or debian:11, debian:10, almalinux:8
Change-Id: I100d8dfc0c58bdafe7efb0fa4108031ce10398a5
-rw-r--r-- | jobs/gerrit-binpkgs.yml | 24 | ||||
-rw-r--r-- | scripts/obs/README | 1 | ||||
-rwxr-xr-x | scripts/obs/gerrit_binpkgs.sh | 40 |
3 files changed, 44 insertions, 21 deletions
diff --git a/jobs/gerrit-binpkgs.yml b/jobs/gerrit-binpkgs.yml index 7cf2230..a6cf44b 100644 --- a/jobs/gerrit-binpkgs.yml +++ b/jobs/gerrit-binpkgs.yml @@ -28,7 +28,7 @@ scm: - git: - basedir: 'code-from-gerrit' + basedir: '$PROJECT_NAME' url: '$GERRIT_REPO_URL' credentials-id: d5eda5e9-b59d-44ba-88d2-43473cb6e42d branches: @@ -60,27 +60,9 @@ osmo-ci git -C osmo-ci log --oneline - # Move code from gerrit to build_srcpkg.py's git cache - cache_dir=osmo-ci/scripts/obs/_cache - mkdir -p $cache_dir - mv code-from-gerrit "$cache_dir/$PROJECT_NAME" + cd "$PROJECT_NAME" + ../osmo-ci/scripts/obs/gerrit_binpkgs.sh "$DISTRO" - # Set a known branch name - git -C "$cache_dir/$PROJECT_NAME" checkout -B "origin/gerrit" - - # Build source package - cd osmo-ci/scripts/obs/ - ./build_srcpkg.py \ - --docker \ - --feed master \ - --git-branch gerrit \ - --git-skip-fetch \ - "$PROJECT_NAME" - - # Build binary package - ./build_binpkg.py \ - --docker "$DISTRO" \ - "$PROJECT_NAME" wrappers: - ansicolor: colormap: xterm diff --git a/scripts/obs/README b/scripts/obs/README index cf8e201..e6ca502 100644 --- a/scripts/obs/README +++ b/scripts/obs/README @@ -4,6 +4,7 @@ This directory contains the following scripts, related to building Osmocom projects in OBS (Open Build Service) and building binary packages. Here is an overview of the scripts, run them with -h to get a more detailed description. +* gerrit_binpkgs.sh: build source + binary packages like CI for gerrit * build_srcpkg.py: build one source package for an Osmocom project * update_obs_project.py: generate source packages and upload them to OBS * build_binpkg.py: build rpm/deb packages for one Osmocom project diff --git a/scripts/obs/gerrit_binpkgs.sh b/scripts/obs/gerrit_binpkgs.sh new file mode 100755 index 0000000..1e4ae26 --- /dev/null +++ b/scripts/obs/gerrit_binpkgs.sh @@ -0,0 +1,40 @@ +#!/bin/sh -e +SCRIPTS_OBS_DIR="$(realpath "$(dirname "$0")")" + +DISTRO="$1" +if [ -z "$DISTRO" ]; then + echo "usage: gerrit-binpkgs.sh DISTRO" + echo "examples:" + echo " gerrit-binpkgs.sh debian:12" + echo " gerrit-binpkgs.sh almalinux:8" + exit 1 +fi + +GIT_REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null || true)" +if [ -z "$GIT_REPO_DIR" ]; then + echo "ERROR: run inside a git repository of an Osmocom project" + exit 1 +fi + +CACHE_DIR="$SCRIPTS_OBS_DIR/_cache" +PROJECT_NAME="$(basename "$GIT_REPO_DIR")" + +# Copy the source dir into the cache dir. It will be mounted inside the docker +# containers for building source and binary packages (so using a symlink does +# not work). Use rsync so it is very fast. +echo ":: Copying the source to the cache dir" +mkdir -p "$CACHE_DIR" +rsync -a --delete "$GIT_REPO_DIR" "$CACHE_DIR" + +echo ":: Building the source package" +"$SCRIPTS_OBS_DIR"/build_srcpkg.py \ + --docker \ + --feed master \ + --git-skip-fetch \ + --git-skip-checkout \ + "$PROJECT_NAME" + +echo ":: Building the binary packages" +"$SCRIPTS_OBS_DIR"/build_binpkg.py \ + --docker "$DISTRO" \ + "$PROJECT_NAME" |