blob: 31c84c34c7c42bf64cca4d5a57529b4e57c88f5d [file] [log] [blame]
#!/usr/bin/env python3.8
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import sys
import tarfile
import os
def main():
parser = argparse.ArgumentParser('Archives a directory')
'--src', help='Path to the directory to archive', required=True)
parser.add_argument('--dst', help='Path to the archive', required=True)
'--depfile', help='Path to dependency file', required=True)
args = parser.parse_args()
deps = []
with, "w:gz") as tar:
for (dirpath, dirnames, filenames) in os.walk(args.src):
for filename in filenames:
path = os.path.join(dirpath, filename)
tar.add(path, arcname=os.path.relpath(path, args.src))
with open(args.depfile, 'w') as depfile:
depfile.write('%s: %s\n' % (args.dst, ' '.join(sorted(deps))))
return 0
if __name__ == "__main__":