|
@@ -1,41 +1,76 @@
|
|
|
import sys
|
|
|
+import argparse
|
|
|
|
|
|
from .config import Config
|
|
|
from .util import term
|
|
|
from .repo import Repo
|
|
|
+from . import server
|
|
|
|
|
|
+def update(args, config):
|
|
|
+ print(config.path)
|
|
|
+ print('---')
|
|
|
+ print()
|
|
|
+ print(config)
|
|
|
+ print()
|
|
|
+ for repo in config.repos:
|
|
|
+ print(repo.path)
|
|
|
+ print('---')
|
|
|
+ print()
|
|
|
+ print(repo)
|
|
|
+ print()
|
|
|
|
|
|
-def main(args):
|
|
|
- try:
|
|
|
- config = Config(args[0] if len(args) else '/etc/pacman-repo.d')
|
|
|
- print(config.path)
|
|
|
+ for server in config.servers:
|
|
|
+ print(server.path)
|
|
|
print('---')
|
|
|
print()
|
|
|
- print(config)
|
|
|
+ print(server)
|
|
|
print()
|
|
|
- for repo in config.repos:
|
|
|
- print(repo.path)
|
|
|
- print('---')
|
|
|
- print()
|
|
|
- print(repo)
|
|
|
- print()
|
|
|
-
|
|
|
- for server in config.servers:
|
|
|
- print(server.path)
|
|
|
- print('---')
|
|
|
- print()
|
|
|
- print(server)
|
|
|
- print()
|
|
|
-
|
|
|
- repos = []
|
|
|
- for repo in config.repos:
|
|
|
- repo = Repo(repo)
|
|
|
- repos.append(repo)
|
|
|
- print("Repo: {}".format(repo.name))
|
|
|
- for package in repo.packages:
|
|
|
- package.update()
|
|
|
- print(" {0}: {1}".format(package.name, package.url))
|
|
|
- package.makepkg()
|
|
|
+
|
|
|
+ repos = []
|
|
|
+ for repo in config.repos:
|
|
|
+ repo = Repo(repo)
|
|
|
+ repos.append(repo)
|
|
|
+ print("Repo: {}".format(repo.name))
|
|
|
+ for package in repo.packages:
|
|
|
+ package.update()
|
|
|
+ print(" {0}: {1}".format(package.name, package.url))
|
|
|
+ package.makepkg(args.force)
|
|
|
+
|
|
|
+def webserver(args, config):
|
|
|
+ server.start()
|
|
|
+
|
|
|
+def main(argv):
|
|
|
+
|
|
|
+ parser = argparse.ArgumentParser(
|
|
|
+ prog="pacman-repo",
|
|
|
+ description='A tool for automating the creation and maintenance of pacman repos')
|
|
|
+ parser.add_argument(
|
|
|
+ '--config', '-c',
|
|
|
+ default='/etc/pacman-repo.d',
|
|
|
+ help="Configuration folder path"
|
|
|
+ )
|
|
|
+ subparsers = parser.add_subparsers()
|
|
|
+
|
|
|
+ update_parser = subparsers.add_parser('update', help='Update repository')
|
|
|
+ update_parser.add_argument(
|
|
|
+ '--force', '-f',
|
|
|
+ action="store_true",
|
|
|
+ help="Force rebuild of all packages, even if they already exist"
|
|
|
+ )
|
|
|
+ update_parser.set_defaults(func=update)
|
|
|
+
|
|
|
+ webserver_parser = subparsers.add_parser('webserver', help='Run as a webserver')
|
|
|
+ webserver_parser.add_argument(
|
|
|
+ '--weserver',
|
|
|
+ action='store_true',
|
|
|
+ help='Run webserver '
|
|
|
+ )
|
|
|
+ webserver_parser.set_defaults(func=webserver)
|
|
|
+
|
|
|
+ args = parser.parse_args(argv)
|
|
|
+ try:
|
|
|
+ config = Config(args.config)
|
|
|
+ args.func(args, config)
|
|
|
|
|
|
except Exception:
|
|
|
from traceback import format_exc
|