from itertools import imap
import os
import re
import sys
import tarfile

def dontpack(fn):
    return '/.' in fn or '/CVS/' in fn

def package(indir, outfile):
    try:
        tarball = tarfile.open(outfile, 'w:bz2')
        tarball.dereference = True

        rtname = os.path.split(os.path.normpath(indir))[1]

        # package bin, etc
        subdirs = ['bin', 'lib', 'module', 'python']

        for (path, dirs, files) in os.walk(indir):
            if 'data' not in dirs:
                continue

            rtpath = os.path.join(os.path.relpath(path, indir), 'data')
            subdirs.append(rtpath)

        for subdir in subdirs:
            inname = os.path.join(indir, subdir)
            if not os.path.isdir(inname):
                continue
            outname = os.path.join(rtname, subdir)
            print "packing", subdir
            tarball.add(inname, outname, exclude=dontpack)

        tarball.close()
    except:
        raise

@@ -95,23 +95,48 @@
   re
-turn '/.
+s = ('/.' in fn and not '/.SCRAM
 ' in fn
+)
  or 
@@ -148,16 +148,78 @@
 /' in fn
+%0A    if res:%0A        return True%0A    print fn%0A    return False
 %0A%0Adef pa
@@ -442,19 +442,39 @@
 irs = %5B'
-bin
+.SCRAM', 'bin', 'config
 ', 'lib'

Add the bits that cmsenv/cmsRun actually need.