aboutsummaryrefslogtreecommitdiff
path: root/release/scripts/X11/build_x.sh
blob: f32da1bfa1cf60eca00e58d9f34b62c8d8ee0d02 (plain) (blame)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/sh
#
# This script builds X 3.3.x from the XFree86 and XFree86-contrib ports and
# installs it into a work directory.  Once that is done, it uses XFree86's
# build-bindist command to package up the binary dists leaving them stored
# in the 'dist/bindist' subdirectory of the specified output directory.

# usage information
#
usage() {
	echo "$0 <work dir> <output dir>"
	echo
	echo "Where <output dir> is the base directory to install X into,"
	echo "and <work dir> is a scratch directory that the XFree86 ports"
	echo "can be checked out into and built.  This script also assumes"
	echo "that it can get the distfiles from /usr/ports/distfiles (or"
	echo "fetch them into that directory).  The CVSROOT environment"
	echo "variable should point to a FreeBSD CVS repository."
	echo
	echo "Before running this script, the following packages should be"
	echo "installed:"
	echo "	XFree86"
	echo "	Tcl83, Tk83"
	echo "	ja-Tcl80, ja-Tk80"
	echo
	echo "Also, this should really be run as root."
	exit 1
}

# check the command line
if [ $# -ne 2 ]; then
	usage
fi

# check $CVSROOT
if [ -z "$CVSROOT" ]; then
	echo "\$CVSROOT not set!"
	echo
	usage
fi

# setup the output directory
output_dir=$2
echo ">>> preparing output directory: ${output_dir}"
case $output_dir in
	/*)
		;;
	*)
		output_dir=`pwd`/${output_dir}
		;;
esac
if [ -r ${output_dir} ]; then
	if ! rm -rf ${output_dir}; then
		echo "Could not remove ${output_dir}!"
		echo
		usage
	fi
fi
if ! mkdir -p ${output_dir}; then
	echo "Could not create ${output_dir}!"
	echo
	usage
fi
if ! rmdir ${output_dir}; then
	echo "Could not remove ${output_dir} the second time!"
	echo
	usage
fi

# setup the work directory
work_dir=$1
echo ">>> preparing work directory: ${work_dir}"
if [ -r ${work_dir} ]; then
	if ! rm -rf ${work_dir}; then
		echo "Could not remove ${work_dir}!"
		echo
		usage
	fi
fi
if ! mkdir -p ${work_dir}; then
	echo "Could not create ${work_dir}!"
	echo
	usage
fi
if ! mkdir ${work_dir}/base; then
	echo "Could not create ${work_dir}/base!"
	echo
	usage
fi
if ! mkdir ${work_dir}/dist; then
	echo "Could not create ${work_dir}/dist!"
	echo
	usage
fi
if ! mkdir ${work_dir}/ports; then
	echo "Could not create ${work_dir}/ports!"
	echo
	usage
fi

# check out the XFree86 and XFree86-contrib ports and set them up
echo ">>> checking out ports"
if ! ( cd ${work_dir}/ports && \
    cvs -R -d ${CVSROOT} co -P XFree86 XFree86-contrib ); then
	echo "Could not checkout the XFree86 port!"
	echo
	usage
fi
if [ -r  XF86.patch ]; then
	echo ">>> patching ports"
	if ! patch -d ${work_dir}/ports/XFree86 < XF86.patch; then
		echo "Could not patch the XFree86 port!"
		echo
		usage
	fi
fi

# actually build X
echo ">>> building X"
if ! ( cd ${work_dir}/ports/XFree86 && \
    make BUILD_XDIST=yes DISTDIR=/usr/ports/distfiles \
    DESTDIR=${work_dir}/base NO_PKG_REGISTER=yes all install ); then
	echo "Could not build XFree86!"
	echo
	usage
fi
if ! ( cd ${work_dir}/ports/XFree86-contrib && \
    make DISTDIR=/usr/ports/distfiles DESTDIR=${work_dir}/base \
    NO_PKG_REGISTER=yes all install ); then
	echo "Could not build XFree86-contrib!"
	echo
	usage
fi

# now package up the bindists
echo ">>> building bindist"
bindist_dir=${work_dir}/ports/XFree86/work/xc/programs/Xserver/hw/xfree86/etc/bindist
if ! cp ${bindist_dir}/FreeBSD-ELF/* ${work_dir}/dist; then
	echo "Could not copy over distribution lists!"
	echo
	usage
fi
if ! cp ${bindist_dir}/common/* ${work_dir}/dist; then
	echo "Could not copy over distribution lists!"
	echo
	usage
fi
if ! ${bindist_dir}/build-bindist X ${work_dir}/base ${work_dir}/dist; then
	echo "Could not package up binary dists!"
	echo
	usage
fi
if ! mv ${work_dir}/dist/bindist ${output_dir}; then
	echo "Could not move binary dists into ${output_dir}!"
	echo
	usage
fi