code: def extractArchive(builddir, archiveName):
      """
      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, it does not
      work for current Tcl and Tk source releases where the basename of
      the archive ends with "-src" but the uncompressed directory does not.
      For now, just special case Tcl and Tk tar.gz downloads.
      """
      curdir = os.getcwd()
      try:
          os.chdir(builddir)
          if archiveName.endswith(".tar.gz"):
              retval = os.path.basename(archiveName[:-7])
              if (
                  retval.startswith("tcl") or retval.startswith("tk")
              ) and retval.endswith("-src"):
                  retval = retval[:-4]
                  # Strip rcxx suffix from Tcl/Tk release candidates
                  retval_rc = retval.find("rc")
                  if retval_rc > 0:
                      retval = retval[:retval_rc]
              if os.path.exists(retval):
                  shutil.rmtree(retval)
              fp = os.popen(
                  "tar zxf %s 2>&1" % (shellQuote(archiveName),), "r"
              )
  
          elif archiveName.endswith(".tar.bz2"):
              retval = os.path.basename(archiveName[:-8])
              if os.path.exists(retval):
                  shutil.rmtree(retval)
              fp = os.popen(
                  "tar jxf %s 2>&1" % (shellQuote(archiveName),), "r"
              )
  
          elif archiveName.endswith(".tar"):
              retval = os.path.basename(archiveName[:-4])
              if os.path.exists(retval):
                  shutil.rmtree(retval)
              fp = os.popen(
                  "tar xf %s 2>&1" % (shellQuote(archiveName),), "r"
              )
  
          elif archiveName.endswith(".zip"):
              retval = os.path.basename(archiveName[:-4])
              if os.path.exists(retval):
                  shutil.rmtree(retval)
              fp = os.popen(
                  "unzip %s 2>&1" % (shellQuote(archiveName),), "r"
              )
  
          data = fp.read()
          xit = fp.close()
          if xit is not None:
              sys.stdout.write(data)
              raise RuntimeError("Cannot extract %s" % (archiveName,))
  
          return os.path.join(builddir, retval)
  
      finally:
          os.chdir(curdir)
  
imports: import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp
label_desc: Use image node_id 22 for calling a global function with example usage: extractArchive(builddir, archiveName) and returns: os