Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Contributions to ELOG  Not logged in ELOG logo
Entry   RPM build process enhancements, posted by Laurent Jean-Rigaud on Fri Feb 21 19:05:18 2020 elog_patch_for_4936b76915d63a9ebb3788d50d62faadf49cdb6b.patch
    Reply   Re: RPM build process enhancements, posted by Laurent Jean-Rigaud on Mon Mar 2 14:31:12 2020 elog-git_dd35f04ec8effce1c12927078a9efb59822ceb3f-add_use_options.diff
       Reply   Re: Re: RPM build process enhancements, posted by Laurent Jean-Rigaud on Wed Mar 4 18:40:57 2020 elog.spec.template
Message ID: 150     Entry time: Fri Feb 21 19:05:18 2020     Reply to this: 151
Author: Laurent Jean-Rigaud 
Author Email: lollspam@free.fr 
Category: Other 
Subject: RPM build process enhancements 
Status: Stable 
Last Revision: Fri Feb 21 19:14:53 2020 by Laurent Jean-Rigaud 

Hi Stefan,

I enclosed a patch for RPM build process available on GIT.

changes :

  • rpmbuild :
    • checks if provider or custom build (the rm/mv are done on your computers only :-))
    • call rpmbuild with version / release given as parameters
  • elog.spec :
    • last changelog entry date is set to build date
    • build with debug for debuginfo rpms (product rpms are normally automatically strimmed)
    • elog.init call /etc/ini.d/functions for RHEL/Centos/Fedora/? dists

 

Todo:

  • add RPMbuild options for ldap/pam/...
  • enclosed git log in changelog automatically (the dream :-))
Attachment 1: elog_patch_for_4936b76915d63a9ebb3788d50d62faadf49cdb6b.patch  4 kB  | Hide | Hide all
diff --git a/buildrpm b/buildrpm
index 9d21f4a..dba7067 100755
--- a/buildrpm
+++ b/buildrpm
@@ -12,7 +12,7 @@ set release = $argv[2]
 set dir = /tmp/elog-$version
 set archive = elog-$version-$release.tar.gz
 
-perl -wapi.bak -e 's&^(Version:\s+).*$&${1}'"${version}"'&;s&^(Release:\s+).*$&${1}'"${release}"'&;' elog.spec
+#perl -wapi.bak -e 's&^(Version:\s+).*$&${1}'"${version}"'&;s&^(Release:\s+).*$&${1}'"${release}"'&;' elog.spec
 
 # create temporary directory
 rm -Rf $dir
@@ -68,19 +68,33 @@ rm -Rf $dir
 
 # transfer archive
 echo Transfer archive...
-cp /tmp/$archive ~ritt/html/elog/download/tar/
-cp /tmp/$archive ~ritt/html/elog/download/tar/elog-latest.tar.gz
 cp /tmp/$archive ~/rpmbuild/SOURCES/elog-$version.tar.gz
-cd ~ritt/elog
-cp -f doc/ChangeLog ~ritt/html/elog/download/ChangeLog
+# If Stefan...
+if ( -d /home/ritt ) then
+  echo "Manager mode"
+  if ( -d ~ritt/html/elog/download/tar ) then
+    cp /tmp/$archive ~ritt/html/elog/download/tar/
+    cp /tmp/$archive ~ritt/html/elog/download/tar/elog-latest.tar.gz
+    cd ~ritt/elog
+    cp -f doc/ChangeLog ~ritt/html/elog/download/ChangeLog
+  endif
+endif
+cd -
 rm -f /tmp/$archive
 
