# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: sed.py
# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
# The above named program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License version 2 as published by the Free Software Foundation.
# The above named program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public
# License along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# ========== Copyright Header End ============================================
# use baseline file to generate a target specific file.
# usage: sed.py base_file [key1:val1,key2:val2,...] dest_file
# replace every @-keyX-@ in base_file with valX, and store the final
if __name__
== '__main__':
sys
.stdout
.write('usage: python %s base-file [key1:val1,key2:val2,...] dest-file\n' % (sys
.argv
[0]))
if not options
.has_key(key
):
sys
.stdout
.write('ERROR: %s: duplicate option "%s"\n' % (sys
.argv
[0], key
))
tmp1
= os
.path
.basename(dest_file
) + '_tmp1'
tmp2
= os
.path
.basename(dest_file
) + '_tmp2'
os
.system('/usr/bin/cp -f %s %s' % (base_file
, tmp1
))
for key
in options
.keys():
cmd
= "/usr/bin/sed 's!@-%s-@!%s!g' < %s > %s" % (key
, options
[key
], tmp1
, tmp2
)
os
.system('/usr/bin/cp -f %s %s' % (tmp2
, tmp1
))
os
.system('/usr/bin/cp -f %s %s' % (tmp1
, dest_file
))