-
Notifications
You must be signed in to change notification settings - Fork 4
Use rpm macros to avoid postinst failures in a container #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+52
−48
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
788e18d
Use rpm macros to avoid postinst failures in a container
jakub-id b154ce2
Update metaproxy.spec
adamdickmeiss 9557094
Update metaproxy.spec
adamdickmeiss 2d56cc0
SERVER_HOME by defualt /var/lib/metaproxy
adamdickmeiss f16ddca
Do not ignore errors during install/upgrade
adamdickmeiss b6a09ca
Merge remote-tracking branch 'origin/master' into container-systemd
adamdickmeiss 195ab8a
spawn metaproxy with type=exec
adamdickmeiss c6c7a57
Honor reload
adamdickmeiss ade0b29
Build require systemd-rpm-macros
adamdickmeiss 917cedb
Ensure systemd macros are present at build
adamdickmeiss 79040a6
Update metaproxy.spec
adamdickmeiss c4b7dbf
Update metaproxy.spec
adamdickmeiss bbfb617
Update rpm/metaproxy.service
adamdickmeiss 156c065
use rhel in test
adamdickmeiss 75308d3
Merge remote-tracking branch 'origin/container-systemd' into containe…
adamdickmeiss 5a880d5
Update metaproxy.spec
adamdickmeiss 7992d04
Update metaproxy.spec
adamdickmeiss a9e6edc
logrotate: handle systemd not running
adamdickmeiss 7040848
Update metaproxy.spec
adamdickmeiss ee9caa3
Update metaproxy.spec
adamdickmeiss e5be59d
Update Requires, URL
adamdickmeiss 2fc41e9
Add CentOS 10
adamdickmeiss 02b36e1
No quoting
adamdickmeiss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| DEBIAN_DIST="bullseye bookworm trixie" | ||
| UBUNTU_DIST="focal jammy noble" | ||
| CENTOS_DIST="centos7 centos8 centos9" | ||
| CENTOS_DIST="centos7 centos8 centos9 centos10" | ||
| VERSION=1.22.2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| %define idmetaversion %(. ./IDMETA; echo $VERSION) | ||
|
|
||
| Summary: Z39.50/SRU router | ||
| Name: metaproxy | ||
| Version: %{idmetaversion} | ||
|
|
@@ -9,11 +10,20 @@ Vendor: Index Data ApS <[email protected]> | |
| Source: metaproxy-%{version}.tar.gz | ||
| BuildRoot: %{_tmppath}/%{name}-%{version}-root | ||
| Prefix: %{_prefix} /etc/metaproxy | ||
| %if 0%{?rhel} >= 9 | ||
| BuildRequires: systemd-rpm-macros | ||
| %else | ||
| BuildRequires: systemd | ||
| %endif | ||
| BuildRequires: pkgconfig, libyaz5-devel >= 5.35.0, libyazpp7-devel >= 1.9.0 | ||
| BuildRequires: libxslt-devel, boost-devel | ||
| Conflicts: cf-engine <= 2.12.5 | ||
| Packager: Adam Dickmeiss <[email protected]> | ||
| URL: http://www.indexdata.com/metaproxy | ||
| URL: https://www.indexdata.com/metaproxy | ||
|
|
||
| # Use systemd macros for safe scriptlets | ||
| %{?systemd_requires} | ||
adamdickmeiss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Requires: libmetaproxy6 = %{version} | ||
| Provides: metaproxy6 | ||
|
|
||
|
|
@@ -30,15 +40,15 @@ Metaproxy documentation. | |
| %package -n libmetaproxy6 | ||
| Summary: Metaproxy library | ||
| Group: Libraries | ||
| Requires: libyazpp7 >= 1.8.0, libyaz5 >= 5.30.0 | ||
| Requires: libyazpp7 >= 1.9.0, libyaz5 >= 5.35.0 | ||
|
|
||
| %description -n libmetaproxy6 | ||
| The Metaproxy libraries. | ||
|
|
||
| %package -n libmetaproxy6-devel | ||
| Summary: Metaproxy development package | ||
| Group: Development/Libraries | ||
| Requires: libmetaproxy6 = %{version}, libyazpp6-devel, boost-devel | ||
| Requires: libmetaproxy6 = %{version}, libyazpp7-devel, boost-devel | ||
| Conflicts: libmetaproxy3-devel, libmetaproxy4-devel, libmetaproxy5-devel | ||
|
|
||
| %description -n libmetaproxy6-devel | ||
|
|
@@ -48,7 +58,6 @@ Development libraries and include files for the Metaproxy package. | |
| %setup | ||
|
|
||
| %build | ||
|
|
||
| CFLAGS="$RPM_OPT_FLAGS" \ | ||
| ./configure --prefix=%{_prefix} --libdir=%{_libdir} --mandir=%{_mandir} \ | ||
| --enable-shared --with-yazpp=pkg | ||
|
|
@@ -88,7 +97,6 @@ rm -fr ${RPM_BUILD_ROOT} | |
| %dir %{_libdir}/metaproxy6/modules | ||
|
|
||
| %post -n libmetaproxy6 -p /sbin/ldconfig | ||
|
|
||
| %postun -n libmetaproxy6 -p /sbin/ldconfig | ||
|
|
||
| %files -n libmetaproxy6-devel | ||
|
|
@@ -121,46 +129,43 @@ rm -fr ${RPM_BUILD_ROOT} | |
| %config(noreplace) /etc/sysconfig/metaproxy | ||
|
|
||
| %post | ||
| . /etc/metaproxy/metaproxy.user | ||
| . /etc/metaproxy/metaproxy.user 2>/dev/null | ||
|
|
||
| # 1. create group if not existing | ||
| if ! getent group | grep -q "^$SERVER_GROUP:" ; then | ||
| echo -n "Adding group $SERVER_GROUP.." | ||
| groupadd -r $SERVER_GROUP 2>/dev/null ||true | ||
| echo "..done" | ||
| fi | ||
| # 2. create user if not existing | ||
| if ! getent passwd | grep -q "^$SERVER_USER:"; then | ||
| echo -n "Adding system user $SERVER_USER.." | ||
| useradd \ | ||
| -r \ | ||
| -s /sbin/nologin \ | ||
| -c "$SERVER_NAME" \ | ||
| -d $SERVER_HOME \ | ||
| -g $SERVER_GROUP \ | ||
| $SERVER_USER 2>/dev/null || true | ||
| echo "..done" | ||
| # Ensure group exists | ||
| if [ -n "$SERVER_GROUP" ] && ! getent group | grep -q "^$SERVER_GROUP:" ; then | ||
| groupadd -r "$SERVER_GROUP" 2>/dev/null | ||
| fi | ||
|
|
||
| if test ! -d $SERVER_HOME; then | ||
| mkdir $SERVER_HOME | ||
| chown $SERVER_USER:$SERVER_GROUP $SERVER_HOME | ||
| # Ensure user exists | ||
| if [ -n "$SERVER_USER" ] && ! getent passwd | grep -q "^$SERVER_USER:" ; then | ||
| useradd -r -s /sbin/nologin -c "${SERVER_NAME:-Metaproxy}" \ | ||
| -d "${SERVER_HOME:-/var/lib/metaproxy}" \ | ||
adamdickmeiss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -g "${SERVER_GROUP:-metaproxy}" \ | ||
| "$SERVER_USER" || true | ||
| fi | ||
|
|
||
| if [ $1 = 1 ]; then | ||
| /usr/bin/systemctl daemon-reload > /dev/null 2>&1 | ||
| /usr/bin/systemctl enable metaproxy > /dev/null 2>&1 | ||
| /usr/bin/systemctl start metaproxy > /dev/null 2>&1 | ||
| else | ||
| /usr/bin/systemctl daemon-reload > /dev/null 2>&1 | ||
| /usr/bin/systemctl restart metaproxy > /dev/null 2>&1 | ||
| # Ensure home directory exists | ||
| if [ -n "$SERVER_HOME" ] && [ -n "$SERVER_USER" ] && [ -n "$SERVER_GROUP" ] && [ ! -d "$SERVER_HOME" ]; then | ||
| mkdir -p "$SERVER_HOME" || : | ||
| chown "$SERVER_USER:$SERVER_GROUP" "$SERVER_HOME" 2>/dev/null || : | ||
| fi | ||
|
|
||
| # Safe systemd handling (won't fail in containers) | ||
| %systemd_post metaproxy.service | ||
|
|
||
| %preun | ||
| if [ $1 = 0 ]; then | ||
| if test -f /etc/system/systemd/metaproxy.service; then | ||
| /usr/bin/systemctl stop metaproxy> /dev/null 2>&1 | ||
| fi | ||
| . /etc/metaproxy/metaproxy.user | ||
| test -d $SERVER_HOME && rm -fr $SERVER_HOME | ||
| userdel $SERVER_USER | ||
| %systemd_preun metaproxy.service | ||
|
|
||
adamdickmeiss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # In %preun, $1 is 0 on uninstall and 1 on upgrade; only remove user/home on uninstall. | ||
| if [ $1 -eq 0 ]; then | ||
| . /etc/metaproxy/metaproxy.user 2>/dev/null || : | ||
| if [ -n "$SERVER_HOME" ] && [ -d "$SERVER_HOME" ]; then | ||
| rm -rf "$SERVER_HOME" || : | ||
| fi | ||
| if [ -n "$SERVER_USER" ]; then | ||
| userdel "$SERVER_USER" 2>/dev/null || : | ||
| fi | ||
| fi | ||
|
|
||
| %postun | ||
| %systemd_postun_with_restart metaproxy.service | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # Metaproxy user information | ||
| SERVER_HOME=/var/metaproxy | ||
| SERVER_HOME=/var/lib/metaproxy | ||
| SERVER_USER=metaproxy | ||
| SERVER_NAME="Metaproxy user" | ||
| SERVER_GROUP=metaproxy |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.