+echo Cleanup $version-$release rpms
+rm -f ~/rpmbuild/RPMS/*/elog*${version}-${release}*.rpm
+rm -f ~/rpmbuild/SRPMS/elog*${version}-${release}*.rpm
 # building RPMs
-echo Build RPMs...
-rm -f ~/rpmbuild/RPMS/x86_64/*
-rm -f ~/rpmbuild/SRPMS/*
-rpmbuild -ba elog.spec || exit $?
-cp ~/rpmbuild/RPMS/x86_64/elog*rpm ~ritt/html/elog/download/RPMS/
-cp ~/rpmbuild/RPMS/x86_64/elog-$version-$release.x86_64.rpm ~ritt/html/elog/download/RPMS/elog-latest.x86_64.rpm
-cp ~/rpmbuild/SRPMS/elog*rpm ~ritt/html/elog/download/SRPMS/
-cp ~/rpmbuild/SRPMS/elog-$version-$release.src.rpm ~ritt/html/elog/download/SRPMS/elog-latest.src.rpm
+echo Build RPMs..
+rpmbuild -ba --define "version ${version}" --define "release ${release}" elog.spec || exit $?
+
+# If Stefan...
+if ( -d /home/ritt ) then
+  if ( -d ~ritt/html/elog/download/tar ) then
+    cp ~/rpmbuild/RPMS/x86_64/elog*rpm ~ritt/html/elog/download/RPMS/
+    cp ~/rpmbuild/RPMS/x86_64/elog-$version-$release.x86_64.rpm ~ritt/html/elog/download/RPMS/elog-latest.x86_64.rpm
+    cp ~/rpmbuild/SRPMS/elog*rpm ~ritt/html/elog/download/SRPMS/
+    cp ~/rpmbuild/SRPMS/elog-$version-$release.src.rpm ~ritt/html/elog/download/SRPMS/elog-latest.src.rpm
+  endif
+endif
diff --git a/elog.spec b/elog.spec
index 16add8f..8397eab 100755
--- a/elog.spec
+++ b/elog.spec
@@ -1,9 +1,13 @@
-# OpenSSH privilege separation requires a user & group ID
+# ELOG weblog application
+# rpmbuild -ba --define 'version 3.1.4' --define 'release 2' --define "date $(LC_TIME=En date '+%a %b %d %Y')" elog.spec
+ 
+#define	date	$(LC_TIME=En date '+%a %b %d %Y')      
+%define build_timestamp %(LC_TIME=En date '+%a %b %d %Y')
 
 Name:       elog
 Summary:    elog is a standalone electronic web logbook
-Version:    3.1.4
-Release:    2
+Version:    %version
+Release:    %release%{?dist}
 License:    GPL
 Group:      Applications/Networking
 Source:     http://elog.psi.ch/elog/download/elog-%{version}.tar.gz
@@ -41,6 +45,8 @@ access control, etc. Moreover, a single server can host several weblogs, and
 each weblog can be totally different from the rest. 
 
 %changelog
+* %{build_timestamp} Stefan Ritt <stefan.ritt@psi.ch> %version-%release
+- Updated from git 
 * Wed Sep 26 2018 Stefan Ritt <stefan.ritt@psi.ch>
 - Made adjustments for new elog server and RH7
 * Fri Aug 29 2014 Stefan Ritt <stefan.ritt@psi.ch>
@@ -72,7 +78,7 @@ each weblog can be totally different from the rest.
    -g elog -M -r elog 2>/dev/null || :
 
 %build
-make
+make CFLAGS='-O3 -funroll-loops -fomit-frame-pointer -W -Wall -Wno-deprecated-declarations -Imxml -g'
 sed "s#\@PREFIX\@#%{prefix}#g" elogd.init_template > elogd.init
 
 %install
diff --git a/elogd.init b/elogd.init
index 5d4e7ee..e04143c 100644
--- a/elogd.init
+++ b/elogd.init
@@ -6,6 +6,9 @@
 # config: /usr/local/elog/elogd.cfg
 # pidfile: /var/run/elogd.pid
 
+# RHEL
+[ -f /etc/init.d/functions ] && . /etc/init.d/functions
+
 # Check for the config file
 if [ ! -f /usr/local/elog/elogd.cfg ]; then
     exit 0
diff --git a/elogd.init_template b/elogd.init_template
index e94b5d7..bb1b330 100755
--- a/elogd.init_template
+++ b/elogd.init_template
@@ -6,6 +6,9 @@
 # config: @PREFIX@/elog/elogd.cfg
 # pidfile: /var/run/elogd.pid
 
+# RHEL
+[ -f /etc/init.d/functions ] && . /etc/init.d/functions
+
 # Check for the config file
 if [ ! -f @PREFIX@/elog/elogd.cfg ]; then
     exit 0
ELOG V3.1.5-fe60aaf