daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright (c) 2012 Rudix
  5. # Author: Rudá Moura
  6. #
  7.  
  8. import os
  9. import sys
  10. import tempfile
  11.  
  12. def expand(pkg, path):
  13.     cmd = 'pkgutil --expand %s %s' % (pkg, path)
  14.     return os.system(cmd)
  15.  
  16. def expand_head(head, path):
  17.     return expand(head, path)
  18.  
  19. def expand_package(pkg, path):
  20.     tmpdir = tempfile.mktemp()
  21.     print tmpdir
  22.     expand(pkg, tmpdir)
  23.     cmd = 'mv %s/*.pkg %s/' % (tmpdir, path)
  24.     return os.system(cmd)
  25.  
  26. def expand_packages(packages, path):
  27.     for pkg in packages:
  28.         print 'Expanding', pkg
  29.         expand_package(pkg, path)
  30.        
  31. def flatten(path, pkgpath):
  32.     cmd = 'pkgutil --flatten %s %s' % (path, pkgpath)
  33.     return os.system(cmd)
  34.  
  35. def create_distribution(pkgs):
  36.     head = pkgs[0]
  37.     deps = pkgs[1:]
  38.     tmpdir = tempfile.mktemp()
  39.     print tmpdir
  40.     print 'Expanding head package', head
  41.     expand_head(head, tmpdir)
  42.     print 'Expanding dependencies...'
  43.     expand_packages(deps, tmpdir)
  44.     pkgname = os.path.basename(head)
  45.     print 'Creating final package (distribution)', pkgname
  46.     flatten(tmpdir, pkgname)
  47.  
  48. if __name__ == '__main__':
  49.     pkgs = sys.argv[1:]
  50.     create_distribution(pkgs)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top