createrepo makefiles patch for byte compiling .py file
Gareth Armstrong <[email protected]>
| Newsgroups | gmane.linux.rpm.metadata |
|---|---|
| Message-ID | <[email protected]> |
Hello Folks,
I would like to contribute the attached patch to enable the createrepo
tarball to properly byte-compile its *.py components.
Let me explain the context. While packaging createrepo for our group on
my FC5 box, everything goes honky-dory and we have a package containing
the following:
/usr/bin/createrepo
/usr/share/createrepo
/usr/share/createrepo/dumpMetadata.py
/usr/share/createrepo/dumpMetadata.pyc
/usr/share/createrepo/dumpMetadata.pyo
/usr/share/createrepo/genpkgmetadata.py
/usr/share/createrepo/genpkgmetadata.pyc
/usr/share/createrepo/genpkgmetadata.pyo
/usr/share/doc/createrepo-0.4.4
/usr/share/doc/createrepo-0.4.4/ChangeLog
/usr/share/doc/createrepo-0.4.4/README
/usr/share/man/man8/createrepo.8.gz
But this is not due to the makefiles in the tarball but rather
"/usr/lib/rpm/brp-python-bytecompile".
This I found out, when I tried to rebuild my src rpm on both Rhel3 and
Rhel4 and ended up with
/usr/bin/createrepo
/usr/share/createrepo
/usr/share/createrepo/dumpMetadata.py
/usr/share/createrepo/genpkgmetadata.py
/usr/share/doc/createrepo-0.4.4
/usr/share/doc/createrepo-0.4.4/ChangeLog
/usr/share/doc/createrepo-0.4.4/README
/usr/share/man/man8/createrepo.8.gz
For some reason, brp-python-bytecompile doesn't seem to fire on either
Rhel 3 or 4.
So I modified the top-level Makefile to byte-compile all *.py file as
per the original intention and now it generates .pyc files. I also
modified it to generate .pyo files. This allows us fall in with the
python packaging guidelines as currently suggested by Fedora Extras. So
the files section of spec file can now become:
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*.py
%{_datadir}/%{name}/*.pyc
%ghost %{_datadir}/%{name}/*.pyo
instead of:
dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
Along the way, I cleaned up the makefiles in the bin and doc dirs. This
might not be to everyone's taste but it makes things more consistent and
all targets now work again (daily, etc..). Anyway, it would be nice to
see this applied or a variant of it.
All the best,
Gareth
--
_______________________________________________
Rpm-metadata mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
createrepo-0.4.4-makefiles.patch
(text/x-patch, 5.8 KB)
=== modified file 'Makefile'
--- old/Makefile 2006-08-09 08:24:36 +0000
+++ new/Makefile 2006-08-10 11:16:31 +0000
@@ -18,7 +18,7 @@
docdir =
includedir = ${prefix}/include
oldincludedir = /usr/include
-mandir = ${prefix}/share/man
+mandir = ${datadir}/man
pkgdatadir = $(datadir)/$(PACKAGE)
pkglibdir = $(libdir)/$(PACKAGE)
@@ -26,8 +26,7 @@
top_builddir =
# all dirs
-DIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(sysconfdir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
-
+DIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
# INSTALL scripts
INSTALL = install -p --verbose
@@ -40,47 +39,50 @@
SUBDIRS = bin docs
MODULES = $(srcdir)/genpkgmetadata.py \
- $(srcdir)/dumpMetadata.py
-
-.SUFFIXES: .py .pyc
-.py.pyc:
- python -c "import py_compile; py_compile.compile($*.py)"
-
-
-all: $(MODULES)
+ $(srcdir)/dumpMetadata.py
+
+all:
+ echo "Nothing to do in $(srcdir)"
for subdir in $(SUBDIRS) ; do \
- $(MAKE) -C $$subdir VERSION=$(VERSION) PACKAGE=$(PACKAGE) DESTDIR=$(DESTDIR); \
+ $(MAKE) -C $$subdir all VERSION=$(VERSION) PACKAGE=$(PACKAGE) DESTDIR=$(DESTDIR); \
done
+
check:
pychecker $(MODULES) || exit 0
-install: all installdirs
- $(INSTALL_MODULES) $(srcdir)/$(MODULES) $(DESTDIR)$(pkgdatadir)
+
+install: installdirs
+ $(INSTALL_MODULES) $(MODULES) $(DESTDIR)$(pkgdatadir)
for subdir in $(SUBDIRS) ; do \
- $(MAKE) -C $$subdir install VERSION=$(VERSION) PACKAGE=$(PACKAGE); \
+ $(MAKE) -C $$subdir install VERSION=$(VERSION) PACKAGE=$(PACKAGE) DESTDIR=$(DESTDIR); \
done
+ python -c "import compileall; compileall.compile_dir('$(DESTDIR)$(pkgdatadir)', 1)"
+ python -O -c "import compileall; compileall.compile_dir('$(DESTDIR)$(pkgdatadir)', 1)"
+
installdirs:
for dir in $(DIRS) ; do \
- $(INSTALL_DIR) $$dir ; \
+ $(INSTALL_DIR) $$dir ; \
done
uninstall:
for module in $(MODULES) ; do \
- $(RM) $(pkgdatadir)/$$module ; \
+ $(RM) $(DESTDIR)$(pkgdatadir)/$$module* ; \
done
for subdir in $(SUBDIRS) ; do \
$(MAKE) -C $$subdir uninstall VERSION=$(VERSION) PACKAGE=$(PACKAGE); \
done
+
clean:
- $(RM) *.pyc *.pyo
+ $(RM) *.pyc *.pyo
for subdir in $(SUBDIRS) ; do \
$(MAKE) -C $$subdir clean VERSION=$(VERSION) PACKAGE=$(PACKAGE); \
done
+
distclean: clean
$(RM) -r .libs
$(RM) core
@@ -89,6 +91,7 @@
$(MAKE) -C $$subdir distclean VERSION=$(VERSION) PACKAGE=$(PACKAGE); \
done
+
mostlyclean:
$(MAKE) clean
@@ -111,6 +114,7 @@
cd $$olddir
$(RM) -r .disttmp
+
daily:
olddir=`pwd`; \
distdir=$(PACKAGE); \
@@ -122,12 +126,13 @@
distdir=$(PACKAGE); \
tarname=$$distdir-$$day ;\
cd .disttmp; \
- perl -pi -e "s/\#DATE\#/$$day/g" $$distdir/$(PACKAGE)-daily.spec; \
+ perl -pi -e "s/^(Release:\s+\w)/\1\.$$day/g" $$distdir/$(PACKAGE).spec; \
echo $$day; \
tar -cvz > ../$$tarname.tar.gz $$distdir; \
cd $$olddir
$(RM) -rf .disttmp
+
dailyfiles:
distdir=$(PACKAGE); \
cp \
@@ -141,6 +146,7 @@
$(MAKE) -C $$subdir dailyfiles VERSION=$(VERSION) PACKAGE=$(PACKAGE); \
done
+
distfiles:
distdir=$(PACKAGE)-$(VERSION); \
cp \
@@ -154,8 +160,10 @@
$(MAKE) -C $$subdir distfiles VERSION=$(VERSION) PACKAGE=$(PACKAGE); \
done
+
archive: dist
+
.PHONY: todo
todo:
@echo ---------------===========================================
=== modified file 'bin/Makefile'
--- old/bin/Makefile 2006-08-09 08:24:36 +0000
+++ new/bin/Makefile 2006-08-10 10:15:44 +0000
@@ -16,7 +16,7 @@
docdir =
includedir = ${prefix}/include
oldincludedir = /usr/include
-mandir = ${prefix}/man
+mandir = ${datadir}/man
pkgdatadir = $(datadir)/$(PACKAGE)
pkglibdir = $(libdir)/$(PACKAGE)
@@ -24,7 +24,7 @@
top_builddir = ../
# all dirs
-DIRS = $(DESTDIR)$(bindir) $(DESTDIR)/etc $(DESTDIR)$(pkgdatadir)
+DIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
# INSTALL scripts
@@ -36,16 +36,17 @@
RM = rm -f
-all: $(srcdir)/$(PACKAGE)
-
-
-install: all installdirs
- $(INSTALL_BIN) $(srcdir)/$(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE)
+all:
+ echo "Nothing to do in $(srcdir)"
+
+
+install:
+ $(INSTALL_DIR) $(DESTDIR)$(bindir)
+ $(INSTALL_BIN) createrepo $(DESTDIR)$(bindir)/createrepo
uninstall:
- $(RM) $(bindir)/$(PACKAGE)
-
+ $(RM) $(DESTDIR)$(bindir)/createrepo
clean:
@@ -69,21 +70,19 @@
distdir=$(PACKAGE)-$(VERSION); \
mkdir $(top_srcdir)/.disttmp/$$distdir/bin;\
cp \
- $(srcdir)/$(PACKAGE) \
+ $(srcdir)/createrepo \
$(srcdir)/Makefile \
$(top_srcdir)/.disttmp/$$distdir/bin
+
dailyfiles:
distdir=$(PACKAGE); \
mkdir $(top_srcdir)/.disttmp/$$distdir/bin;\
cp \
- $(srcdir)/$(PACKAGE) \
+ $(srcdir)/createrepo \
$(srcdir)/Makefile \
$(top_srcdir)/.disttmp/$$distdir/bin
-installdirs:
- $(MAKE) -C $(top_srcdir) installdirs
-
.PHONY: all install install-strip uninstall clean distclean mostlyclean maintainer-clean info dvi dist distfiles check installcheck installdirs dailyfiles
=== modified file 'docs/Makefile'
--- old/docs/Makefile 2006-08-09 08:24:36 +0000
+++ new/docs/Makefile 2006-08-10 10:15:35 +0000
@@ -24,7 +24,7 @@
top_builddir = ../
# all dirs
-DIRS = $(DESTDIR)$(bindir) $(DESTDIR)/etc $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
+DIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
# INSTALL scripts
@@ -37,16 +37,16 @@
all:
- echo "nothing to do"
-
-install: all installdirs
- mkdir -p $(DESTDIR)$(mandir)/man8
+ echo "Nothing to do in $(srcdir)"
+
+
+install:
+ $(INSTALL_DIR) $(DESTDIR)$(mandir)/man8
$(INSTALL_DATA) createrepo.8 $(DESTDIR)$(mandir)/man8/createrepo.8
uninstall:
- $(RM) $(bindir)/$(PACKAGE)
-
+ $(RM) $(DESTDIR)$(mandir)/man8/createrepo.8
clean:
@@ -82,9 +82,6 @@
$(srcdir)/Makefile \
$(top_srcdir)/.disttmp/$$distdir/docs
-installdirs:
- $(MAKE) -C $(top_srcdir) installdirs
-
.PHONY: all install install-strip uninstall clean distclean mostlyclean maintainer-clean info dvi dist distfiles check installcheck installdirs dailyfiles