Commits

Anonymous committed 543e960

Delete cntainer/aufs code dependent

Comments (0)

Files changed (1)

     subprocess.Popen(cmd).wait()
 
 parser_rsync = subcommands.add_parser('rsync', help='Generate a list of changement and rsync them to the given dest')
-parser_rsync.add_argument('-c', '--container', metavar='path', required=True, help='Path to the container')
+parser_rsync.add_argument('-s', '--source', metavar='path', required=True, help='Source directory')
 parser_rsync.add_argument('--template', action='store_true', help='include template file')
 parser_rsync.add_argument('--other', action='store_true', help='include all other file')
 parser_rsync.add_argument('--persistent', action='store_true', help='include persistent files')
         print 'Manifest is required'
         return
 
-    cont_path = os.path.abspath(args.container)
+    cont_path = os.path.abspath(args.source) + '/'
     assert cont_path
     assert (args.persistent or args.volatile or args.other or args.template or args.all), 'At least one type of files has be choosen'
-    assert os.path.isdir(cont_path), 'container path should exists and should be a directory'
+    assert os.path.isdir(cont_path), 'Source path should exists and should be a directory'
 
-    cont_path = os.path.join(cont_path, 'rw')
-    assert os.path.isdir(cont_path), 'container path do not refer to a valid container (`rw` dir cannot be found)'
     manifest = args.manifest
     assert os.path.isfile(manifest), 'Manifest file cannot be found at {0}'.format(manifest)
 
     cldlts = cloudlets.Manifest.from_filename(manifest)
 
-    add = set()
-    delete = set()
+    include = set()
 
-    args.templates = args.template or args.all
+    args.template = args.template or args.all
     args.volatile = args.volatile or args.all
     args.persistent = args.persistent or args.all
-    args.others = args.other or args.all
+    args.other = args.other or args.all
 
     def generate_file_list(directory):
         files = os.listdir(directory)
 
             abs_file = os.path.join(directory, file)
             relative_file = abs_file.replace(cont_path, '')
+            relative_file = os.path.join('/', relative_file)
 
-            if file.startswith('.wh.'):
-                match = re.match('^\.wh\.(?P<filename>.*?)$', file)
-                filename = match.groupdict()['filename']
-                print 'whiteout: {0}'.format(filename)
-                if filename.startswith('.wh') or (directory == cont_path and filename in ('.cloudlet', '.hgmeta', '.hgignore')):
-                    continue
-                filename = os.path.join(directory, filename) 
-                delete.add(filename.replace(cont_path, ''))
-                continue
+            if cldlts.pass_path(relative_file, args.template,
+                                                 args.volatile,
+                                                 args.persistent,
+                                                 args.other):
+                if not os.path.islink(abs_file) and os.path.isdir(abs_file):
+                    generate_file_list(abs_file)
 
-            if os.path.isdir(abs_file):
-                generate_file_list(abs_file)
-
-            elif cldlts.pass_path(os.path.join('/', relative_file), args.template,
-                                                                    args.volatile,
-                                                                    args.persistent,
-                                                                    args.other):
-                add.add(relative_file)
+                include.add(relative_file)
 
     generate_file_list(cont_path)
-    with open('include_files', 'w') as include:
-        include.write('\n'.join(add))
-
-    with open('deleted_files', 'w') as deleted:
-        deleted.write('\n'.join(delete))
+    with open('include_files', 'w') as fd:
+        fd.write('\n'.join(include))
         
     cmd = 'rsync -avh --delete --numeric-ids --files-from={files} {source} {destionation}'.format(files='include_files', destionation=args.destination, source=cont_path)
     print 'This command will be executed in 3 seconds:\n{command}'.format(command=cmd)