diff --git a/README.rst b/README.rst index 353486a..25dc288 100644 --- a/README.rst +++ b/README.rst @@ -28,6 +28,7 @@ TODO - [high] adding and then removing it before adding complete will result in not-in-database removing - [middle] disable "any" architecture via config +- [middle] some attributes should be set on the EventHandler - [low] fork to background - [low] use one common command queue (now one each repo) - [low] verify packages diff --git a/archrepo.ini.example b/archrepo.ini.example index 63679c1..037164b 100644 --- a/archrepo.ini.example +++ b/archrepo.ini.example @@ -27,10 +27,15 @@ path: /home/lilydjwg/tmpfs/test #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 +# files according to filenames, and move them under the correct architecture # directory. Default is on. #auto-rename: on +# By enabling symlink-any, the server will automatically symlink the package +# files of 'any' architecture to 'i686' and 'x86_64' +# Default is on. +#symlink-any: on + # Seconds before actually running the command. 10s by default. #wait-time: 10 wait-time: 3 diff --git a/archrepo2/repomon.py b/archrepo2/repomon.py index c380030..d531df9 100755 --- a/archrepo2/repomon.py +++ b/archrepo2/repomon.py @@ -59,6 +59,8 @@ class RepoMan: self._command_remove = config.get('command-remove', 'repo-remove') self._wait_time = config.getint('wait-time', 10) self._without_db = config.getboolean('without-db', False) + self._auto_rename = config.getboolean('auto-rename', True) + self._symlink_any = config.getboolean('symlink-any', True) notification_type = config.get('notification-type', 'null') if notification_type != 'null': @@ -235,6 +237,8 @@ class EventHandler(pyinotify.ProcessEvent): wm.add_watch(d, pyinotify.ALL_EVENTS) self.repomans[d] = RepoMan(config, d, self._ioloop) self.name = self.repomans[d].name + self._auto_rename = self.repomans[d]._auto_rename + self._symlink_any = self.repomans[d]._symlink_any self._initial_update(files) @@ -306,7 +310,7 @@ class EventHandler(pyinotify.ProcessEvent): base, arch = os.path.split(d) # rename if a packager has added to a wrong directory - if action == 'add' and act.arch != arch: + if self._auto_rename and action == 'add' and act.arch != arch: newd = os.path.join(base, act.arch) newpath = os.path.join(newd, file) os.rename(path, newpath) @@ -316,8 +320,11 @@ class EventHandler(pyinotify.ProcessEvent): arch = act.arch d = newd - if arch == 'any': - for newarch in ('i686', 'x86_64'): + if self._symlink_any and act.arch == 'any': + for newarch in ('i686', 'x86_64', 'any'): + if newarch == arch: + # this file itself + continue newd = os.path.join(base, newarch) newpath = os.path.join(newd, file) if action == 'add':