#!/usr/bin/env python from __future__ import print_function import tarfile import sys def main(tar_path, folder_path, target_name): try: tar = tarfile.open(tar_path, mode="a") tar.add(folder_path, arcname=target_name) tar.close() except Exception as e: print("Error: ", e) if __name__ == "__main__": if len(sys.argv) != 4: print("Usage: " "add_to_rootfs_tar ") main(sys.argv[1], sys.argv[2], sys.argv[3])