Extract a source archive into 'builddir'. Returns the path of the extracted archive. XXX: This function assumes that archives contain a toplevel directory that is has the same name as the basename of the archive. This is safe enough for almost anything we use. Unfortunately, i
(builddir, archiveName)
| 717 | print("") |
| 718 | |
| 719 | def extractArchive(builddir, archiveName): |
| 720 | """ |
| 721 | Extract a source archive into 'builddir'. Returns the path of the |
| 722 | extracted archive. |
| 723 | |
| 724 | XXX: This function assumes that archives contain a toplevel directory |
| 725 | that is has the same name as the basename of the archive. This is |
| 726 | safe enough for almost anything we use. Unfortunately, it does not |
| 727 | work for current Tcl and Tk source releases where the basename of |
| 728 | the archive ends with "-src" but the uncompressed directory does not. |
| 729 | For now, just special case Tcl and Tk tar.gz downloads. |
| 730 | """ |
| 731 | curdir = os.getcwd() |
| 732 | try: |
| 733 | os.chdir(builddir) |
| 734 | if archiveName.endswith('.tar.gz'): |
| 735 | retval = os.path.basename(archiveName[:-7]) |
| 736 | if ((retval.startswith('tcl') or retval.startswith('tk')) |
| 737 | and retval.endswith('-src')): |
| 738 | retval = retval[:-4] |
| 739 | # Strip rcxx suffix from Tcl/Tk release candidates |
| 740 | retval_rc = retval.find('rc') |
| 741 | if retval_rc > 0: |
| 742 | retval = retval[:retval_rc] |
| 743 | if os.path.exists(retval): |
| 744 | shutil.rmtree(retval) |
| 745 | fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') |
| 746 | |
| 747 | elif archiveName.endswith('.tar.bz2'): |
| 748 | retval = os.path.basename(archiveName[:-8]) |
| 749 | if os.path.exists(retval): |
| 750 | shutil.rmtree(retval) |
| 751 | fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r') |
| 752 | |
| 753 | elif archiveName.endswith('.tar'): |
| 754 | retval = os.path.basename(archiveName[:-4]) |
| 755 | if os.path.exists(retval): |
| 756 | shutil.rmtree(retval) |
| 757 | fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r') |
| 758 | |
| 759 | elif archiveName.endswith('.zip'): |
| 760 | retval = os.path.basename(archiveName[:-4]) |
| 761 | if os.path.exists(retval): |
| 762 | shutil.rmtree(retval) |
| 763 | fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r') |
| 764 | |
| 765 | data = fp.read() |
| 766 | xit = fp.close() |
| 767 | if xit is not None: |
| 768 | sys.stdout.write(data) |
| 769 | raise RuntimeError("Cannot extract %s"%(archiveName,)) |
| 770 | |
| 771 | return os.path.join(builddir, retval) |
| 772 | |
| 773 | finally: |
| 774 | os.chdir(curdir) |
| 775 | |
| 776 | def downloadURL(url, fname): |
no test coverage detected
searching dependent graphs…