Skip to content

Commit

Permalink
Merge pull request #129 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 3.3.0
  • Loading branch information
andyone authored Nov 29, 2023
2 parents 9349541 + f8dda28 commit d7a2de3
Show file tree
Hide file tree
Showing 14 changed files with 2,029 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .docker/centos7.docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG REGISTRY="docker.io"

FROM ${REGISTRY}/essentialkaos/centos:7

ARG GOSU_VER=1.16
ARG GOSU_VER=1.17
ARG HOSTNAME="rpmbuilder-centos7.docker.local"

LABEL org.opencontainers.image.title="RPMBuilder" \
Expand Down
4 changes: 2 additions & 2 deletions .docker/ol7.docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG REGISTRY="docker.io"

FROM ${REGISTRY}/essentialkaos/oraclelinux:7

ARG GOSU_VER=1.16
ARG GOSU_VER=1.17
ARG HOSTNAME="rpmbuilder-ol7.docker.local"

LABEL org.opencontainers.image.title="RPMBuilder" \
Expand All @@ -33,7 +33,7 @@ RUN echo "$HOSTNAME" > /etc/hostname && \
mkdir -p /home/builder/rpmbuild/BUILD /home/builder/rpmbuild/BUILDROOT \
/home/builder/rpmbuild/RPMS /home/builder/rpmbuild/SOURCES \
/home/builder/rpmbuild/SPECS /home/builder/rpmbuild/SRPMS && \
mkdir -p /usr/libexec/rpmbuilder /home/builder/.config /rpmbuilder
mkdir -p /usr/libexec/rpmbuilder /home/builder/.config/rpmbuilder /rpmbuilder

COPY SOURCES/conf/rpmmacros_el7 /home/builder/.rpmmacros
COPY SOURCES/conf/rpmlint /home/builder/.config/rpmlint
Expand Down
4 changes: 2 additions & 2 deletions .docker/ol8.docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG REGISTRY="docker.io"

FROM ${REGISTRY}/essentialkaos/oraclelinux:8

ARG GOSU_VER=1.16
ARG GOSU_VER=1.17
ARG HOSTNAME="rpmbuilder-ol8.docker.local"

LABEL org.opencontainers.image.title="RPMBuilder" \
Expand All @@ -32,7 +32,7 @@ RUN echo "$HOSTNAME" > /etc/hostname && \
mkdir -p /home/builder/rpmbuild/BUILD /home/builder/rpmbuild/BUILDROOT \
/home/builder/rpmbuild/RPMS /home/builder/rpmbuild/SOURCES \
/home/builder/rpmbuild/SPECS /home/builder/rpmbuild/SRPMS && \
mkdir -p /usr/libexec/rpmbuilder /home/builder/.config /rpmbuilder
mkdir -p /usr/libexec/rpmbuilder /home/builder/.config/rpmbuilder /rpmbuilder

COPY SOURCES/conf/rpmmacros_el8 /home/builder/.rpmmacros
COPY SOURCES/conf/builder.sudoers /etc/sudoers.d/rpmbuilder
Expand Down
4 changes: 2 additions & 2 deletions .docker/ol9.docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG REGISTRY="docker.io"

FROM ${REGISTRY}/essentialkaos/oraclelinux:9

ARG GOSU_VER=1.16
ARG GOSU_VER=1.17
ARG HOSTNAME="rpmbuilder-ol9.docker.local"

LABEL org.opencontainers.image.title="RPMBuilder" \
Expand All @@ -32,7 +32,7 @@ RUN echo "$HOSTNAME" > /etc/hostname && \
mkdir -p /home/builder/rpmbuild/BUILD /home/builder/rpmbuild/BUILDROOT \
/home/builder/rpmbuild/RPMS /home/builder/rpmbuild/SOURCES \
/home/builder/rpmbuild/SPECS /home/builder/rpmbuild/SRPMS && \
mkdir -p /usr/libexec/rpmbuilder /home/builder/.config /rpmbuilder
mkdir -p /usr/libexec/rpmbuilder /home/builder/.config/rpmbuilder /rpmbuilder

