Changeset 841


Ignore:
Timestamp:
04/25/13 16:54:27 (8 years ago)
Author:
olahaye
Message:

[Makefile/rpm packaging] Reworked rpm packaging. Still need to fix %post for
systemd enabled system (normal script hangs).

Location:
branches/1.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/Makefile

    r840 r841  
    22#
    33TMPDIR = /tmp
    4 DESTDIR = /usr/local
     4
     5# Where to install
     6DESTDIR =
     7
     8# Install prefix
     9PREFIX = /usr/local
     10
     11# What is the location of the Ganglia web frontend
     12# i.e.: where to we install Job Monarch's web frontend addon
     13#
     14GANGLIA_ROOT = $(PREFIX)/ganglia
     15
     16# Where jobarchived RRDS are stored
     17JOBARCHIVE_RRDS = $(PREFIX)/jobmonarch
    518
    619# Clear this if you don't want to use ${FAKEROOT}
    720#
    821FAKEROOT = fakeroot
    9 
    10 # What is the location of the Ganglia web frontend
    11 # i.e.: where to we install Job Monarch's web frontend addon
    12 #
    13 WEBDIR = /var/www/ganglia
    1422
    1523VERSION = 1.0
     
    2533tarball:        tarball-gzip tarball-bzip
    2634
    27 tarball-gzip:   ${REQUIRED} rpmspec
     35tarball-gzip:   ${REQUIRED} ./pkg/rpm/jobmonarch.spec
    2836        mkdir -p ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}
    2937        ( rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
     
    3240        mv ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}.tar.gz ..
    3341
    34 tarball-bzip:   ${REQUIRED} rpmspec
     42tarball-bzip:   ${REQUIRED} ./pkg/rpm/jobmonarch.spec
    3543        mkdir -p ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}
    3644        ( rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
     
    3947        mv ${TMPDIR}/.monarch_buildroot/ganglia_jobmonarch-${VERSION}.tar.bz2 ..
    4048
    41 rpmspec: pkg/rpm/jobmonarch.spec.in
    42         sed -e 's/__VERSION__/$(VERSION)/g' -e 's/__RELEASE__/$(RELEASE)/g' ./pkg/rpm/jobmonarch.spec.in > jobmonarch.spec
     49rpmspec: ./pkg/rpm/jobmonarch.spec
    4350
    44 debpkgdir: pkg/deb/debian
    45         rsync -a --exclude=.svn pkg/deb/debian debian
     51./pkg/rpm/jobmonarch.spec: pkg/rpm/jobmonarch.spec.in
     52        sed -e 's/__VERSION__/$(VERSION)/g' -e 's/__RELEASE__/$(RELEASE)/g' ./pkg/rpm/jobmonarch.spec.in > ./pkg/rpm/jobmonarch.spec
     53
     54debian: pkg/deb/debian
     55        rsync -a --exclude=.svn pkg/deb/debian ./
    4656        sed -i -e 's/^Version:.*$//Version: $(VERSION)-$(RELEASE)/g' ./debian/control
    4757
     
    4959        rpmbuild -tb ../ganglia_jobmonarch-${VERSION}.tar.bz2
    5060
    51 deb: debpkgdir
     61deb: debian
    5262        dpkg-buildpackage -b
    5363
    5464install:
    55         # Files in SBIN_DIR
    56         install -m 0755 -d $(DESTDIR)/usr/sbin
    57         install -m 0755 jobmond/jobmond.py $(DESTDIR)/usr/sbin/
    58         install -m 0755 jobarchived/jobarchived.py $(DESTDIR)/usr/sbin/
    59         (cd $(DESTDIR)/usr/sbin/; ln -s jobmond.py jobmond; ln -s jobarchived.py jobarchived)
    60         #
    61         # Files specific to distros if /etc/sysconfig => rpm else (/etc/default => debian)
    62         if test -d /etc/sysconfig; then \
     65        @#
     66        @# Set the correct GANGLIA_PATH.
     67        @#
     68        @echo "\nUsing $(GANGLIA_ROOT) as Ganglia root installation path. If it's not what"
     69        @echo "you want, use make GANGLIA_ROOT=/path/to/your/ganglia/root ."
     70        @sed -i -e 's|/var/www/ganglia/|$(GANGLIA_ROOT)/|g' web/addons/job_monarch/conf.php
     71        @#
     72        @# Set the correct JOBARCHIVE_RRDS in jobarchve.conf and ganglia conf.php
     73        @#
     74        @echo "\nUsing $(JOBARCHIVE_RRDS) as jobarchive path to  store rrds files. If it's not what"
     75        @echo "you want, use make JOBARCHIVE_RRDS=/path/to/you/jobarchived/rrdsfiles ."
     76        @sed -i -e 's|/var/lib/jobarchive|$(JOBARCHIVE_RRDS)|g' jobarchived/jobarchived.conf web/addons/job_monarch/conf.php
     77        @#
     78        @# Files in SBIN_DIR
     79        @#
     80        @echo "\nInstalling jobmond.py and jobarchived.py to $(PREFIX)/sbin"
     81        @install -m 0755 -d $(DESTDIR)$(PREFIX)/sbin
     82        @install -m 0755 jobmond/jobmond.py $(DESTDIR)$(PREFIX)/sbin/
     83        @install -m 0755 jobarchived/jobarchived.py $(DESTDIR)$(PREFIX)/sbin/
     84        @(cd $(DESTDIR)$(PREFIX)/sbin/; ln -s jobmond.py jobmond; ln -s jobarchived.py jobarchived)
     85        @#
     86        @# Files specific to distros if /etc/sysconfig => rpm else (/etc/default => debian)
     87        @#
     88        @echo "\nInstalling service files in $(DESTDIR)/etc"
     89        @if test -d /etc/sysconfig; then \
    6390                install -m 0755 -d $(DESTDIR)/etc/rc.d/init.d; \
    6491                install -m 0755 pkg/rpm/init.d/jobmond $(DESTDIR)/etc/rc.d/init.d/; \
     
    75102                install -m 0755 pkg/deb/default/jobarchived $(DESTDIR)/etc/default; \
    76103        fi
    77         #
    78         # Files in /etc
    79         #
    80         install -m 0644 jobmond/jobmond.conf $(DESTDIR)/etc; \
    81         install -m 0644 jobarchived/jobarchived.conf $(DESTDIR)/etc; \
    82         #
    83         # Files in /usr/share
    84         #
    85         install -m 0755 -d $(DESTDIR)/usr/share/jobarchived/
    86         install -m 0755 jobarchived/job_dbase.sql $(DESTDIR)/usr/share/jobarchived/
    87         #
    88         # Create the /var/lib/jobarchive directory where rrds are stored.
    89         #
    90         install -m 0755 -d $(DESTDIR)/var/lib/jobarchive/
    91         #
    92         # Files for ganglia (adapt to rpm or deb or unknown ganglia packaging)
    93         #
    94         if test -d /etc/sysconfig; then \
    95                 install -m 0755 -d $(DESTDIR)/usr/share/ganglia; \
    96                 (cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)/usr/share/ganglia); \
    97         elif test -d /etc/default; then \
    98                 install -m 0755 -d $(DESTDIR)/usr/share/ganglia-webfrontend; \
    99                 (cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)/usr/share/ganglia-webfrontend); \
    100         else \
    101                 install -m 0755 -d $(DESTDIR)/$(WEBDIR); \
    102                 (cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)/$(WEBDIR)); \
    103         fi
    104 
     104        @#
     105        @# Files in /etc
     106        @#
     107        @echo "\nInstalling config files jobmond.conf jobarchived.conf in $(DESTDIR)/etc"
     108        @install -m 0644 jobmond/jobmond.conf $(DESTDIR)/etc
     109        @install -m 0644 jobarchived/jobarchived.conf $(DESTDIR)/etc
     110        @#
     111        @# Files in /usr/share
     112        @#
     113        @echo "\nInstalling job_dbase.sql in $(PREFIX)/share/jobarchived"
     114        @install -m 0755 -d $(DESTDIR)$(PREFIX)/share/jobarchived
     115        @install -m 0755 jobarchived/job_dbase.sql $(DESTDIR)$(PREFIX)/share/jobarchived/
     116        @#
     117        @# Create the /var/lib/jobarchive directory where rrds are stored.
     118        @#
     119        @echo "\nCreating the directory where RRDs will be stored: $(JOBARCHIVE_RRDS)"
     120        @install -m 0755 -d $(DESTDIR)$(JOBARCHIVE_RRDS)
     121        @#
     122        @# Files for ganglia (adapt to rpm or deb or unknown ganglia packaging)
     123        @#
     124        @echo "\nInstalling Ganglia web interface to $(GANGLIA_ROOT) ."
     125        @install -m 0755 -d $(DESTDIR)$(GANGLIA_ROOT)
     126        @(cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php . $(DESTDIR)$(GANGLIA_ROOT)/)
     127        @#
     128        @echo "\nInstallation complete.\n"
    105129
    106130deb-webfrontend:        ${REQUIRED}
    107131        mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend_${VERSION}-${RELEASE}/DEBIAN >/dev/null
    108         mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend_${VERSION}-${RELEASE}/${WEBDIR} >/dev/null
     132        mkdir -p ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend_${VERSION}-${RELEASE}/${GANGLIA_ROOT} >/dev/null
    109133        ( cd web; rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
    110         . ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend_${VERSION}-${RELEASE}/${WEBDIR} )
     134        . ${TMPDIR}/.monarch_buildroot/jobmonarch-webfrontend_${VERSION}-${RELEASE}/${GANGLIA_ROOT} )
    111135        ( cd pkg/deb/web/DEBIAN; \
    112136        rsync -a --exclude=.svn --exclude=*_test* --exclude=*-example.php \
     
    165189clean:
    166190        rm -rf ${TMPDIR}/.monarch_buildroot
    167         rm -rf ./jobmonarch.spec
     191        rm -rf ./pkg/rpm/jobmonarch.spec
    168192        rm -rf ./debian
  • branches/1.0/jobarchived/jobarchived.conf

    r839 r841  
    7676#
    7777JOB_SQL_DBASE                   : localhost/jobarchive
    78 JOB_SQL_USER            : jobarchive
     78JOB_SQL_USER                    : jobarchive
    7979
    8080#JOB_SQL_PASSWORD        :
  • branches/1.0/pkg/rpm/jobmonarch.spec.in

    r840 r841  
    5252Requires: postgresql >= 8.1.22
    5353Requires: postgresql-server >= 8.1.22
     54Requires: ganglia-gmond
    5455Requires: python >= 2.5
    55 Requires: python-rrdtool
    5656Requires: python-psycopg2
     57Requires: rrdtool-python rrdtool
    5758
    5859%description -n jobmonarch-jobarchived
     
    6768Requires: python >= 2.5
    6869Requires: pbs_python
     70Requires: ganglia-gmetad
    6971# Requires: lsf_python
    7072
     
    7577%package -n jobmonarch-webfrontend
    7678Summary: webfrontend is the ganglia webfrontend for jobmonarch.
    77 Requires: ganglia-gmetad >= 3.5.0 ganglia-web >= 3.5.7
     79Requires: ganglia-web >= 3.5.7
    7880Requires: jobmonarch-jobmond = 1.0
     81Requires: php-gd
     82Requires: php-pgsql
    7983
    8084%description -n jobmonarch-webfrontend
     
    9296rm -rf $RPM_BUILD_ROOT
    9397
    94 # Set the correct GANGLIA_PATH.
    95 sed -i -e 's|/var/www/ganglia/|%{gangliaroot}/|g' web/addons/job_monarch/conf.php
    9698
    9799# Fix rrdtool web link in footer:
    98 sed -i -e 's|http:/www.rrdtool.com/|http:/oss.oetiker.ch/rrdtool/|g' ./web/addons/job_monarch/templates/footer.tpl
    99 
    100 %__make install DESTDIR=$RPM_BUILD_ROOT
    101 
    102 # Create the directory structure.
    103 #install -m 0755 -d $RPM_BUILD_ROOT/%{_sbindir}
    104 #install -m 0755 -d $RPM_BUILD_ROOT%{_initrddir}
    105 #install -m 0755 -d $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
    106 #install -m 0755 -d $RPM_BUILD_ROOT%{gangliatemplatedir}
    107 #install -m 0755 -d $RPM_BUILD_ROOT%{gangliaaddonsdir}
    108 #install -m 0755 -d $RPM_BUILD_ROOT%{_datadir}/jobarchived/
    109 #install -m 0755 -d $RPM_BUILD_ROOT%{_sharedstatedir}/jobarchived/
    110 
    111 # Install jobmond files
    112 #install -m 0644 jobmond/jobmond.conf $RPM_BUILD_ROOT%{_sysconfdir}/
    113 #install -m 0755 jobmond/jobmond.py $RPM_BUILD_ROOT/%{_sbindir}/
    114 #install -m 0755 pkg/rpm/init.d/jobmond $RPM_BUILD_ROOT%{_initrddir}/
    115 #install -m 0755 pkg/rpm/sysconfig/jobmond $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/
    116 #(cd $RPM_BUILD_ROOT/%{_sbindir}/; ln -s jobmond.py jobmond)
    117 
    118 # Install jobarchived files
    119 #install -m 0644 jobarchived/jobarchived.conf $RPM_BUILD_ROOT%{_sysconfdir}/
    120 #install -m 0755 jobarchived/jobarchived.py $RPM_BUILD_ROOT/%{_sbindir}/
    121 #install -m 0755 pkg/rpm/init.d/jobarchived $RPM_BUILD_ROOT%{_initrddir}/
    122 #install -m 0755 pkg/rpm/sysconfig/jobarchived $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/
    123 #install -m 0755 jobarchived/job_dbase.sql $RPM_BUILD_ROOT%{_datadir}/jobarchived/
    124 #(cd $RPM_BUILD_ROOT/%{_sbindir}/; ln -s jobarchived.py jobarchived)
    125 
    126 # Install gangliaweb interface
    127 #cp %{gangliatemplatedir}/default/images/logo.jpg web/templates/job_monarch/images
    128 #cp -r web/templates/job_monarch $RPM_BUILD_ROOT%{gangliatemplatedir}/job_monarch
    129 #cp -r web/addons/job_monarch $RPM_BUILD_ROOT%{gangliaaddonsdir}/job_monarch
     100#sed -i -e 's|http:/www.rrdtool.com/|http:/oss.oetiker.ch/rrdtool/|g' ./web/addons/job_monarch/templates/footer.tpl
     101
     102# Install files in RPM_BUILD_ROOT
     103%__make install \
     104        PREFIX=/usr \
     105        GANGLIA_ROOT=%{gangliaroot} \
     106        JOBARCHIVE_RRDS=%{_sharedstatedir}/jobarchive \
     107        DESTDIR=$RPM_BUILD_ROOT
     108
    130109
    131110%clean
     
    133112
    134113%post -n jobmonarch-jobmond
    135 if [ -x /sbin/chkconfig ]; then
     114# $1 = 1 => install ($1 = 2 => upgrade)
     115if [ "$1" = 1 ]; then
    136116    /sbin/chkconfig --add jobmond
     117    /sbin/service jobmond start
     118elif [ "$1" = 2 ]; then
     119    /sbin/service jobmond restart
    137120fi
    138121
    139122%post -n jobmonarch-jobarchived
    140 if [ -x /sbin/chkconfig ]; then
    141     if [ ! -d /var/lib/pgsql/data/base ]; then
    142         /sbin/service postgresql initdb
     123# $1 = 1 => install ($1 = 2 => upgrade)
     124if [ "$1" = 1 ]; then
     125    if [ -x /usr/sbin/systemctl ]; then
     126        if [ ! -d %{_sharedstatedir}/pgsql/data/base ]; then
     127            %{_bindir}/postgresql-setup initdb
     128        fi
     129        %{_sbindir}/systemctl enable postgresql
     130        %{_sbindir}/systemctl start postgresql
     131    elif [ -x /sbin/chkconfig ]; then
     132        if [ ! -d %{_sharedstatedir}/pgsql/data/base ]; then
     133            /sbin/service postgresql initdb
     134        fi
     135        /sbin/chkconfig --level 235 postgresql on
     136        /sbin/service postgresql start
    143137    fi
    144     /sbin/service postgresql start
    145     su -l postgres -c "/usr/bin/createdb jobarchive"
    146     su -l postgres -c "/usr/bin/psql -f /usr/share/jobarchived/job_dbase.sql jobarchive"
     138    # Generate a 8 char password for the database:
     139    export DB_PASSWD=$(tr -dc A-Za-z0-9_< /dev/urandom |head -c 8 | xargs)
     140    # Set the password in the SQL script
     141    sed -i -e '/^.*modify me:.*$/d' -e 's/^#CREATE/CREATE/g' -e "s/'';/'$DB_PASSWD';/g" %{_datadir}/jobarchived/job_dbase.sql
     142    # Set the password in the jobarchived config.
     143    sed -i -s "s/^#JOB_SQL_PASSWORD.*$/JOB_SQL_PASSWORD\t\t: $DB_PASSWD/g" %{_sysconfdir}/jobarchived.conf
     144    # Create the database
     145    su -l postgres -c "%{_bindir}/createdb jobarchive"
     146    # Ccreate the tables.
     147    su -l postgres -c "%{_bindir}/psql -f %{_datadir}/jobarchived/job_dbase.sql jobarchive"
    147148    /sbin/chkconfig --add jobarchived
     149    /sbin/service jobarchived start
     150elif [ "$1" = 2 ]; then
     151    /sbin/service jobarchived restart
    148152fi
    149153
     
    174178    echo "Make sure to set your Ganglia template to previous config now"
    175179    echo ""
    176     echo "In your Ganglia conf.php, remove this line:"
    177     echo "\$template_name = \"job_monarch\";"
     180    echo "In your Ganglia conf.php, restore your previous template:"
     181    echo "\$template_name = \"default\";"
    178182fi
    179183
     
    183187%files -n jobmonarch-jobmond
    184188%doc jobmond/examples
    185 %config %{_sysconfdir}/jobmond.conf
     189%config(noreplace) %{_sysconfdir}/jobmond.conf
    186190%{_sysconfdir}/sysconfig/jobmond
    187191%{_initrddir}/jobmond
     
    191195%files -n jobmonarch-jobarchived
    192196%doc jobarchived/examples
    193 %config %{_sysconfdir}/jobarchived.conf
     197%config(noreplace) %{_sysconfdir}/jobarchived.conf
    194198%{_sysconfdir}/sysconfig/jobarchived
    195199%{_initrddir}/jobarchived
     
    207211%dir %{gangliatemplatedir}/job_monarch/images
    208212%{gangliatemplatedir}/job_monarch/images/logo.jpg
    209 %config %{gangliaaddonsdir}/job_monarch/conf.php
     213%config(noreplace) %{gangliaaddonsdir}/job_monarch/conf.php
    210214%{gangliaaddonsdir}/job_monarch/ajax-loader.gif
    211215%{gangliaaddonsdir}/job_monarch/cal.gif
     
    375379- Fix the correct gangliaroot path
    376380- Fix the correct jobarchive rrd file path.
     381- Generate a password for the database and update config files accordingly.
    377382
    378383* Tue Apr 23 2013 Olivier Lahaye <olivier.lahaye@free.fr> 1.0-2
Note: See TracChangeset for help on using the changeset viewer.