2006-12-01 05:50:47 +01:00
|
|
|
#!/usr/bin/env python
|
2007-04-10 00:49:02 +02:00
|
|
|
# Copyright (c) 2006-2007 The Regents of The University of Michigan
|
2006-12-01 05:50:47 +01:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met: redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer;
|
|
|
|
# redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution;
|
|
|
|
# neither the name of the copyright holders nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived from
|
|
|
|
# this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# Authors: Ali Saidi
|
|
|
|
# Steve Reinhardt
|
|
|
|
# Nathan Binkert
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import shutil
|
|
|
|
import sys
|
2007-04-27 21:15:25 +02:00
|
|
|
import time
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
from glob import glob
|
|
|
|
from os import system
|
|
|
|
from os.path import basename, dirname, exists, isdir, isfile, join as joinpath
|
|
|
|
|
|
|
|
def mkdir(*args):
|
|
|
|
path = joinpath(*args)
|
|
|
|
os.mkdir(path)
|
|
|
|
|
2007-04-27 21:15:25 +02:00
|
|
|
def touch(*args, **kwargs):
|
|
|
|
when = kwargs.get('when', None)
|
2006-12-01 05:50:47 +01:00
|
|
|
path = joinpath(*args)
|
2007-04-27 21:15:25 +02:00
|
|
|
os.utime(path, when)
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
def rmtree(*args):
|
|
|
|
path = joinpath(*args)
|
|
|
|
for match in glob(path):
|
|
|
|
if isdir(match):
|
|
|
|
shutil.rmtree(match)
|
|
|
|
else:
|
|
|
|
os.unlink(match)
|
|
|
|
|
|
|
|
def remove(*args):
|
|
|
|
path = joinpath(*args)
|
|
|
|
for match in glob(path):
|
|
|
|
if not isdir(match):
|
|
|
|
os.unlink(match)
|
|
|
|
|
|
|
|
def movedir(srcdir, destdir, dir):
|
|
|
|
src = joinpath(srcdir, dir)
|
|
|
|
dest = joinpath(destdir, dir)
|
|
|
|
|
|
|
|
if not isdir(src):
|
|
|
|
raise AttributeError
|
|
|
|
|
|
|
|
os.makedirs(dirname(dest))
|
|
|
|
shutil.move(src, dest)
|
|
|
|
|
2007-10-31 06:21:55 +01:00
|
|
|
if not isdir('.hg'):
|
2006-12-01 05:50:47 +01:00
|
|
|
sys.exit('Not in the top level of an m5 tree!')
|
|
|
|
|
|
|
|
usage = '%s <destdir> <release name>' % sys.argv[0]
|
|
|
|
|
|
|
|
if len(sys.argv) != 3:
|
|
|
|
sys.exit(usage)
|
|
|
|
|
|
|
|
destdir = sys.argv[1]
|
|
|
|
releasename = sys.argv[2]
|
2006-12-02 07:33:18 +01:00
|
|
|
release_dest = joinpath(destdir, 'release')
|
2007-10-31 06:21:55 +01:00
|
|
|
#encumbered_dest = joinpath(destdir, 'encumbered')
|
2006-12-02 07:33:18 +01:00
|
|
|
release_dir = joinpath(release_dest, releasename)
|
2007-10-31 06:21:55 +01:00
|
|
|
#encumbered_dir = joinpath(encumbered_dest, releasename)
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
if exists(destdir):
|
|
|
|
if not isdir(destdir):
|
|
|
|
raise AttributeError, '%s exists, but is not a directory' % destdir
|
2006-12-02 07:33:18 +01:00
|
|
|
else:
|
|
|
|
mkdir(destdir)
|
|
|
|
|
|
|
|
if exists(release_dest):
|
|
|
|
if not isdir(release_dest):
|
|
|
|
raise AttributeError, \
|
|
|
|
'%s exists, but is not a directory' % release_dest
|
|
|
|
rmtree(release_dest)
|
|
|
|
|
2007-10-31 06:21:55 +01:00
|
|
|
#if exists(encumbered_dest):
|
|
|
|
# if not isdir(encumbered_dest):
|
|
|
|
# raise AttributeError, \
|
|
|
|
# '%s exists, but is not a directory' % encumbered_dest
|
|
|
|
# rmtree(encumbered_dest)
|
2006-12-02 07:33:18 +01:00
|
|
|
|
|
|
|
mkdir(release_dest)
|
2007-10-31 06:21:55 +01:00
|
|
|
#mkdir(encumbered_dest)
|
2006-12-01 05:50:47 +01:00
|
|
|
mkdir(release_dir)
|
2007-10-31 06:21:55 +01:00
|
|
|
#mkdir(encumbered_dir)
|
2007-04-27 21:15:25 +02:00
|
|
|
|
2007-10-31 06:21:55 +01:00
|
|
|
system('hg update')
|
|
|
|
system('rsync -av --exclude ".hg*" --exclude build . %s' % release_dir)
|
2007-04-27 21:15:25 +02:00
|
|
|
# move the time forward on some files by a couple of minutes so we can
|
|
|
|
# avoid building things unnecessarily
|
|
|
|
when = int(time.time()) + 120
|
|
|
|
|
2006-12-01 05:50:47 +01:00
|
|
|
# make sure scons doesn't try to run flex unnecessarily
|
2007-10-31 06:21:55 +01:00
|
|
|
#touch(release_dir, 'src/encumbered/eio/exolex.cc', when=(when, when))
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
# get rid of non-shipping code
|
2007-10-31 06:21:55 +01:00
|
|
|
#rmtree(release_dir, 'src/encumbered/dev')
|
2006-12-01 05:50:47 +01:00
|
|
|
rmtree(release_dir, 'src/cpu/ozone')
|
2007-10-31 06:21:55 +01:00
|
|
|
rmtree(release_dir, 'src/arch/x86')
|
|
|
|
#rmtree(release_dir, 'src/mem/cache/tags/split*.cc')
|
|
|
|
#rmtree(release_dir, 'src/mem/cache/tags/split*.hh')
|
|
|
|
#rmtree(release_dir, 'src/mem/cache/prefetch/ghb_*.cc')
|
|
|
|
#rmtree(release_dir, 'src/mem/cache/prefetch/ghb_*.hh')
|
|
|
|
#rmtree(release_dir, 'src/mem/cache/prefetch/stride_*.cc')
|
|
|
|
#rmtree(release_dir, 'src/mem/cache/prefetch/stride_*.hh')
|
2006-12-01 05:50:47 +01:00
|
|
|
rmtree(release_dir, 'configs/fullsys')
|
|
|
|
rmtree(release_dir, 'configs/test')
|
|
|
|
rmtree(release_dir, 'configs/splash2')
|
|
|
|
rmtree(release_dir, 'tests/long/*/ref')
|
|
|
|
rmtree(release_dir, 'tests/old')
|
2007-10-31 06:21:55 +01:00
|
|
|
rmtree(release_dir, 'tests/quick/00.hello/ref/x86')
|
|
|
|
rmtree(release_dir, 'tests/test-progs/hello/bin/x86')
|
|
|
|
rmtree(release_dir, 'src/dev/x86')
|
|
|
|
|
|
|
|
remove(release_dir, 'src/cpu/nativetrace.hh')
|
|
|
|
remove(release_dir, 'src/cpu/nativetrace.cc')
|
|
|
|
remove(release_dir, 'build_opts/X86_SE')
|
|
|
|
remove(release_dir, 'build_opts/X86_FS')
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
# get rid of some of private scripts
|
|
|
|
remove(release_dir, 'util/chgcopyright')
|
|
|
|
remove(release_dir, 'util/make_release.py')
|
|
|
|
|
2007-04-19 01:56:06 +02:00
|
|
|
def remove_sources(regex, subdir):
|
|
|
|
script = joinpath(release_dir, subdir, 'SConscript')
|
|
|
|
if isinstance(regex, str):
|
|
|
|
regex = re.compile(regex)
|
|
|
|
inscript = file(script, 'r').readlines()
|
|
|
|
outscript = file(script, 'w')
|
|
|
|
for line in inscript:
|
|
|
|
if regex.match(line):
|
|
|
|
continue
|
|
|
|
|
|
|
|
outscript.write(line)
|
|
|
|
outscript.close()
|
2006-12-01 05:50:47 +01:00
|
|
|
|
2007-10-31 06:21:55 +01:00
|
|
|
def remove_lines(s_regex, e_regex, f):
|
|
|
|
f = joinpath(release_dir, f)
|
|
|
|
if isinstance(s_regex, str):
|
|
|
|
s_regex = re.compile(s_regex)
|
|
|
|
if isinstance(e_regex, str):
|
|
|
|
e_regex = re.compile(e_regex)
|
|
|
|
inscript = file(f, 'r').readlines()
|
|
|
|
outscript = file(f, 'w')
|
|
|
|
skipping = False
|
|
|
|
for line in inscript:
|
|
|
|
if (not skipping and s_regex.match(line)) or \
|
|
|
|
(e_regex and skipping and not e_regex.match(line)):
|
2007-10-31 22:52:07 +01:00
|
|
|
if e_regex:
|
|
|
|
skipping = True
|
2007-10-31 06:21:55 +01:00
|
|
|
continue
|
|
|
|
skipping = False
|
|
|
|
outscript.write(line)
|
|
|
|
outscript.close()
|
|
|
|
|
|
|
|
def replace_line(s_regex, f, rl):
|
|
|
|
f = joinpath(release_dir, f)
|
|
|
|
if isinstance(s_regex, str):
|
|
|
|
s_regex = re.compile(s_regex)
|
|
|
|
inscript = file(f, 'r').readlines()
|
|
|
|
outscript = file(f, 'w')
|
|
|
|
for line in inscript:
|
|
|
|
if s_regex.match(line):
|
|
|
|
outscript.write(rl)
|
|
|
|
continue
|
|
|
|
outscript.write(line)
|
|
|
|
outscript.close()
|
2007-04-10 00:49:02 +02:00
|
|
|
|
2007-10-31 06:21:55 +01:00
|
|
|
|
|
|
|
# fix up the SConscript to deal with files we've removed
|
|
|
|
#remove_sources(r'.*split.*\.cc', 'src/mem/cache/tags')
|
|
|
|
#remove_sources(r'.*(ghb|stride)_prefetcher\.cc', 'src/mem/cache/prefetch')
|
|
|
|
remove_sources(r'.*nativetrace.*', 'src/cpu')
|
|
|
|
|
|
|
|
remove_lines(r'.*X86.*', None, 'src/arch/isa_specific.hh')
|
2007-11-02 02:18:08 +01:00
|
|
|
#remove_lines(r'.*X86.*', None, 'src/base/traceflags.py')
|
2007-11-02 02:07:49 +01:00
|
|
|
remove_lines(r'.*X86.*', None, 'AUTHORS')
|
2007-10-31 06:21:55 +01:00
|
|
|
remove_lines(r'.*X86.*', None, 'src/base/loader/object_file.hh')
|
|
|
|
remove_lines(r'.*_X86_.*', '.*else.*', 'src/base/loader/elf_object.cc')
|
|
|
|
remove_lines(r'.*X86_ISA.*', r'^.el.*','src/sim/process.cc')
|
|
|
|
remove_lines(r'.*x86.*', r'.*mips.*','src/cpu/BaseCPU.py')
|
|
|
|
remove_lines(r'.*X86_ISA.*', r'^.*else.*','src/cpu/o3/dyn_inst.hh')
|
|
|
|
remove_lines(r'.*X86_ISA.*', r'.*stay.*','src/cpu/simple/base.cc')
|
|
|
|
remove_lines(r'.*x86.*', r'^if.*','src/cpu/SConscript')
|
|
|
|
|
|
|
|
remove_lines(r'.*makeX86System.*', r'.*makeDualRoot.*','configs/common/FSConfig.py')
|
|
|
|
remove_lines(r'.*X86.*', None, 'configs/example/fs.py')
|
|
|
|
remove_lines(r'.*x86.*', None, 'configs/example/fs.py')
|
|
|
|
|
|
|
|
replace_line(r'.*X86_SE.*', 'util/regress', " 'SPARC_SE,SPARC_FS',")
|
2006-12-01 05:50:47 +01:00
|
|
|
benches = [ 'bzip2', 'eon', 'gzip', 'mcf', 'parser', 'perlbmk',
|
|
|
|
'twolf', 'vortex' ]
|
|
|
|
for bench in benches:
|
|
|
|
rmtree(release_dir, 'tests', 'test-progs', bench)
|
|
|
|
|
2007-10-31 06:21:55 +01:00
|
|
|
#movedir(release_dir, encumbered_dir, 'src/encumbered')
|
|
|
|
rmtree(release_dir, 'tests/test-progs/anagram')
|
|
|
|
rmtree(release_dir, 'tests/quick/20.eio-short')
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
def taritup(directory, destdir, filename):
|
|
|
|
basedir = dirname(directory)
|
|
|
|
tarball = joinpath(destdir, filename)
|
|
|
|
tardir = basename(directory)
|
|
|
|
|
|
|
|
system('cd %s; tar cfj %s %s' % (basedir, tarball, tardir))
|
|
|
|
|
|
|
|
taritup(release_dir, destdir, '%s.tar.bz2' % releasename)
|
2007-10-31 06:21:55 +01:00
|
|
|
#taritup(encumbered_dir, destdir, '%s-encumbered.tar.bz2' % releasename)
|
2006-12-01 05:50:47 +01:00
|
|
|
|
|
|
|
print "release created in %s" % destdir
|
2007-10-31 06:21:55 +01:00
|
|
|
print "don't forget to tag the repository!"
|