Re: Building rpms in mock

Zenon Panoussis <[email protected]>
Newsgroups gmane.mail.imap.courier.general
Message-ID <[email protected]>
I put some work in this. It got quite messy. Ugly, in fact.
The documentation of rpm macros and their workings is
absolutely superficial and sparse. The same goes for man mock.
Look at this:

--with=OPTION
     Enable configure OPTION for build. This option may be used multiple times. For example:

     --with=extra_cheese

It would only have costed 47 extra bytes to write explicitly
that "--with=OPTION does not accept option arguments", but
instead you're left to find that out by trial and error. So
--with=extra_cheese works, but --with-cheese=mozzarella does
not, and you have to use --define 'cheese mozzarella' instead.

Anyway, I got it working on the level of the specfile, but
then I run into a problem in the source code. A specfile diff
follows below. Check the comment between %install and %{__install}.

Z

***
--- courier-authlib.spec.orig   2023-12-23 03:13:10.000000000 +0000
+++ courier-authlib.spec        2023-12-23 03:39:24.677000000 +0000
@@ -9,11 +9,126 @@
  %define courier_release %{nil}
  %endif

+###
+# To pass plain with/without options to rpmbuild or mock, use --with-<option_name>, --without-<option_name>,
+# e.g. --without-authuserdb just as you would directly to ./configure .
+# To pass options with an argument to rpmbuild or mock, use --define '<option_name> <value>',
+# e.g. --define 'mailuser courier' when you mean ./configure --with-mailuser=courier, and
+# substitute underscore _ for hyphen - in option names, e.g. mysql_libs instead of mysql-libs.
+
+%if 0%{?db:1}
+%global with_db --with-db=%{db}
+%endif
+
+%if 0%{?_without_authuserdb:1}
+%global without_authuserdb --without-authuserdb
+%endif
+
+%if 0%{?_without_authpam:1}
+%global without_authpam --without-authpam
+%endif
+
+%if 0%{?_without_authldap:1}
+%global without_authldap --without-authldap
+%endif
+
+%if 0%{?authldaprc:1}
+%global with_authldaprc --with-authldaprc=%{authldaprc}
+%endif
+
+%if 0%{?_without_authpwd:1}
+%global without_authpwd --without-authpwd
+%endif
+
+%if 0%{?_without_authshadow:1}
+%global without_authshadow --without-authshadow
+%endif
+
+%if 0%{?authpgsqlrc:1}
+%global with_authpgsqlrc --with-authpgsqlrc=%{authpgsqlrc}
+%endif
+
+%if 0%{?_without_authpgsql:1}
+%global without_authpgsql --without-authpgsql
+%endif
+
+%if 0%{?pgsql_libs:1}
+%global with_pgsql_libs --with-pgsql-libs=%{pgsql_libs}
+%endif
+
+%if 0%{?pgsql_includes:1}
+%global with_pgsql_includes --with-pgsql-includes=%{pgsql_includes}
+%endif
+
+%if 0%{?authmysqlrc:1}
+%global with_authmysqlrc --with-authmysqlrc=%{authmysqlrc}
+%endif
+
+%if 0%{?_without_authmysql}
+%global without_authmysql --without-authmysql
+%endif
+
+%if 0%{?mysql_libs:1}
+%global with_mysql_libs --with-mysql-libs=%{mysql_libs}
+%endif
+
+%if 0%{?mysql_includes:1}
+%global with_mysql_includes --with-mysql-includes=%{mysql_includes}
+%endif
+
+%if 0%{?authsqliterc:1}
+%global with_authsqliterc --with-authsqliterc=%{authsqliterc}
+%endif
+
+%if 0%{?_without_authsqlite}
+%global without_authsqlite --without-authsqlite
+%endif
+
+%if 0%{?sqlite_libs:1}
+%global with_sqlite_libs --with-sqlite-libs=%{sqlite_libs}
+%endif
+
+%if 0%{?sqlite_includes:1}
+%global with_sqlite_includes --with-mysql-includes=%{sqlite_includes}
+%endif
+
+%if 0%{?_without_authcustom}
+%global without_authcustom --without-authcustom
+%endif
+
+%if 0%{?pipeprog:1}
+%global with_pipeprog --with-pipeprog=%{pipeprog}
+%endif
+
+%if 0%{?_without_authpipe:1}
+%global without_authpipe --without-authpipe
+%endif
+
+%if 0%{?authdaemonrc:1}
+%global with_authdaemonrc --with-authdaemonrc=%{authdaemonrc}
+%endif
+
+%if 0%{?mailuser:1}
+%global with_mailuser --with-mailuser=%{mailuser}
+%global mailuser %{mailuser}
+%else
+%global with_mailuser --with-mailuser=courier
+%global mailuser courier
+%endif
+
+%if 0%{?mailgroup:1}
+%global with_mailgroup --with-mailgroup=%{mailgroup}
+%global mailgroup %{mailgroup}
+%else
+%global with_mailgroup --with-mailgroup=courier
+%global mailgroup courier
+%endif
+
  ################################################################################

  Name:           courier-authlib
  Version:        0.72.0
