Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2525c04034
Fetching contributors…

Cannot retrieve contributors at this time

executable file 87 lines (67 sloc) 2.163 kb
# Copyright (c) 2010-2012 Liraz Siri <>
# This file is part of TKLBAM (TurnKey Linux BAckup and Migration).
# TKLBAM is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
Fix ownership and permissions of files according to delta specification
-u --uid-map=<mapspec> Old to new UID map
-g --gid-map=<mapspec> Old to new GID map
-v --verbose Print list of fixes
-s --simulate Print list of fixes, don't apply them
<mapspec> := <key>,<val>[:<key>,<val> ...]
import os
import sys
import getopt
from changes import Changes
def usage(e=None):
if e:
print >> sys.stderr, "error: " + str(e)
print >> sys.stderr, "Syntax: %s [-options] delta|- [path ...]" % sys.argv[0]
print >> sys.stderr, __doc__.strip()
def main():
opts, args = getopt.gnu_getopt(sys.argv[1:], 'u:g:svh',
['uid-map=', 'gid-map=', 'simulate', 'verbose'])
except getopt.GetoptError, e:
verbose = False
simulate = False
uidmap = {}
gidmap = {}
def parse_idmap(line):
return dict([ map(int, val.split(',', 1)) for val in line.split(':') ])
for opt, val in opts:
if opt in ('-u', '--uid-map'):
uidmap = parse_idmap(val)
elif opt in ('-g', '--gid-map'):
gidmap = parse_idmap(val)
elif opt in ('-s', '--simulate'):
simulate = True
elif opt in ('-v', '--verbose'):
verbose = True
if len(args) < 1:
delta = args[0]
paths = args[1:]
changes = Changes.fromfile(delta, paths)
if simulate:
verbose = True
for action in changes.statfixes(uidmap, gidmap):
if verbose:
print action
if not simulate:
if __name__=="__main__":
Jump to Line
Something went wrong with that request. Please try again.