summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-02-11 11:43:54 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-12 00:30:29 +0000
commit3faa635fd408695dd5b754fda3f6060dd670b81d (patch)
treed0ba5d2d4acca9f7748029116f3a74877ee899c9 /bitbake/lib/bb/fetch2
parente56f63a2843e5a7d70fd60e0aaed4d962a277da7 (diff)
downloadpoky-3faa635fd408695dd5b754fda3f6060dd670b81d.tar.gz
fetch2: unpack revision
Revise the unpack function to have a way to disable the unpack. This is based on the work from "Andreas Oberritter <obi@opendreambox.org>", see http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=2bdfe8519eda8067845019a699acdf19a21ba380 In addition, the to_boolean function comes from the work of "Chris Larson <chris_larson@mentor.com>", see http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=900cc29b603691eb3a077cb660545ead3715ed54 Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py92
1 files changed, 53 insertions, 39 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index d8bee063e7..9008121126 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -658,6 +658,13 @@ class FetchMethod(object):
658 import subprocess 658 import subprocess
659 iterate = False 659 iterate = False
660 file = urldata.localpath 660 file = urldata.localpath
661
662 try:
663 unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True)
664 except ValueError, exc:
665 bb.fatal("Invalid value for 'unpack' parameter for %s: %s" %
666 (file, urldata.parm.get('unpack')))
667
661 dots = file.split(".") 668 dots = file.split(".")
662 if dots[-1] in ['gz', 'bz2', 'Z']: 669 if dots[-1] in ['gz', 'bz2', 'Z']:
663 efile = os.path.join(bb.data.getVar('WORKDIR', data, True),os.path.basename('.'.join(dots[0:-1]))) 670 efile = os.path.join(bb.data.getVar('WORKDIR', data, True),os.path.basename('.'.join(dots[0:-1])))
@@ -665,34 +672,41 @@ class FetchMethod(object):
665 efile = file 672 efile = file
666 cmd = None 673 cmd = None
667 674
668 if file.endswith('.tar'): 675 if unpack:
669 cmd = 'tar x --no-same-owner -f %s' % file 676 if file.endswith('.tar'):
670 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): 677 cmd = 'tar x --no-same-owner -f %s' % file
671 cmd = 'tar xz --no-same-owner -f %s' % file 678 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
672 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'): 679 cmd = 'tar xz --no-same-owner -f %s' % file
673 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file 680 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
674 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'): 681 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
675 cmd = 'gzip -dc %s > %s' % (file, efile) 682 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
676 elif file.endswith('.bz2'): 683 cmd = 'gzip -dc %s > %s' % (file, efile)
677 cmd = 'bzip2 -dc %s > %s' % (file, efile) 684 elif file.endswith('.bz2'):
678 elif file.endswith('.tar.xz'): 685 cmd = 'bzip2 -dc %s > %s' % (file, efile)
679 cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file 686 elif file.endswith('.tar.xz'):
680 elif file.endswith('.xz'): 687 cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
681 cmd = 'xz -dc %s > %s' % (file, efile) 688 elif file.endswith('.xz'):
682 elif file.endswith('.zip') or file.endswith('.jar'): 689 cmd = 'xz -dc %s > %s' % (file, efile)
683 cmd = 'unzip -q -o' 690 elif file.endswith('.zip') or file.endswith('.jar'):
684 if 'dos' in urldata.parm: 691 try:
685 cmd = '%s -a' % cmd 692 dos = bb.utils.to_boolean(urldata.parm.get('dos'), False)
686 cmd = "%s '%s'" % (cmd, file) 693 except ValueError, exc:
687 elif file.endswith('.src.rpm') or file.endswith('.srpm'): 694 bb.fatal("Invalid value for 'dos' parameter for %s: %s" %
688 if 'unpack' in urldata.parm: 695 (file, urldata.parm.get('dos')))
689 unpack_file = ("%s" % urldata.parm['unpack']) 696 cmd = 'unzip -q -o'
690 cmd = 'rpm2cpio.sh %s | cpio -i %s' % (file, unpack_file) 697 if dos:
691 iterate = True 698 cmd = '%s -a' % cmd
692 iterate_file = unpack_file 699 cmd = "%s '%s'" % (cmd, file)
693 else: 700 elif file.endswith('.src.rpm') or file.endswith('.srpm'):
694 cmd = 'rpm2cpio.sh %s | cpio -i' % (file) 701 if 'extract' in urldata.parm:
695 else: 702 unpack_file = urldata.parm.get('extract')
703 cmd = 'rpm2cpio.sh %s | cpio -i %s' % (file, unpack_file)
704 iterate = True
705 iterate_file = unpack_file
706 else:
707 cmd = 'rpm2cpio.sh %s | cpio -i' % (file)
708
709 if not unpack or not cmd:
696 # If file == dest, then avoid any copies, as we already put the file into dest! 710 # If file == dest, then avoid any copies, as we already put the file into dest!
697 dest = os.path.join(rootdir, os.path.basename(file)) 711 dest = os.path.join(rootdir, os.path.basename(file))
698 if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)): 712 if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)):
@@ -706,17 +720,17 @@ class FetchMethod(object):
706 destdir = "." 720 destdir = "."
707 elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK): 721 elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
708 os.makedirs("%s/%s" % (rootdir, destdir)) 722 os.makedirs("%s/%s" % (rootdir, destdir))
709 cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir) 723 #cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir)
724 cmd = 'tar -cf - -C "%d" -ps . | tar -xf - -C "%s/%s/"' % (file, rootdir, destdir)
710 else: 725 else:
711 if not 'patch' in urldata.parm: 726 # The "destdir" handling was specifically done for FILESPATH
712 # The "destdir" handling was specifically done for FILESPATH 727 # items. So, only do so for file:// entries.
713 # items. So, only do so for file:// entries. 728 if urldata.type == "file" and urldata.path.find("/") != -1:
714 if urldata.type == "file" and urldata.path.find("/") != -1: 729 destdir = urldata.path.rsplit("/", 1)[0]
715 destdir = urldata.path.rsplit("/", 1)[0] 730 else:
716 else: 731 destdir = "."
717 destdir = "." 732 bb.mkdirhier("%s/%s" % (rootdir, destdir))
718 bb.mkdirhier("%s/%s" % (rootdir, destdir)) 733 cmd = 'cp %s %s/%s/' % (file, rootdir, destdir)
719 cmd = 'cp %s %s/%s/' % (file, rootdir, destdir)
720 734
721 if not cmd: 735 if not cmd:
722 return 736 return
@@ -725,7 +739,7 @@ class FetchMethod(object):
725 save_cwd = os.getcwd(); 739 save_cwd = os.getcwd();
726 os.chdir(rootdir) 740 os.chdir(rootdir)
727 if 'subdir' in urldata.parm: 741 if 'subdir' in urldata.parm:
728 newdir = ("%s/%s" % (rootdir, urldata.parm['subdir'])) 742 newdir = ("%s/%s" % (rootdir, urldata.parm.get('subdir')))
729 bb.mkdirhier(newdir) 743 bb.mkdirhier(newdir)
730 os.chdir(newdir) 744 os.chdir(newdir)
731 745