-
Notifications
You must be signed in to change notification settings - Fork 5
/
fix.sh
executable file
·116 lines (104 loc) · 2.25 KB
/
fix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
#
# This script has been ripped from the Allegro game library.
# It handles the CR/LF in the text files so that there are
# no conflicts between DOS/Windows and UNIX text readers.
proc_help()
{
echo "Usage: ./fix.sh {unix|dos}"
exit 1
}
proc_fix_unix()
{
proc_filelist
FILELIST="$FILELIST `find . -type f "(" \
-name "*.sh" -o \
-name "*.in" -o \
-name "config.guess" -o \
-name "config.sub" -o \
-name "install-sh" -o \
-name "liquidward" \
")"`"
proc_dtou
proc_chmod
}
proc_fix_dos()
{
proc_filelist
FILELIST="$FILELIST `find . -type f "(" \
-name "*.bat" -o \
-name "*.js" \
")"`"
proc_utod
}
proc_filelist()
{
# common files.
FILELIST=`find . -type f "(" \
-name "*.c" -o \
-name "*.h" -o \
-name "*.s" -o \
-name "*.txt" -o \
-name "*.xml" -o \
-name "*.html" -o \
-name "*.tex" -o \
-name "*.texi" -o \
-name "*.man" -o \
-name "*.py" -o \
-name "*.win" -o \
-name "*.dos" -o \
-name "ALLEGRO" -o \
-name "COPYING" -o \
-name "INSTALL" -o \
-name "README" -o \
-name "README.*" -o \
-name "ChangeLog" \
")"`
}
proc_chmod()
{
echo "Changing file attributes..."
find . -type d | xargs chmod 755
find . -type f | xargs chmod 644
find . -type f "(" \
-name "configure" -o \
-name "config.status" -o \
-name "config.guess" -o \
-name "config.sub" -o \
-name "install-sh" -o \
-name "*.sh" -o \
-name "liquidwar" -o \
-name "liquidwar-server" -o \
-name "liquidward" \
")" | xargs chmod 755
}
proc_utod()
{
echo "Converting files from Unix to DOS/Win32..."
for file in $FILELIST; do
#echo "$file"
cp $file _tmpfile
perl -p -i -e "s/([^\r]|^)\n/\1\r\n/" _tmpfile
touch -r $file _tmpfile
mv _tmpfile $file
done
}
proc_dtou()
{
echo "Converting files from DOS/Win32 to Unix..."
for file in $FILELIST; do
#echo "$file"
mv $file _tmpfile
tr -d '\015' < _tmpfile > $file
touch -r _tmpfile $file
rm _tmpfile
done
}
# prepare allegro for the given platform.
case "$1" in
"unix" ) proc_fix_unix;;
"dos" ) proc_fix_dos;;
* ) proc_help;;
esac
echo "Done!"
exit 0