diff options
-rw-r--r-- | config.py | 77 | ||||
-rwxr-xr-x | config.sh | 51 |
2 files changed, 84 insertions, 44 deletions
@@ -1,53 +1,39 @@ -#!/usr/bin/python +#!/usr/bin/pythonn # -*- coding: utf-8 -*- -from user import home -import commands +try: + from subprocess import check_output +except(ImportError): + from commands import getoutput as check_output import os -time__ = commands.getoutput("date +%Y%m%d-%H:%M") - -# Mirror Parameters -mirror = "mirrors.eu.kernel.org" -mirrorpath = "::mirrors/archlinux" - -# Directories and files - -## Optionals -path = home + "/parabolagnulinux.org" -docs = path + "/docs" -logdir = path + "/log" - -## Must be defined -logname= logdir + "/" + time__ + "-repo-maintainer.log" -freedir= path + "/free/" -repodir= path + "/repo" -tmp = home + "/tmp" -archdb = tmp + "/db" - -free_path= path + "/free/" - -# Repo, arch, and other folders to use for repo -# This are tuples, so **always keep a comma before closing parenthesis ** -repo_list = ("core", "extra", "community", "testing", "community-testing", "multilib",) -dir_list = ("pool",) -arch_list = ("i686", "x86_64",) -other = ("any",) - -# Output -output = True -verbose = True - -# Files -blacklist = docs + "/blacklist.txt" -whitelist = docs + "/whitelist.txt" -pending = docs + "/pending" -rsync_blacklist = docs + "/rsyncBlacklist" +stringvars=("mirror", "mirrorpath", "logname", "tempdir", "docs_dir", + "repodir",) +listvars=("repo_list", "dir_list", "arch_list", "other",) +boolvars=("output", "debug",) + +config=dict() + +def exit_if_none: + if os.environ.get(var) is None: + exit("%s is not defined" % var) + +for var in stringvars: + exit_if_none(var) + config[var]=os.environ.get(var) +for var in listvars: + exit_if_none(var) + config[var]=tuple(os.environ.get(var).split(":")) +for var in boolvars: + exit_if_none(var) + if os.environ.get(var) == "True": + config[var]=True + elif os.environ.get(var) =="False": + config[var]=False + else: + print('%s is not True or False' % var) # Rsync commands - rsync_list_command="rsync -a --no-motd --list-only " -rsync_update_command="rsync -av --delay-updates --exclude=*.{abs|db}.tar.* " -rsync_post_command="rsync -av --delete --exclude=*.abs.tar.* " # Classes and Exceptions class NonValidFile(ValueError): pass @@ -91,3 +77,6 @@ class Package: else: return True +if __name__=="__main__": + for key in config.keys(): + print("%s : %s" % (key,config[key])) diff --git a/config.sh b/config.sh new file mode 100755 index 0000000..66be477 --- /dev/null +++ b/config.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# -*- coding: utf-8 -*- + + +# Mirror options +mirror="mirrors.eu.kernel.org" +mirrorpath="::mirrors/archlinux" + +# Directories and files + +## Optionals +paraboladir=~/parabolagnulinux.org +logtime=$(date -u +%Y%m%d-%H:%M) + +## Must be defined +logname=${paraboladir}/${logtime}-repo-maintainer.log +tempdir=~/tmp/ +docs_dir=${paraboladir}/docs +repodir=${paraboladir}/repo + +# Repos, arches, and dirs for repo +repo_list="core:extra:community:testing:community-testing:multilib" +dir_list="pool" +arch_list="i686:x86_64" +other="any" + +# Output options +output="True" +debug="False" + +# Rsync commands +rsync_update_command="rsync -av --delay-updates --exclude=*.{abs|db}.tar.* " +rsync_post_command="rsync -av --delete --exclude=*.abs.tar.* " + + +function run_python_cmd { + env \ + mirror=${mirror} \ + mirrorpath=${mirrorpath} \ + logname=${logname} \ + tempdir=${tempdir} \ + docs_dir=${docs_dir} \ + repodir=${repodir} \ + repo_list=${repo_list} \ + dir_list=${dir_list} \ + arch_list=${arch_list} \ + other=${other} \ + output=${output} \ + debug=${debug} \ + $1 +}
\ No newline at end of file |