From 69d13d5c97341d6e9ae86532c1a577db626ef221 Mon Sep 17 00:00:00 2001 From: brent s Date: Thu, 8 Nov 2018 19:04:11 -0500 Subject: [PATCH] updating minor spec break in repoclone for arch, other small notes/fixes --- arch/repoclone.py | 13 +++++++++---- storage/backups/borg/backup.py | 2 ++ storage/mtree_to_xml.py | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/repoclone.py b/arch/repoclone.py index 241cbe1..4c89021 100755 --- a/arch/repoclone.py +++ b/arch/repoclone.py @@ -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', diff --git a/storage/backups/borg/backup.py b/storage/backups/borg/backup.py index c8b435c..be9aa65 100755 --- a/storage/backups/borg/backup.py +++ b/storage/backups/borg/backup.py @@ -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 diff --git a/storage/mtree_to_xml.py b/storage/mtree_to_xml.py index eddcb94..4887869 100755 --- a/storage/mtree_to_xml.py +++ b/storage/mtree_to_xml.py @@ -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