Skip to content

Commit

Permalink
Merge pull request #25 from stfc/packaging
Browse files Browse the repository at this point in the history
Rework Packaging
  • Loading branch information
Oli-Rest authored Jul 24, 2024
2 parents 8e0539e + 25f241f commit 1375e97
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 310 deletions.
132 changes: 69 additions & 63 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name = mrepo
version = $(shell awk '/^Version: / {print $$2}' $(name).spec)
name = mrepo-lite
version = $(shell git describe --dirty --broken)
date = $(shell date +%Y%m%d%H%M)

### Get the branch information from git
git_ref = $(shell git symbolic-ref -q HEAD)
git_branch ?= $(lastword $(subst /, ,$(git_ref)))
git_branch ?= HEAD

prefix = /usr
sysconfdir = /etc
bindir = $(prefix)/bin
Expand All @@ -17,66 +12,77 @@ mandir = $(datadir)/man
localstatedir = /var

cachedir = $(localstatedir)/cache/mrepo
srcdir = $(localstatedir)/mrepo
wwwdir = $(localstatedir)/www/mrepo

DESTDIR=
OFFICIAL=

distversion=$(version)
rpmrelease=
ifeq ($(OFFICIAL),)
distversion=$(version)-git$(date)
rpmrelease=.git$(date)
endif

all:
@echo "There is nothing to be build. Try install !"

install:
install -Dp -m0755 mrepo.py $(DESTDIR)$(bindir)/mrepo
[ ! -f $(DESTDIR)$(sysconfdir)/mrepo.conf ] && install -D -m0600 config/mrepo.conf $(DESTDIR)$(sysconfdir)/mrepo.conf || :
install -d -m0755 $(DESTDIR)$(sysconfdir)/mrepo.conf.d/

install -d -m0755 $(DESTDIR)$(srcdir)/all/
install -d -m0755 $(DESTDIR)$(wwwdir)
install -d -m0755 $(DESTDIR)$(cachedir)
docdir = $(datadir)/doc/$(name)-$(version)

[ "$(DESTDIR)" -o ! -f "$(DESTDIR)$(sysconfdir)/cron.d/mrepo" ] && install -Dp -m0644 config/mrepo.cron $(DESTDIR)$(sysconfdir)/cron.d/mrepo || :

install -Dp -m0644 config/mrepo.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/mrepo

@if [ -z "$(DESTDIR)" -a -x "/sbin/chkconfig" ]; then \
/sbin/chkconfig --add mrepo; \
elif [ -z "$(DESTDIR)" -a -x "$(sbindir)/chkconfig" ]; then \
$(sbindir)/chkconfig --add mrepo; \
fi
.PHONY: all
all: clean rpm deb

docs:
make -C docs

dist: clean
sed -i \
-e 's#^Source:.*#Source: $(name)-$(distversion).tar.bz2#' \
-e 's#^Version:.*#Version: $(version)#' \
-e 's#^\(Release: *[0-9]\+\)#\1$(rpmrelease)#' \
$(name).spec
git ls-tree -r --name-only --full-tree $(git_branch) | \
tar -cjf $(name)-$(distversion).tar.bz2 --transform='s,^,$(name)-$(version)/,S' --files-from=-
git checkout $(name).spec

rpm: dist
rpmbuild -tb --clean --rmspec \
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
--define "debug_package %{nil}" \
--define "_rpmdir %(pwd)" \
$(name)-$(distversion).tar.bz2

srpm: dist
rpmbuild -ts --clean --rmsource --rmspec \
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
--define "_srcrpmdir ../" \
$(name)-$(distversion).tar.bz2

dist:
mkdir -p dist/mrepo.conf.d dist/cache
cp -f mrepo.py dist/mrepo
sed -i 's/#version#/$(version)/' dist/mrepo

.PHONY: package-%
package-%: dist
fpm \
--verbose \
\
--input-type dir \
--output-type "$(lastword $(subst -, ,$@))" \
--package dist/ \
\
--name "$(name)" \
--version "$(version)" \
--iteration 1 \
--license GPL \
--epoch "$(shell date +%s)" \
--architecture noarch \
--vendor 'Science and Technology Facilties Council' \
--url 'https://github.com/stfc/mrepo-lite' \
--description 'mrepo-lite is a tool for mirroring upstream software repositories.' \
--category 'System Environment/Base' \
\
--depends 'createrepo' \
--depends 'python >= 2.7' \
--conflicts yam \
--conflicts mrepo \
\
--config-files $(sysconfdir)/cron.d/mrepo \
--config-files $(sysconfdir)/logrotate.d/mrepo \
--config-files $(sysconfdir)/mrepo.conf \
--config-files $(sysconfdir)/mrepo.conf.d \
\
--directories $(sysconfdir)/mrepo.conf.d \
--directories $(docdir) \
--directories $(cachedir) \
\
dist/mrepo=$(bindir)/mrepo \
dist/cache=$(cachedir) \
dist/mrepo.conf.d=$(sysconfdir)/ \
config/mrepo.conf=$(sysconfdir)/mrepo.conf \
config/mrepo.cron=$(sysconfdir)/cron.d/mrepo \
config/mrepo.logrotate=$(sysconfdir)/logrotate.d/mrepo \
\
config/mrepo-example.conf=$(docdir)/ \
config/mrepo-complex.conf=$(docdir)/ \
docs/=$(docdir) \
AUTHORS=$(docdir) \
ChangeLog=$(docdir) \
COPYING=$(docdir) \
README=$(docdir) \
THANKS=$(docdir) \
TODO=$(docdir)

.PHONY: rpm
rpm: package-rpm

.PHONY: deb
deb: package-deb

.PHONY: clean
clean:
rm -f README*.html
rm -rf dist/
5 changes: 2 additions & 3 deletions mrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@
import urlparse
import urllib

__version__ = "$Revision$"
# $Source$
__version__ = "#version#"

VERSION = "0.8.9"
VERSION = __version__

ARCHS = {
'alpha': ('alpha', 'alphaev5', 'alphaev56', 'alphaev6', 'alphaev67'),
Expand Down
170 changes: 0 additions & 170 deletions mrepo.spec

This file was deleted.

Loading

0 comments on commit 1375e97

Please sign in to comment.