3 # $FreeBSD: src/tools/tools/upgrade/move_aout_libs.sh,v 1.6 1999/08/28 00:54:34 peter Exp $
4 # $DragonFly: src/tools/tools/upgrade/Attic/move_aout_libs.sh,v 1.2 2003/06/17 04:29:11 dillon Exp $
6 # Search for a.out libraries and move them to an aout subdirectory of
7 # the elf library directory.
9 # The arguments are the directories to search.
13 # Create a temporary tool to get the timestamp of libraries. No, I don't
14 # want to use perl or whatever.
15 create_get_time_stamp ( )
17 echo "#include <stdio.h>" > /tmp/get_time_stamp.c
18 echo "#include <sys/stat.h>" >> /tmp/get_time_stamp.c
19 echo "int main(int argc, char *argv[]) {" >> /tmp/get_time_stamp.c
20 echo "int ierr; struct stat fs;" >> /tmp/get_time_stamp.c
21 echo "if ((ierr = stat(argv[1],&fs)) == 0)" >> /tmp/get_time_stamp.c
22 echo "printf(\"%ld\n\",(long) fs.st_mtime);" >> /tmp/get_time_stamp.c
23 echo "return (ierr); }" >> /tmp/get_time_stamp.c
24 gcc -o /tmp/get_time_stamp /tmp/get_time_stamp.c
25 rm /tmp/get_time_stamp.c
29 # Move an a.out library to the aout subdirectory of the elf directory.
32 if test -d $dir/aout; then
34 echo "Creating directory $dir/aout"
39 if test -f $dir/aout/$fname; then
40 if test -x /tmp/get_time_stamp; then
44 t1=`/tmp/get_time_stamp $dir/aout/$fname`
45 t2=`/tmp/get_time_stamp $file`
46 if test $t1 -gt $t2; then
47 echo $file is older than $dir/aout/$fname
49 while test "$answer" != "y" -a "$answer" != "n"; do
50 read -p "OK to delete the older file? (y/n) " answer
52 if test $answer = "y"; then
57 echo "You need to move $file out of $dir because that's an elf directory"
60 echo $dir/aout/$fname is older than $file
62 while test "$answer" != "y" -a "$answer" != "n"; do
63 read -p "OK to overwrite the older file? (y/n) " answer
65 if test $answer = "y"; then
66 echo Overwriting $dir/aout/$fname with $file
68 mv $file $dir/aout/$fname
71 echo "You need to move $file out of $dir because that's an elf directory"
75 echo Move $fname from $dir to $dir/aout
77 mv $file $dir/aout/$fname
83 # Given a list of files in a directory, find those that are a.out
84 # libraries and move them.
90 # Don't touch symbolic links yet. It's not clear how
91 # they should be handled.
92 if test -h $file; then
94 # Check that this is a normal file.
95 if test -f $file; then
96 # Identify the file by magic
97 filemagic=`file $file`
99 # Check if the file is an a.out library
100 if expr "$filemagic" : ".*$aoutmagic"; then
101 # Move the a.out library
110 # Only search the directories specified.
113 # Make sure the directory exists, or ldconfig will choke later.
114 mkdir -p $dir $dir/aout
116 echo "Searching library directory $dir for a.out libraries..."
118 # Get a list of archive libraries.
119 files=`ls $dir/*.a 2> /dev/null`
121 # a.out archive libraries look like this:
122 aoutmagic="current ar archive random library"
124 # Move each a.out archive library:
127 # Get a list of shared libraries
128 files=`ls $dir/*.so.*.* 2> /dev/null`
130 # a.out shared libraries look like this:
131 aoutmagic="FreeBSD/i386 compact demand paged shared library"
133 # Move each a.out shared library:
137 # If we created the time stamp program, delete it:
138 if test -x /tmp/get_time_stamp; then
139 rm /tmp/get_time_stamp