COPY SOURCES/conf/rpmmacros_el9 /home/builder/.rpmmacros
COPY SOURCES/conf/builder.sudoers /etc/sudoers.d/rpmbuilder
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Check scripts with Shellcheck
uses: essentialkaos/shellcheck-action@v1
with:
files: SOURCES/rpmbuilder SOURCES/libexec/*.shx SOURCES/rpmunbuilder SOURCES/buildmon SOURCES/initenv SOURCES/nodeinfo .docker/entrypoint .docker/node-entrypoint rpmbuilder-docker
files: SOURCES/rpmbuilder SOURCES/libexec/*.shx SOURCES/rpmunbuilder SOURCES/buildmon SOURCES/initenv SOURCES/nodeinfo .docker/entrypoint .docker/node-entrypoint rpmbuilder-docker rpmbuilder-farm

Hadolint:
name: Hadolint
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test: ## Run shellcheck tests
shellcheck .docker/entrypoint
shellcheck .docker/node-entrypoint
shellcheck rpmbuilder-docker
shellcheck rpmbuilder-farm

install: ## Install app to current system (requires sudo)
ifneq ($(shell id -u), 0)
Expand Down
178 changes: 104 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,24 @@ Build node images:

</p></details>

Package build using basic image:
Package build using base image:

```bash
# Download and install rpmbuilder-docker script
curl -fL# -o rpmbuilder-docker https://kaos.sh/rpmbuilder/rpmbuilder-docker
chmod +x rpmbuilder-docker
sudo mv rpmbuilder-docker /usr/bin/

# Pull image
# Pull rpmbuilder image based on OracleLinux 8
docker pull ghcr.io/essentialkaos/rpmbuilder:ol8
export IMAGE=ghcr.io/essentialkaos/rpmbuilder:ol8

# Build package
# Build package locally
cd my-package-dir
rpmbuilder-docker my-package.spec

# Build package using build nodes
rpmbuilder-docker my-package.spec -r buildnode-ol7.acme.corp:2022 -r buildnode-ol8.acme.corp:2022 -k $(base64 -w0 ~/.ssh/buildnode)
```

Package build using build node image:
Expand All @@ -93,9 +96,35 @@ docker pull ghcr.io/essentialkaos/rpmbuilder:node-ol8
docker run -e PUB_KEY="$(cat ~/.ssh/buildnode.pub)" -p 2038:2038 -d ghcr.io/essentialkaos/rpmbuilder:node-ol8

cd my-package-dir
rpmbuilder my-package.spec -r builder@localhost:2038 -kk ~/.ssh/buildnode

# Using local version of rpmbuilder (if you are use RHEL, Alma, Rocky, CentOS…)
rpmbuilder my-package.spec -r builder@localhost:2038 -k ~/.ssh/buildnode

# With docker helper script (any Linux distro or macOS)
rpmbuilder-docker my-package.spec -r builder@localhost:2038 -k $(base64 -w0 ~/.ssh/buildnode)
```

You can bootstrap your own build farm using Docker and `rpmbuilder-farm` script:

```bash
curl -fL# -o rpmbuilder-farm https://kaos.sh/rpmbuilder/rpmbuilder-farm
chmod +x rpmbuilder-farm
sudo mv rpmbuilder-farm /usr/bin/

# Install farm script
sudo rpmbuilder-farm install

# Create user bob and add public key
sudo farm add-user bob

# Start all containers for user bob
sudo farm start bob
```

<p align="center">
<img src="https://gh.kaos.st/rpmbuilder-farm.png" alt="rpmbuilder-farm preview" />
</p>

### Tips

* You could define rpmbuilder options inside your specs ([example](https://github.com/essentialkaos/kaos-repo/blob/develop/specs/libnut/libnut.spec#L3-L4)). It very helpful for determining information about external sources.
Expand All @@ -115,35 +144,35 @@ Spec file:
Source packaging:
--pack, -p files Pack specified files to archive with default source name (mergeable)
--relative-pack, -R Use relative path in source archive instead of absolute
--source-dir, -sd path Path to a directory which contains source files specified in spec file
--source-list, -sl file Path to file which contains a list of source files specified in spec file
--dlcache, -dc dir Path to a directory for downloads caching
--download, -dl dir Download all remote sources to a specified directory
--no-validate, -nv Don't validate sources
--git url Fetch sources from Git repository
--svn url Fetch sources from SVN repository
--hg url Fetch sources from Mercurial repository
--bzr url Fetch sources from Bazaar repository
--path, -rp path Path to a directory with sources in repository
--branch, -rb branch Use specified repository branch
--revision, -rr rev Use specified revision
--tag, -rt tag Use specified tag
--svn-user, -su username Username for access to SVN repository
--svn-pass, -sp password Password for access to SVN repository
┌ --github, -gh url Fetch sources from github.com repository by url
│ --github, -gh user:project Fetch sources from github.com repository by user and project
└ --github, -gh user/project Fetch sources from github.com repository by user and project
┌ --bitbucket, -bb url Fetch sources from bitbucket.org repository by url
│ --bitbucket, -bb user:project Fetch sources from bitbucket.org repository by user and project
└ --bitbucket, -bb user/project Fetch sources from bitbucket.org repository by user and project
┌ --launchpad, -lp url Fetch sources from launchpad.net repository by url
└ --launchpad, -lp project-name Fetch sources from launchpad.net repository by project name
--gopack, -G url Fetch and pack golang sources using gopack
--pack, -p files Pack specified files to archive with default source name (mergeable)
--relative-pack, -R Use relative path in source archive instead of absolute
--source-dir, -sd path Path to a directory which contains source files specified in spec file
--source-list, -sl file Path to file which contains a list of source files specified in spec file
--dlcache, -dc dir Path to a directory for downloads caching
--download, -dl dir Download all remote sources to a specified directory
--no-validate, -nv Don't validate sources
--git url Fetch sources from Git repository
--svn url Fetch sources from SVN repository
--hg url Fetch sources from Mercurial repository
--bzr url Fetch sources from Bazaar repository
--path, -rp path Path to a directory with sources in repository
--branch, -rb branch Use specified repository branch
--revision, -rr rev Use specified revision
--tag, -rt tag Use specified tag
--svn-user, -su username Username for access to SVN repository
--svn-pass, -sp password Password for access to SVN repository
┌ --github, -gh url Fetch sources from github.com repository by url
│ --github, -gh user:project Fetch sources from github.com repository by user and project
└ --github, -gh user/project Fetch sources from github.com repository by user and project
┌ --bitbucket, -bb url Fetch sources from bitbucket.org repository by url
│ --bitbucket, -bb user:project Fetch sources from bitbucket.org repository by user and project
└ --bitbucket, -bb user/project Fetch sources from bitbucket.org repository by user and project
┌ --launchpad, -lp url Fetch sources from launchpad.net repository by url
└ --launchpad, -lp project-name Fetch sources from launchpad.net repository by project name
--gopack, -G url Fetch and pack golang sources using gopack
Examples:
Expand All @@ -160,73 +189,74 @@ Source packaging:
Dependencies install:
--install, -I Install build dependencies before build process
--install-latest, -IL Install the latest versions of build dependencies before build process
--enable-repo, -ER repo-name Enable repositories (mergeable)
--disable-repo, -DR repo-name Disable repositories (mergeable)
--exclude-package, -EX package Exclude package by name or glob (mergeable)
--install, -I Install build dependencies before build process
--install-latest, -IL Install the latest versions of build dependencies before build process
--enable-repo, -ER repo-name Enable repositories (mergeable)
--disable-repo, -DR repo-name Disable repositories (mergeable)
--exclude-package, -EX package Exclude package by name or glob (mergeable)
Remote build:
--parallel, -P Parallel build on all build servers in same time (tmux is required)
┌ --remote, -r Build rpm package on remote server
--remote, -r user:pass@host:port Build rpm package on the remote server with specified host, username and password
--remote, -r file Build rpm package on the remote servers listed in specified file
--key, -k file Path to the private key for specified user
--node, -N index-or-name Node index or name from file with build servers
--attach, -A Attach to parallel build session in tmux
--parallel, -P Parallel build on all build nodes in the same time (tmux is required)
┌ --remote, -r user:pass@host:port Build rpm package on the remote node with specified host, username and password (mergeable)
--remote, -r file Build rpm package on the remote nodes listed in specified file
--key, -k file Path to the private key for specified user
--key, -k data Base64-encoded private key for specified user
--node, -N index-or-name Node index or name from the file with build nodes
--attach, -A Attach to parallel build session in tmux
Examples:
rpmbuilder package.spec -r builder@127.0.0.1
rpmbuilder package.spec -r builder:mypass@127.0.0.1:2022~i386
rpmbuilder package.spec --remote ~/servers.list --key ~/.ssh/id_ed25519
rpmbuilder package.spec --parallel --remote ~/servers.list --node 1,2
rpmbuilder package.spec -r builder@192.168.1.100 -r builder@192.168.1.101 -k ~/.ssh/id_rsa
rpmbuilder package.spec -r builder:mypass@127.0.0.1:2022~i386 -k ~/.ssh/id_ed25519
rpmbuilder package.spec --remote ~/buildnodes.list --key ~/.ssh/id_ed25519
rpmbuilder package.spec --remote builder@127.0.0.1:5001 --key $(base64 -w0 ~/.ssh/id_ed25519)
rpmbuilder package.spec --parallel --remote ~/buildnodes.list --node 1,2
Build options:
--no-build, -NB Don't execute any build stages
--no-clean, -NC Don't remove source files and spec file after build
--no-deps, -ND Don't verify build dependencies
--no-binary, -NR Don't build binary packages
--no-source, -NS Don't build source package
--arch, -a arch Override target arch for a build
--qa-rpaths "<value>,…" Ignoring rpaths check
--no-build, -NB Don't execute any build stages
--no-clean, -NC Don't remove source files and spec file after build
--no-deps, -ND Don't verify build dependencies
--no-binary, -NR Don't build binary packages
--no-source, -NS Don't build source package
--arch, -a arch Override target arch for a build
--qa-rpaths "<value>,<value>,..." Ignoring rpaths check
Arguments passing:
--with, -w param Pass conditional parameters into a rpmbuild (mergeable)
--without, -W param Pass conditional parameters into a rpmbuild (mergeable)
--define, -D "macro=value" Define MACRO with value (exist macro will be not redefined) (mergeable)
--with, -w param Pass conditional parameters into a rpmbuild (mergeable)
--without, -W param Pass conditional parameters into a rpmbuild (mergeable)
--define, -D "macro=value" Define MACRO with value (exist macro will be not redefined) (mergeable)
Examples:
rpmbuilder package.spec --with ssl --with ldap
rpmbuilder package.spec -w ssl -W ldap
rpmbuilder package.spec -w ssl -w static -W ldap
rpmbuilder package.spec --with "ssl ldap"
rpmbuilder package.spec --define "install_dir=/some/dir" --define "service_user=someone"
More info: https://kaos.sh/rpmbuilder/w/Conditional-Builds
Spec validation:
--no-lint, -0 Don't check spec file before package build
--strict, -1 Don't build package if perfecto found major problems in spec file
--pedantic, -2 Don't build package if perfecto found minor problems in spec file
--perfect, -3 Don't build package if perfecto found any problems in spec file
--no-lint, -0 Don't check spec file before package build
--strict, -1 Don't build package if perfecto found major problems in spec file
--pedantic, -2 Don't build package if perfecto found minor problems in spec file
--perfect, -3 Don't build package if perfecto found any problems in spec file
Other:
--sign, -s Sign package after build
--dest, -d dir Save built packages to a specified directory
--keep-log, -kl Save build log after an unsuccessful build
--bump, -b Bump release in spec file after a successful build
--bump-comment, -bc comment Comment which will be added while release bump
--tmp dir Path to a temporary directory
--verbose, -V Verbose output
--no-color, -nc Disable colors in output
--help, -h Show this help message
--version, -v Show information about version
--sign, -s Sign package after build
--dest, -d dir Save built packages to a specified directory
--keep-log, -kl Save build log after an unsuccessful build
--bump, -b Bump release in spec file after a successful build
--bump-comment, -bc comment Comment which will be added while release bump
--tmp dir Path to a temporary directory (default: /var/tmp)
--verbose, -V Verbose output
--no-color, -nc Disable colors in output
--help, -h Show this help message
--version, -v Show information about version
```

### Build Status
Expand Down
16 changes: 0 additions & 16 deletions SOURCES/libexec/build-local.shx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ localBuild() {

setupBuildTree

if [[ -n "$pre" ]] ; then
show "Executing pre-build script…"
# shellcheck disable=SC2091
$($pre)
fi

packSources "$spec"
processSpec "$spec"

Expand Down Expand Up @@ -286,16 +280,6 @@ localBuildProcess() {
doExit $ERROR_VALIDATE
fi

pushd "$CWD" &> /dev/null || printErrorAndExit "Can't set working dir to $CWD"

if [[ -n "$post" ]] ; then
show "Executing post-build script…"
# shellcheck disable=SC2091
$($post)
fi

popd &> /dev/null || printErrorAndExit "Can't set working dir"

[[ -n "$bump" ]] && releaseBump "$CWD/$spec"

if [[ -n "$dest_dir" ]] ; then
Expand Down
Loading

0 comments on commit d7a2de3

Please sign in to comment.