-Release:        1%{?dist}%{?courier_release}
+Release:        2%{?dist}%{?courier_release}
  Summary:        Courier authentication library

  Group:          System Environment/Daemons
@@ -40,10 +155,16 @@
  BuildRequires:     redhat-rpm-config
  BuildRequires:      courier-unicode-devel
  BuildRequires:      %{__make}
-
+BuildRequires:      procps-ng
  BuildRequires:      %{_includedir}/ltdl.h
+BuildRequires:      glibc-common
+BuildRequires:      shadow-utils
+
+# Using the distro macros instead of edhat-release etc, catches the
+# derivatives, e.g. alma and rocky. BuildRequires /usr/bin/ps and
+# procps-ng overlap in this case.
+%if ( 0%{?rhel} || 0%{?fedora} )

-%if 0%(rpm -q redhat-release >/dev/null 2>&1 || rpm -q fedora-release >/dev/null 2>&1 || exit 0; echo "1")
  BuildRequires:      redhat-rpm-config
  BuildRequires:      /usr/bin/ps
  %endif
@@ -165,13 +286,51 @@
  %setup -q

  %build
-%configure
+%configure \
+   %{?with_db} \
+   %{?without_authuserdb} \
+   %{?without_authpam} \
+   %{?without_authldap} \
+   %{?with_authldaprc} \
+   %{?without_authpwd} \
+   %{?without_authshadow} \
+   %{?with_authpgsqlrc} \
+   %{?without_authpgsql} \
+   %{?with_pgsql_libs} \
+   %{?with_pgsql_includes} \
+   %{?with_authmysqlrc} \
+   %{?without_authmysql} \
+   %{?with_mysql_libs} \
+   %{?with_mysql_includes} \
+   %{?with_authsqliterc} \
+   %{?without_authsqlite} \
+   %{?with_sqlite_libs} \
+   %{?with_sqlite_includes} \
+   %{?without_authcustom} \
+   %{?with_pipeprog} \
+   %{?without_authpipe} \
+   %{?with_authdaemonrc} \
+   %{?with_mailuser} \
+   %{?with_mailgroup}
+
  %{__make} -s %{_smp_mflags}

  %install
  rm -rf $RPM_BUILD_ROOT
  MAKEFLAGS= %{__make} -j 1 install DESTDIR=$RPM_BUILD_ROOT
  %{__rm} -f $RPM_BUILD_ROOT%{_libdir}/courier-authlib/*.a
+
+# There is a getent or similar somewhere in the install scripts, that
+# tries to find the uid:gid of the build's mailuser:mailgroup. If the
+# mailuser:mailgroup don't exist, install fails. Therefore we have to
+# create the mailuser:mailgroup before installing:
+
+getent group %{mailgroup} > /dev/null || groupadd -r -g 900 %{mailgroup}
+getent passwd %{mailuser} > /dev/null || useradd -r -g %{mailgroup} -u 900 -d %{_exec_prefix}/lib/courier -s /sbin/nologin -c "Courier mail" %{mailuser}
+
+# However, in mock this results in "permission denied" and install
+# fails anyway.
+
  %{__install} -m 555 sysconftool $RPM_BUILD_ROOT%{_libexecdir}/courier-authlib

  ./courierauthconfig --configfiles >configtmp
@@ -223,6 +382,12 @@
          $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/courier-authlib
  %endif

+
+%pre
+getent group %{mailgroup} > /dev/null || groupadd -r -g 900 %{mailgroup}
+getent passwd %{mailuser} > /dev/null || useradd -r -g %{mailgroup} -u 900 -d %{_exec_prefix}/lib/courier -s /sbin/nologin -c "Courier mail" %{mailuser}
+exit 0
+
  %post
  %{_libexecdir}/courier-authlib/sysconftool %{_sysconfdir}/authlib/*.dist >/dev/null
  %if 1
@@ -261,7 +426,6 @@
  %clean
  rm -rf $RPM_BUILD_ROOT

-
  %files -f configfiles.base
  %if 1
  %attr(644,root,root) /lib/systemd/system/*



-- 
Слава Україні!
Путин хуйло!


_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.