From 051427c7b10d34952d6377a1dc3d4d7f1148fb98 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 23 Aug 2013 12:19:53 +0800 Subject: [PATCH] setup.py and directory structure change and README switched to rst --- README.mkd | 25 ------------ README.rst | 36 +++++++++++++++++ archrepo.ini | 46 ++++++++++++++++++++++ archrepo2/__init__.py | 3 ++ archreposrv => archrepo2/archreposrv.py | 12 ++++-- dbutil.py => archrepo2/dbutil.py | 0 pkgreader.py => archrepo2/pkgreader.py | 0 repomon.py => archrepo2/repomon.py | 4 +- test_readpkg.py => scripts/test_readpkg.py | 2 +- scripts/upgrade_from_0.1_to_0.2.py | 7 +--- scripts/upgrade_from_0.2_to_0.3.py | 5 +-- setup.py | 23 +++++++++++ 12 files changed, 122 insertions(+), 41 deletions(-) delete mode 100644 README.mkd create mode 100644 README.rst create mode 100644 archrepo.ini create mode 100644 archrepo2/__init__.py rename archreposrv => archrepo2/archreposrv.py (86%) rename dbutil.py => archrepo2/dbutil.py (100%) rename pkgreader.py => archrepo2/pkgreader.py (100%) rename repomon.py => archrepo2/repomon.py (99%) rename test_readpkg.py => scripts/test_readpkg.py (87%) create mode 100644 setup.py diff --git a/README.mkd b/README.mkd deleted file mode 100644 index 8c5393d..0000000 --- a/README.mkd +++ /dev/null @@ -1,25 +0,0 @@ -USAGE -==== -Edit a copy of `archrepo.ini` and then run `./archreposrv `. - -DEPENDENCIES -==== - -* Python, >= 3.3, with sqlite support -* distribute -* tornado, > 2.4.1 -* pyinotify, tested with 0.9.4 -* winterpy (add `pylib` to `$PYTHONPATH`) - -NOTE -==== -* relative symlinks may be broken when moving to the right architecture directory - -TODO -==== -* [high] adding and then removing it before adding complete will result in not-in-database removing -* [high] remove winterpy dependency -* [middle] `setup.py` support -* [middle] disable "any" architecture via config -* [low] use one common command queue (now one each repo) -* [low] verify packages diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..bc939ac --- /dev/null +++ b/README.rst @@ -0,0 +1,36 @@ +USAGE +===== + +Install:: + + python3 setup.py install + +Edit a copy of ``archrepo.ini.example`` and then run +``archreposrv ``. + +DEPENDENCIES +============ + +- Python, >= 3.3, with sqlite support +- distribute +- tornado, > 2.4.1 +- pyinotify, tested with 0.9.4 +- winterpy (add ``pylib`` to ``$PYTHONPATH``) + +NOTE +==== + +- relative symlinks may be broken when moving to the right architecture + directory + +TODO +==== + +- [high] adding and then removing it before adding complete will result + in not-in-database removing +- [high] remove winterpy dependency +- [middle] disable "any" architecture via config +- [low] fork to background +- [low] use one common command queue (now one each repo) +- [low] verify packages + diff --git a/archrepo.ini b/archrepo.ini new file mode 100644 index 0000000..63679c1 --- /dev/null +++ b/archrepo.ini @@ -0,0 +1,46 @@ +[multi] +# Names of repository config sections, if you have multiple repositories. +# The names should be delimited by commas. And this value is default to +# "repository". +# config names are the same as below, and will act as default if not specified +# in that repository config. +repos: repository + +# You can specify a "info-db" here to have them all in the same repo +#info-db: /home/lilydjwg/tmpfs/test/pkginfo.db + +[repository] +# Name of the repository. In below example the Pacman repository db file name +# will be archlinuxcn.db.tar.gz +name: archlinuxcn + +# Path to the repository - directory should normally contain any, i686 and +# x86_64. The server will monitor files in it with inotify. If you have lots of +# files in this directory, remember to update the configuration of inotify. +path: /home/lilydjwg/tmpfs/test + +# A database to store package info. Default to ${path}/pkginfo.db +#info-db: /home/lilydjwg/tmpfs/test/pkginfo.db + +# Specify where to find these commands +#command-add: repo-add +#command-remove: repo-remove + +# By enabling auto-rename, the server will automatically rename the package +# files according to .PKGINFO, and move them under the correct architecture +# directory. Default is on. +#auto-rename: on + +# Seconds before actually running the command. 10s by default. +#wait-time: 10 +wait-time: 3 + +# Notification type to use when done. Currently available: simple-udp, null +notification-type: simple-udp +notification-address: 127.0.0.1:9900 +notification-secret: JiUHuGY987G76djItfOskOj + +# If for any reason, you don't want actual database creation or update: +#without-db: true + +# vim: se ft=dosini: diff --git a/archrepo2/__init__.py b/archrepo2/__init__.py new file mode 100644 index 0000000..93cf1da --- /dev/null +++ b/archrepo2/__init__.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +__version__ = '0.3.1' diff --git a/archreposrv b/archrepo2/archreposrv.py similarity index 86% rename from archreposrv rename to archrepo2/archreposrv.py index 2a350c9..f5806f2 100755 --- a/archreposrv +++ b/archrepo2/archreposrv.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# vim:fileencoding=utf-8 import sys import configparser @@ -10,7 +9,9 @@ from tornado.ioloop import IOLoop from myutils import enable_pretty_logging enable_pretty_logging(logging.DEBUG) -from repomon import repomon +from .repomon import repomon + +logger = logging.getLogger(__name__) def check_and_get_repos(config): repos = config['multi'].get('repos', 'repository') @@ -26,7 +27,8 @@ def check_and_get_repos(config): return repos -def main(conffile): +def main(): + conffile = sys.argv[1] config = configparser.ConfigParser(default_section='multi') config.read(conffile) repos = check_and_get_repos(config) @@ -34,12 +36,14 @@ def main(conffile): notifiers = [repomon(config[repo]) for repo in repos] ioloop = IOLoop.instance() + logger.info('starting archreposrv.') try: ioloop.start() except KeyboardInterrupt: ioloop.close() for notifier in notifiers: notifier.stop() + print() if __name__ == '__main__': - main(sys.argv[1]) + main() diff --git a/dbutil.py b/archrepo2/dbutil.py similarity index 100% rename from dbutil.py rename to archrepo2/dbutil.py diff --git a/pkgreader.py b/archrepo2/pkgreader.py similarity index 100% rename from pkgreader.py rename to archrepo2/pkgreader.py diff --git a/repomon.py b/archrepo2/repomon.py similarity index 99% rename from repomon.py rename to archrepo2/repomon.py index dcea20e..c08b044 100755 --- a/repomon.py +++ b/archrepo2/repomon.py @@ -20,8 +20,8 @@ from tornado.ioloop import IOLoop import tornado.process import archpkg -import pkgreader -import dbutil +from . import pkgreader +from . import dbutil logger = logging.getLogger(__name__) diff --git a/test_readpkg.py b/scripts/test_readpkg.py similarity index 87% rename from test_readpkg.py rename to scripts/test_readpkg.py index 58e98b7..d428958 100755 --- a/test_readpkg.py +++ b/scripts/test_readpkg.py @@ -4,7 +4,7 @@ from subprocess import getoutput allpkgs = getoutput(r"locate -be --regex '\.pkg\.tar\.xz$'").split('\n') -from pkgreader import readpkg +from archrepo2.pkgreader import readpkg for p in allpkgs: print('reading package:', p) d = readpkg(p) diff --git a/scripts/upgrade_from_0.1_to_0.2.py b/scripts/upgrade_from_0.1_to_0.2.py index d18347a..10cfdf9 100755 --- a/scripts/upgrade_from_0.1_to_0.2.py +++ b/scripts/upgrade_from_0.1_to_0.2.py @@ -10,11 +10,8 @@ import logging from myutils import enable_pretty_logging enable_pretty_logging(logging.DEBUG) -top_dir = os.path.normpath(os.path.join(__file__, '../..')) -sys.path.append(top_dir) - -import pkgreader -from dbutil import * +import archrepo2.pkgreader +from archrepo2.dbutil import * def main(conffile): config = configparser.ConfigParser() diff --git a/scripts/upgrade_from_0.2_to_0.3.py b/scripts/upgrade_from_0.2_to_0.3.py index a2e0b4c..7f36278 100755 --- a/scripts/upgrade_from_0.2_to_0.3.py +++ b/scripts/upgrade_from_0.2_to_0.3.py @@ -9,10 +9,7 @@ import logging from myutils import enable_pretty_logging enable_pretty_logging(logging.DEBUG) -top_dir = os.path.normpath(os.path.join(__file__, '../..')) -sys.path.append(top_dir) - -from dbutil import * +from archrepo2.dbutil import * def main(dbname, reponame): db = sqlite3.connect(dbname, isolation_level=None) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f5b37b9 --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +from setuptools import setup, find_packages +import archrepo2 + +setup( + name = 'archrepo2', + version = archrepo2.__version__, + packages = find_packages(), + install_requires = ['tornado>2.4.1', 'pyinotify'], + entry_points = { + 'console_scripts': [ + 'archreposrv = archrepo2.archreposrv:main', + ], + }, + + author = 'lilydjwg', + author_email = 'lilydjwg@gmail.com', + description = 'Arch Linux repository manager', + license = 'MIT', + keywords = 'archlinux linux', + url = 'https://github.com/lilydjwg/archrepo2', +)