#!/usr/bin/env perl

##**************************************************************
##
## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
## University of Wisconsin-Madison, WI.
## 
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License.  You may
## obtain a copy of the License at
## 
##    http://www.apache.org/licenses/LICENSE-2.0
## 
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##**************************************************************



# This script performs all steps necessary to make the
# static_dir/release.tar file on platforms where special magic must be
# done.  It should be run in the top-level src directory.
#
# For now, this is specific to Linux/glibc21, where the statically
# linked version needs to include seperate lib subdirectories for each
# version of libc that we might be installed on: libc5, glibc20, and
# glibc21.  We get the libc5 and glibc20 versions from tarballs in
# AFS land that are put there by the build on other platforms.
#
# Derek Wright <wright@cs.wisc.edu>, 11/3/99

# Autoflush the output
$| = 1;

umask(022);
chomp($home_dir = `pwd`);

# First, create all the appropriate subdirs
mkdir( "static_dir/lib/libc5", 0777 );
mkdir( "static_dir/lib/glibc20", 0777 );
mkdir( "static_dir/lib/glibc21", 0777 );

# Now, move all the platform specific stuff out of static_dir/lib into
# the glibc21 subdir.
`mv static_dir/lib/*.[oa] static_dir/lib/glibc21`;

# Next, unpack the libtar files in AFS land into the appropriate
# subdirs:
foreach $lib ( "libc5", "glibc20") {
    print "Working on $lib...\n";
    $afs_file = "/p/condor/workspaces/release/libtars/lib-$lib.tar";
    chdir( "static_dir/lib/$lib" );
    print `tar -xvf $afs_file`;
    chdir( $home_dir );
}
	
# Now, we're nearly done.  All we have to do is make the release.tar
# file itself...
chdir( "static_dir" );
print "Making release.tar...\n";
print `tar -cvf release.tar etc include lib bin sbin`;
print "Done.\n";
