updating minor spec break in repoclone for arch, other small notes/fixes

This commit is contained in:
brent s 2018-11-08 19:04:11 -05:00
parent b17646ea4f
commit 69d13d5c97
3 changed files with 13 additions and 4 deletions

View File

@ -97,9 +97,7 @@ def sync(args):
# No-op. Stderr should be empty.
c = subprocess.run(['echo'], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
now = int(datetime.datetime.timestamp(datetime.datetime.utcnow()))
# always write the "lastcheck" timestamp. This is something I personally do since other mirrors only update
# lastsync when syncs are needed.
with open(os.path.join(args['destination'], 'lastcheck'), 'w') as f:
with open(args['lastcheck'], 'w') as f:
f.write(str(now) + '\n')
os.remove(args['lockfile'])
# Only report errors at the end of the run if we aren't running in cron. Otherwise, log them.
@ -122,6 +120,7 @@ def getDefaults():
dflt = {'mirror': 'rsync://mirror.square-r00t.net/arch/',
'repos': 'core,extra,community,multilib,iso/latest',
'destination': '/srv/repos/arch',
'lastcheck': '/srv/http/arch.lastcheck',
'mount': '/',
'bwlimit': 0,
'lockfile': '/var/run/repo-sync_arch.lck',
@ -159,12 +158,18 @@ def parseArgs():
dest = 'destination',
default = liveopts['destination'],
help = 'The destination directory to sync to. Default: {0}'.format(liveopts['destination']))
args.add_argument('-c', '--last-check',
dest = 'lastcheck',
default = liveopts['lastcheck'],
help = ('The file to update with a timestamp on every run. Per spec, this must be outside the '
'repository webroot'))
args.add_argument('-b',
'--bwlimit',
dest = 'bwlimit',
default = liveopts['bwlimit'],
type = int,
help = 'The amount, in Kilobytes per second, to throttle the sync to. Default is to not throttle (0).')
help = ('The amount, in Kilobytes per second, to throttle the sync to. Default is to not '
'throttle (0).'))
args.add_argument('-l',
'--log',
dest = 'logfile',

View File

@ -5,6 +5,8 @@
# we import it for various prep stuff anyways.
# TODO: change loglevel of borg itself in subprocess to match the argparse?
# --debug, --info (same as -v/--verbose), --warning, --error, --critical
# TODO: switch to XML-based cfg instead of JSON. add automatic converter.
# TODO: modify config to add repo to cfg for init? or add new operation, "add"

import argparse
import configparser

View File

@ -13,6 +13,8 @@ import lxml.etree
# Serialize BSD mtree spec files into XML.
# On arch, BSD mtree is ported in the AUR as nmtree.

# TODO: use bitwise operations to convert octal modes back and forth. ex. at https://stackoverflow.com/a/1746850

class MtreeXML(object):
def __init__(self, spec):
# spec is a string or bytes