From: Seth Vidal Date: Sun, 11 Jan 2004 22:07:11 +0000 (+0000) Subject: - translation stubs X-Git-Tag: upstream/0.9.9~321 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=906c135e904057153e9be6da2ad43e1a9fa5db0d;p=tools%2Fcreaterepo.git - translation stubs - makefiles - spec file - bin wrapper --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9ff193d --- /dev/null +++ b/Makefile @@ -0,0 +1,160 @@ +PACKAGE = createrepo +VERSION = 0.1 +SHELL = /bin/sh +top_srcdir = . +srcdir = . +prefix = /usr +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +docdir = +includedir = ${prefix}/include +oldincludedir = /usr/include +mandir = ${prefix}/man + +pkgdatadir = $(datadir)/$(PACKAGE) +pkglibdir = $(libdir)/$(PACKAGE) +pkgincludedir = $(includedir)/$(PACKAGE) +top_builddir = + +# all dirs +DIRS = $(DESTDIR)$(bindir) $(DESTDIR)/etc $(DESTDIR)$(pkgdatadir) + + +# INSTALL scripts +INSTALL = install -p --verbose +INSTALL_BIN = $(INSTALL) -m 755 +INSTALL_DIR = $(INSTALL) -m 755 -d +INSTALL_DATA = $(INSTALL) -m 644 +INSTALL_MODULES = $(INSTALL) -m 755 -D +RM = rm -f + +SUBDIRS = bin + +MODULES = $(srcdir)/genpkgmetadata.py \ + $(srcdir)/dumpMetadata.py + +.SUFFIXES: .py .pyc +.py.pyc: + python -c "import py_compile; py_compile.compile($*.py)" + + +all: $(MODULES) + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir ; \ + done + +check: + pychecker $(MODULES) || exit 0 + +install: all installdirs + $(INSTALL_MODULES) $(srcdir)/$(MODULES) $(DESTDIR)$(pkgdatadir) + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir install ; \ + done + +installdirs: + for dir in $(DIRS) ; do \ + $(INSTALL_DIR) $$dir ; \ + done + + +uninstall: + for module in $(MODULES) ; do \ + $(RM) $(pkgdatadir)/$$module ; \ + done + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir uninstall ; \ + done + +clean: + $(RM) *.pyc *.pyo + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir clean ; \ + done + +distclean: clean + $(RM) -r .libs + $(RM) core + $(RM) *~ + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir distclean ; \ + done + +mostlyclean: + $(MAKE) clean + + +maintainer-clean: + $(MAKE) distclean + $(RM) $(srcdir)/configure + + +dist: + olddir=`pwd`; \ + distdir=$(PACKAGE)-$(VERSION); \ + $(RM) -r .disttmp; \ + $(INSTALL_DIR) .disttmp; \ + $(INSTALL_DIR) .disttmp/$$distdir; \ + $(MAKE) distfiles + distdir=$(PACKAGE)-$(VERSION); \ + cd .disttmp; \ + tar -cvz > ../$$distdir.tar.gz $$distdir; \ + cd $$olddir + $(RM) -r .disttmp + +daily: + olddir=`pwd`; \ + distdir=$(PACKAGE); \ + $(RM) -r .disttmp; \ + $(INSTALL_DIR) .disttmp; \ + $(INSTALL_DIR) .disttmp/$$distdir; \ + $(MAKE) dailyfiles + day=`/bin/date +%Y%m%d`; \ + distdir=$(PACKAGE); \ + tarname=$$distdir-$$day ;\ + cd .disttmp; \ + perl -pi -e "s/\#DATE\#/$$day/g" $$distdir/$(PACKAGE)-daily.spec; \ + echo $$day; \ + tar -cvz > ../$$tarname.tar.gz $$distdir; \ + cd $$olddir + $(RM) -rf .disttmp + +dailyfiles: + distdir=$(PACKAGE); \ + cp \ + $(srcdir)/*.py \ + $(srcdir)/Makefile \ + $(srcdir)/$(PACKAGE).spec + $(top_srcdir)/.disttmp/$$distdir + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir dailyfiles ; \ + done + +distfiles: + distdir=$(PACKAGE)-$(VERSION); \ + cp \ + $(srcdir)/*.py \ + $(srcdir)/Makefile \ + $(srcdir)/$(PACKAGE).spec \ + $(top_srcdir)/.disttmp/$$distdir + for subdir in $(SUBDIRS) ; do \ + $(MAKE) -C $$subdir distfiles ; \ + done + +archive: dist + +.PHONY: todo +todo: + @echo ---------------=========================================== + @grep -n TODO\\\|FIXME `find . -type f` | grep -v grep + @echo ---------------=========================================== +.PHONY: all install install-strip uninstall clean distclean mostlyclean maintainer-clean info dvi dist distfiles check installcheck installdirs daily dailyfiles diff --git a/bin/Makefile b/bin/Makefile new file mode 100644 index 0000000..278c469 --- /dev/null +++ b/bin/Makefile @@ -0,0 +1,93 @@ +PACKAGE = createrepo +VERSION = 0.1 +SHELL = /bin/sh +top_srcdir = .. +srcdir = ../bin +prefix = /usr +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +docdir = +includedir = ${prefix}/include +oldincludedir = /usr/include +mandir = ${prefix}/man + +pkgdatadir = $(datadir)/$(PACKAGE) +pkglibdir = $(libdir)/$(PACKAGE) +pkgincludedir = $(includedir)/$(PACKAGE) +top_builddir = ../ + +# all dirs +DIRS = $(DESTDIR)$(bindir) $(DESTDIR)/etc $(DESTDIR)$(pkgdatadir) + + +# INSTALL scripts +INSTALL = install -p --verbose +INSTALL_BIN = $(INSTALL) -m 755 +INSTALL_DIR = $(INSTALL) -m 755 -d +INSTALL_DATA = $(INSTALL) -m 644 +INSTALL_MODULES = $(INSTALL) -m 755 -D +RM = rm -f + + +all: $(srcdir)/createrepo + + +install: all installdirs + $(INSTALL_BIN) $(srcdir)/createrepo $(DESTDIR)$(bindir)/createrepo + + +uninstall: + $(RM) $(bindir)/createrepo + + + +clean: + + +distclean: + $(RM) -rf .libs + $(RM) -f core + $(RM) -f *~ + + +mostlyclean: + $(MAKE) clean + + +maintainer-clean: + $(MAKE) distclean + + +distfiles: + distdir=$(PACKAGE)-$(VERSION); \ + mkdir $(top_srcdir)/.disttmp/$$distdir/bin;\ + cp \ + $(srcdir)/createrepo \ + $(srcdir)/Makefile \ + $(top_srcdir)/.disttmp/$$distdir/bin + +dailyfiles: + distdir=$(PACKAGE); \ + mkdir $(top_srcdir)/.disttmp/$$distdir/bin;\ + cp \ + $(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 + + + diff --git a/bin/createrepo b/bin/createrepo new file mode 100755 index 0000000..0f313a9 --- /dev/null +++ b/bin/createrepo @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/share/createrepo/genpkgmetadata.py $* diff --git a/createrepo.spec b/createrepo.spec new file mode 100644 index 0000000..a08db12 --- /dev/null +++ b/createrepo.spec @@ -0,0 +1,37 @@ +Summary: Creates a common metadata repository +Name: createrepo +Version: 0.1 +Release: 1 +License: GPL +Group: System Environment/Base +Source: %{name}-%{version}.tar.gz +URL: http://linux.duke.edu/metadata/ +BuildRoot: %{_tmppath}/%{name}-%{version}root +BuildArchitectures: noarch +Requires: python >= 2.1, rpm-python, rpm >= 0:4.1.1, libxml2-python + +%description +This utility will generate a common metadata repository from a directory of +rpm packages + +%prep +%setup -q + +%install +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT +%makeinstall + +%clean +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT + + +%files +%defattr(-, root, root) +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/* +%{_bindir}/%{name} + +%changelog +* Sat Jan 10 2004 Seth Vidal +- first packaginging + diff --git a/dumpMetadata.py b/dumpMetadata.py index a414bc8..62ea69e 100644 --- a/dumpMetadata.py +++ b/dumpMetadata.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python -t # base classes and functions for dumping out package Metadata # # This program is free software; you can redistribute it and/or modify @@ -16,7 +16,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2003 Duke University -$Id$ +# $Id$ import os import rpm diff --git a/genpkgmetadata.py b/genpkgmetadata.py index 169e46f..3b406b3 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python -t # primary functions and glue for generating the repository metadata # @@ -16,7 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2003 Duke University -$Id$ + +# $Id$ + + import os import sys import getopt @@ -31,8 +34,12 @@ __version__ = '0.1' def errorprint(stuff): print >> sys.stderr, stuff +def _(args): + """Stub function for translation""" + return args + def usage(): - print """ + print _(""" %s [options] directory-of-packages Options: @@ -46,7 +53,7 @@ def usage(): -h, --help = show this help -V, --version = output version - """ % os.path.basename(sys.argv[0]) + """) % os.path.basename(sys.argv[0]) sys.exit(1) @@ -60,7 +67,7 @@ def getFileList(path, ext, filelist): try: dir_list = os.listdir(path) except OSError, e: - errorprint('Error accessing directory %s, %s' % (path, e)) + errorprint(_('Error accessing directory %s, %s') % (path, e)) sys.exit(1) for d in dir_list: @@ -111,7 +118,7 @@ def parseArgs(args): 'baseurl=', 'groupfile=', 'checksum=', 'version']) except getopt.error, e: - errorprint('Options Error: %s.' % e) + errorprint(_('Options Error: %s.') % e) usage() try: @@ -127,13 +134,13 @@ def parseArgs(args): cmds['quiet'] = 1 elif arg in ['-u', '--baseurl']: if cmds['baseurl'] is not None: - errorprint('Error: Only one baseurl allowed.') + errorprint(_('Error: Only one baseurl allowed.')) usage() else: cmds['baseurl'] = a elif arg in ['-g', '--groupfile']: if cmds['groupfile'] is not None: - errorprint('Error: Only one groupfile allowed.') + errorprint(_('Error: Only one groupfile allowed.')) usage() else: cmds['groupfile'] = a @@ -142,17 +149,17 @@ def parseArgs(args): cmds['excludes'].append(a) elif arg in ['-s', '--checksum']: if a not in ['md5', 'sha']: - errorprint('Error: checksums are: md5 or sha.') + errorprint(_('Error: checksums are: md5 or sha.')) usage() else: cmds['sumtype'] = a except ValueError, e: - errorprint('Options Error: %s' % e) + errorprint(_('Options Error: %s') % e) usage() if len(argsleft) != 1: - errorprint('Error: Only one directory allowed per run.') + errorprint(_('Error: Only one directory allowed per run.')) usage() else: directory = argsleft[0] @@ -201,17 +208,17 @@ def doPkgMetadata(cmds, ts): try: dumpMetadata.generateXML(basedoc, baseroot, mdobj, cmds['sumtype']) except dumpMetadata.MDError, e: - errorprint('\nan error occurred creating primary metadata - hmm %s' % e) + errorprint(_('\nAn error occurred creating primary metadata: %s') % e) continue try: dumpMetadata.fileListXML(filesdoc, filesroot, mdobj) except dumpMetadata.MDError, e: - errorprint('\nan error occurred creating filelists- hmm %s' % e) + errorprint(_('\nAn error occurred creating filelists: %s') % e) continue try: dumpMetadata.otherXML(otherdoc, otherroot, mdobj) except dumpMetadata.MDError, e: - errorprint('\nan error occurred - hmm %s' % e) + errorprint(_('\nAn error occurred: %s') % e) continue if not cmds['quiet']: print '' @@ -219,17 +226,17 @@ def doPkgMetadata(cmds, ts): # save them up to the tmp locations: basedoc.setDocCompressMode(9) if not cmds['quiet']: - print 'Saving Primary metadata' + print _('Saving Primary metadata') basedoc.saveFormatFileEnc('.primary.xml.gz', 'UTF-8', 1) filesdoc.setDocCompressMode(9) if not cmds['quiet']: - print 'Saving file lists metadata' + print _('Saving file lists metadata') filesdoc.saveFormatFileEnc('.filelists.xml.gz', 'UTF-8', 1) otherdoc.setDocCompressMode(9) if not cmds['quiet']: - print 'Saving other metadata' + print _('Saving other metadata') otherdoc.saveFormatFileEnc('.other.xml.gz', 'UTF-8', 1) # move them to their final locations @@ -239,8 +246,8 @@ def doPkgMetadata(cmds, ts): try: os.rename(tmp, dest) except OSError, e: - errorprint('Error finishing file %s: %s' % (dest, e)) - errorprint('Exiting.') + errorprint(_('Error finishing file %s: %s') % (dest, e)) + errorprint(_('Exiting.')) os.unlink(tmp) sys.exit(1) @@ -254,20 +261,20 @@ def doRepoMetadata(cmds): try: dumpMetadata.repoXML(reporoot, cmds) except dumpMetadata.MDError, e: - errorprint('Error generating repo xml file: %s' % e) + errorprint(_('Error generating repo xml file: %s') % e) sys.exit(1) try: repodoc.saveFormatFileEnc('.repomd.xml.gz', 'UTF-8', 1) except: - errorprint('Error saving temp file for rep xml') + errorprint(_('Error saving temp file for rep xml')) sys.exit(1) try: os.rename('.repomd.xml.gz', cmds['repomdfile']) except OSError, e: - errorprint('Error finishing file %s: %s' % (cmds['repomdfile'], e)) - errorprint('Exiting.') + errorprint(_('Error finishing file %s: %s') % (cmds['repomdfile'], e)) + errorprint(_('Exiting.')) os.unlink('.repomd.xml.gz') sys.exit(1) else: @@ -287,19 +294,19 @@ def main(args): curdir = os.getcwd() # start the sanity/stupidity checks if not os.path.exists(directory): - errorprint('Directory must exist') + errorprint(_('Directory must exist')) usage() if not os.path.isdir(directory): - errorprint('Directory of packages must be a directory.') + errorprint(_('Directory of packages must be a directory.')) usage() if not os.access(directory, os.W_OK): - errorprint('Directory must be writable.') + errorprint(_('Directory must be writable.')) usage() # check out the group file if specified if cmds['groupfile'] is not None: grpfile = os.path.join(directory, cmds['groupfile']) if not os.access(grpfile, os.R_OK): - errorprint('groupfile %s must exist and be readable' % grpfile) + errorprint(_('Groupfile %s must exist and be readable') % grpfile) usage() # make sure we can write to where we want to write to: for file in ['primaryfile', 'filelistsfile', 'otherfile', 'repomdfile']: @@ -307,11 +314,11 @@ def main(args): dirpath = os.path.dirname(filepath) if os.path.exists(filepath): if not os.access(filepath, os.W_OK): - errorprint('error in must be able to write to metadata files:\n -> %s' % filepath) + errorprint(_('error in must be able to write to metadata files:\n -> %s') % filepath) usage() else: if not os.access(dirpath, os.W_OK): - errorprint('must be able to write to path for metadata files:\n -> %s' % dirpath) + errorprint(_('must be able to write to path for metadata files:\n -> %s') % dirpath) usage() # change to the basedir to work from w/i the path - for relative url paths