File: mkunixdists.sh

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (141 lines) | stat: -rwxr-xr-x 4,400 bytes parent folder | download | duplicates (3)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh

################################################################
# mkunixdists.sh -- shell script to generate Unix distributions
#
# Usage: mkunixdists.sh <archive>[.zip] [tmpdir]
#
# This generates all the Unix-specific distributions.  The
# existing ZIP format is fine on Unix too, but we'll generate
# here a .tar.gz in Unix format (no `fix.sh unix' necessary) and
# also an end-user distribution which just creates and installs
# the library, without examples, documentation, etc.  I suppose
# there's a danger that people will download this as a cut-down
# development version, but if we shoot those people then this
# problem will be solved.  This script might need a lot of disk
# space, but no more than the existing zipup.sh needs. :)



################################################################
# First process the arguments

if [ $# -lt 1 -o $# -gt 2 ]; then
	echo "Usage: mkunixdists.sh <archive>[.zip] [tmpdir]"
	exit 1
fi

# Sort out `dir', adding a trailing `/' if necessary
if [ $# -gt 1 ]; then
	dir=$(echo "$2" | sed -e 's/\([^/]\)$/\0\//').tmp
else
	dir=.tmp
fi



################################################################
# Error reporter

error() {
	echo "Error occured, aborting" ; rm -rf $dir ; exit 1
}


################################################################
# Unzip the archive and run fix.sh unix

mkdir $dir || error

echo "Unzipping $1 to $dir"
	unzip -qq $1 -d $dir || error
echo "Running 'fix.sh unix'"
	(cd $dir/allegro && rm -f makefile && . fix.sh unix --dtou >/dev/null) || error
echo "Checking version number"
	basename=$(sed -n -e 's/shared_version = /allegro-/p' $dir/allegro/makefile.ver)
	basename2=$(sed -n -e 's/shared_version = /allegro-enduser-/p' $dir/allegro/makefile.ver)
echo "Renaming 'allegro' to '$basename'"
	mv $dir/allegro $dir/$basename || error

################################################################
# Make .tar.gz distributions

mktargz() {
	echo "Creating $1.tar"
	(cd $dir && tar -cf - $basename) > $1.tar || error
	echo "gzipping to $1.tar.gz"
	gzip $1.tar || error
}

# Create the developers' archive
mktargz $basename

# Hack'n'slash
echo "Stripping to form end-user distribution"
(cd $dir/$basename && {
	(cd src && rm -rf beos qnx dos mac ppc win)
	(cd obj && rm -rf bcc32 beos qnx djgpp mingw32 msvc watcom)
	(cd lib && rm -rf bcc32 beos qnx djgpp mingw32 msvc watcom)
	(cd include && rm -f bealleg.h qnxalleg.h macalleg.h winalleg.h)
	(cd misc && rm -f cmplog.pl dllsyms.lst findtext.sh fixpatch.sh fixver.sh)
	(cd misc && rm -f allegro-config-qnx.sh zipup.sh zipwin.sh *.bat *.c)
	mkdir .saveme
	cp readme.txt docs/build/unix.txt docs/build/linux.txt .saveme
	rm -rf demo docs examples resource setup tests tools
	rm -f AUTHORS CHANGES THANKS *.txt fix* indent* readme.* allegro.mft
	rm -f makefile.all makefile.be makefile.qnx makefile.bcc makefile.dj
	rm -f makefile.mgw makefile.mpw makefile.vc makefile.wat makefile.tst
	rm -f xmake.sh
	rm -f keyboard.dat language.dat
	mv .saveme/* .
	rmdir .saveme
	{       # Tweak makefile.in
		cp makefile.in makefile.old &&
		cat makefile.old |
		sed -e "s/INSTALL_TARGETS = .*/INSTALL_TARGETS = mini-install/" |
		sed -e "s/DEFAULT_TARGETS = .*/DEFAULT_TARGETS = lib modules/" |
		cat > makefile.in &&
		rm -f makefile.old
	}
})

# Create the end users' archive
mktargz $basename2


################################################################
# Create SRPM distribution
#
# We don't actually create the binary RPMs here, since that
# will really need to be done on many different machines.
# Instead we'll build the source RPM.
#
# This requires you to have Red Hat's default RPM build system
# properly set up, so we'll skip it if that's not the case.

rpmdir=
[ -d /usr/src/redhat ] && rpmdir=/usr/src/redhat
[ -d /usr/src/packages ] && rpmdir=/usr/src/packages
[ -d /usr/src/RPM ] && rpmdir=/usr/src/RPM
[ -d /usr/src/rpm ] && rpmdir=/usr/src/rpm

if [ -n "$rpmdir" ]; then
	echo "Creating SRPM"
	echo "Enter your root password if prompted"
	su -c "(\
		cp -f $basename.tar.gz $rpmdir/SOURCES ;\
		cp -f $dir/$basename/misc/alex.xpm $rpmdir/SOURCES ;\
		rpm -bs $dir/$basename/misc/allegro.spec ;\
		mv -f $rpmdir/SRPMS/allegro-*.rpm . ;\
		rm -f $rpmdir/SOURCES/alex.xpm ;\
		rm -f $rpmdir/SOURCES/$basename.tar.gz ;\
	)"
fi


################################################################
# All done!

rm -rf $dir
echo "All done!"