2 # This is useful for debugging
5 if [ "$1" = "-v" ]; then
9 silent_make_flags="-s LIBTOOLFLAGS=--silent"
12 if [ ! -f common-src/amanda.h ]; then
13 echo "Error: 'buildpkg' must be run from the root of an otherwise unused amanda source"
14 echo " directory." >&2
18 if [ ! -f configure ]; then
19 echo "Error: The source directory has not been autogen'd -- please download a source"
20 echo " distribution tarball or run ./autogen. You will need autoconf, automake,"
21 echo " and libtool to run autogen (but not to compile from a distribution tarball)."
25 # Until we get package revisioning in community.
26 [ -f "PKG_REV" ] || echo "1" > PKG_REV
28 pkg_root=packaging/sun-pkg
30 # Get our version using substitute.pl
31 echo "%%VERSION%%" > ${pkg_root}/version.src
32 /opt/csw/bin/perl packaging/common/substitute.pl ${pkg_root}/version.src ${pkg_root}/version || exit 1
33 VERSION=`cat ${pkg_root}/version`
34 rm ${pkg_root}/version.src ${pkg_root}/version || exit 1
38 file_list="client/pkginfo \
46 for file in ${file_list}; do
47 /opt/csw/bin/perl packaging/common/substitute.pl \
48 ${pkg_root}/${file}.src \
49 ${pkg_root}/${file} || exit 1
51 chmod ug+x ${pkg_root}/*/pre* ${pkg_root}/*/post*
55 # Run for each server and client package. .pkg files don't get whacked.
56 # $1 must be "client" or "server"
57 [ x"$1" = x"client" ] || [ x"$1" = x"server" ] || \
58 { echo "client or server not given" && exit 1; }
59 rm -rf ${INSTALL_DEST} ${PKG_DEST}
60 mkdir ${INSTALL_DEST} ${PKG_DEST} || exit 1
61 make ${silent_make_flags} distclean
62 echo "Running configure.."
64 STAR=/opt/csw/bin/star \
65 GNUTAR=/opt/csw/bin/gtar \
67 --with-user=amandabackup \
70 --exec-prefix=/${PREFIX} \
71 --sbindir=/${PREFIX}/sbin \
72 --sysconfdir=/${ETCDIR} \
73 --with-amandates=/${ETCDIR}/amandates \
74 --mandir=/${PREFIX}/share/man \
75 --with-amlibexecdir=/${amlibdir}/amanda \
76 --with-amperldir=/${amlibdir}/amanda/perl \
77 --localstatedir=/${LOCALSTATEDIR} \
78 --with-amdatadir=/${AMSTATEDIR} \
79 --with-gnutar-listdir=/${AMSTATEDIR}/gnutar-lists \
80 --with-index-server=localhost \
81 --with-tape-server=localhost \
84 --with-bsdtcp-security \
85 --with-bsdudp-security \
86 --with-udpportrange=800,840 \
87 --with-tcpportrange=11000,11040 \
88 --with-low-tcpportrange=800,840 \
90 --with-debugging=/${DBGDIR} \
93 --disable-installperms \
94 --disable-syntax-checks \
97 # PKG_CONFIG_PATH was exported, so is in the environment.
98 ./configure CFLAGS="${CFLAGS}" \
99 CPPFLAGS="${CPPFLAGS}" \
100 LDFLAGS="${LDFLAGS}" \
101 GLIB_CFLAGS="${GLIB_CFLAGS}" \
102 GLIB_LIBS="${GLIB_LIBS}" \
103 GLIB_GENMARSHAL=glib-genmarshal \
104 GOBJECT_QUERY=gobject-query \
105 GLIB_MKENUMS=glib-mkenums \
110 # rpcgen should be run natively on solaris, linux generated XDR stubs
111 # are not compatible. Specially when being compiled in 64 bit mode.
112 # Ideally this should be part of Make.
114 (cd ndmp-src;rpcgen ndmp0.x;rpcgen ndmp2.x;rpcgen ndmp3.x;rpcgen ndmp4.x; rpcgen ndmp9.x)
116 make ${silent_make_flags}|| exit 1
117 make ${silent_make_flags} DESTDIR=${INSTALL_DEST} install || exit 1
119 # the gnulib makefiles create $amlibdir/charset.alias in hopes of "merging"
120 # it with a similar file from other applications. This doesn't work with
121 # DESTDIR, and anyway Amanda doesn't need this kind of fanciness because it
122 # doesn't really use gettext. So we just kill the file. See bug 10955 for
124 rm -f ${INSTALL_DEST}/${amlibdir}/charset.alias
126 echo "Amanda Enterprise Edition - version ${VERSION}" > ${INSTALL_DEST}/${PREFIX}/amanda-release || exit 1
130 # First parameter is the subpkg, in all lower case.
132 gnu_triplet=`/bin/sh ${src_dir}/config/config.guess`
133 # Some but not all solaris packages have arch-plat-os dependent depend
135 if [ -f ${src_dir}/${pkg_root}/${subpkg}/depend-${gnu_triplet} ]; then
136 # Move the arch-plat-os specific depend file to "depend"
137 mv ${src_dir}/${pkg_root}/${subpkg}/depend-${gnu_triplet} \
138 ${src_dir}/${pkg_root}/${subpkg}/depend || exit 1
139 # Delete extra depend-${gnu_triplet} files
140 rm ${src_dir}/${pkg_root}/${subpkg}/depend-*
142 cp ${src_dir}/${pkg_root}/${subpkg}/* ${PKG_DEST} || exit 1
143 cd ${INSTALL_DEST} || exit 1
145 # amanda does not create /etc/amanda
146 mkdir -p ${AMSTATEDIR} || exit 1
147 mkdir -p ${ETCDIR}/amanda || exit 1
149 # Add the contents of 'pkgproto' along with all installed files to
150 # 'prototype'. pkgproto will generate file list for provided base
151 # directories including the base dir. Including base dir in the pkg should
152 # be avoided as the pkg installation will try to alter the base directory
153 # permissions and ownership per pkg settings if included.
154 cat "${PKG_DEST}/pkgproto" \
155 >> ${PKG_DEST}/prototype || exit 1
156 pkgproto $PREFIX ${AMSTATEDIR} ${ETCDIR}/amanda >> ${PKG_DEST}/prototype || exit 1
158 # Using --disable-installperms creates installperms.sh, which this bit of
159 # perl will merge into the prototype. Note that this perl script is
160 # perl-5.4 compatible
161 cat > "${src_dir}/process_proto" <<'EOF'
162 # make a hash from installperms
163 open(INSTPERM, "<" . shift @ARGV) or die("open installperms.sh: $!");
164 my %installperms = map {
165 my ($u, $g, $m, $fn) = ($_ =~ /^installperm "([^:"]+)(?:([^:"]+))?" "([^"]*)" "(.*)"/);
166 $fn =~ s{^/}{}; # pkgproto has files without the leading slash
167 ($fn, [ $u, $g, $m ]);
169 # set user/group/mode from installperms, defaulting to amandabackup:disk
170 open(PROTO, "<" . shift @ARGV) or die("open proto: $!");
171 for my $line (<PROTO>) {
172 if ($line !~ /^[df]/) {
176 my ($type, $class, $file, $mode, $user, $group) = split(/ /, $line);
177 # default to amandabackup:disk, without changing mode
178 ($user, $group) = ( "amandabackup", "disk" );
179 if (exists $installperms{$file}) {
180 ($u, $g, $m) = @{$installperms{$file}};
185 print "$type $class $file $mode $user $group\n";
189 perl "${src_dir}/process_proto" \
190 "${src_dir}/installperms.sh" \
191 "${PKG_DEST}/prototype" \
192 > "${PKG_DEST}/prototype~" || exit 1
193 mv "${PKG_DEST}/prototype~" "${PKG_DEST}/prototype"
195 # Look for installed files in ${INSTALL_DEST}, send package to ${PKG_DEST}
196 pkgmk -r ${INSTALL_DEST} -o -f ${PKG_DEST}/prototype -d ${PKG_DEST} \
198 # pkgtrans puts the package back in our src_dir, where I would expected
199 # it, and "translates" it into a .pkg file at the same time.
201 pkgtrans -s ${PKG_DEST} ${src_dir}/AMANamanda-${subpkg}-${VERSION}-${gnu_triplet}.pkg<<EOF
204 cd ${src_dir} || exit 1
213 PKG_TMP=`pwd`/pkg_${VERSION}; export PKG_TMP
214 INSTALL_DEST=${PKG_TMP}/install; export INSTALL_DEST
215 PKG_DEST=${PKG_TMP}/pkg; export PKG_DEST
217 # Explanation of solaris paths:
218 # /opt/SUNWspro/*: Sun compiler, NOT USED FOR PACKAGING.
219 # /opt/csw/*: OpenCSW.
220 # /usr/ccs/*: sun compilation tools (ld, lex, yacc)
221 # /usr/sfw/*: SunFreeware, sometimes. (solaris 10)
222 # /usr/local/*: SunFreeware, othertimes. (solaris 8)
230 mkdir ${PKG_TMP} || exit 1
232 PATH=/opt/csw/bin:/usr/bin:/usr/sbin:/usr/ccs/bin;export PATH
233 # Compile 32bit because csw perl is 32bit and native is too old.
234 CFLAGS="-O2 -pipe -m32"; export CFLAGS
235 CPPFLAGS="-I/opt/csw/include"; export CPPFLAGS
236 # Not Absolute! Remember to prefix a "/" except in pkgproto.
237 PREFIX=opt/amanda; export PREFIX # Not absolute.
238 amlibdir=${PREFIX}/lib # Not absolute
239 LOCALSTATEDIR=var; export LOCALSTATEDIR
240 AMSTATEDIR=${LOCALSTATEDIR}/lib/amanda; export AMSTATEDIR
241 ETCDIR=etc; export ETCDIR
242 DBGDIR=${LOCALSTATEDIR}/log; export DBGDIR
243 # Each client and server and platform combination gets different compile options
244 if [ "x${1}" = "xclient" ] || [ "x${1}" = "x" ]; then
246 # Variables with spaces must be entered on the configure line separate from
247 # CONF to maintain quoting.
248 LDFLAGS="-L/usr/lib -R/usr/lib \
249 -L/opt/csw/lib -R/opt/csw/lib \
250 -Wl,-z,ignore"; export LDFLAGS
251 PKG_CONFIG_PATH="/usr/lib/pkgconfig"; export PKG_CONFIG_PATH
252 if [ "x$arch" = "xsparc" -a "x$os_rel" = "x5.10" ]; then
253 # Use explicit flags for GLIB, because pkgconfig provides flags
254 # for SunStudio compiler (not compatible with gcc).
255 GLIB_CFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"; export GLIB_CFLAGS
256 GLIB_LIBS="-lglib-2.0 -lgobject-2.0 -lgthread-2.0"; export GLIB_LIBS
257 elif [ "x$arch" = "xi386" -a "x$os_rel" = "x5.10" ]; then
258 GLIB_CFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"; export GLIB_CFLAGS
259 GLIB_LIBS="-lglib-2.0 -lgobject-2.0 -lgthread-2.0"; export GLIB_LIBS
260 elif [ "x$arch" = "xsparc" -a "x$os_rel" = "x5.8" ]; then
261 # CSW glib2.0 flags for gcc. CSW compiles with Sunstudio, so some
263 GLIB_CFLAGS="-I/opt/csw/include/glib-2.0 -I/opt/csw/lib/glib-2.0/include"; export GLIB_CFLAGS
264 GLIB_LIBS="-lglib-2.0 -lintl -lgobject-2.0 -lgthread-2.0"; export GLIB_LIBS
265 CC="/usr/local/bin/gcc"
267 CONF="--with-amlibdir=/${amlibdir} \
269 --disable-s3-device \
271 PERL=/opt/csw/bin/perl"; export CONF
277 if [ "x${1}" = "xserver" ] || [ "x${1}" = "x" ]; then
278 LDFLAGS="-L/usr/lib -R/usr/lib \
279 -L/opt/csw/lib -R/opt/csw/lib \
281 -Wl,-z,ignore"; export LDFLAGS
282 PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/pkgconfig:/opt/csw/lib/pkgconfig"; export PKG_CONFIG_PATH
283 if [ "x$arch" = "xsparc" -a "x$os_rel" = "x5.10" ]; then
284 # Use explicit flags for GLIB, because pkgconfig provides flags
285 # for SunStudio compiler (not compatible with gcc).
286 GLIB_CFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"; export GLIB_CFLAGS
287 GLIB_LIBS="-lglib-2.0 -lgobject-2.0 -lgthread-2.0"; export GLIB_LIBS
288 elif [ "x$arch" = "xi386" -a "x$os_rel" = "x5.10" ]; then
289 GLIB_CFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"; export GLIB_CFLAGS
290 GLIB_LIBS="-lglib-2.0 -lgobject-2.0 -lgthread-2.0"; export GLIB_LIBS
291 elif [ "x$arch" = "xsparc" -a "x$os_rel" = "x5.8" ]; then
292 msg="We don't support server on Solaris 5.8."
293 # if we were run with no arguments, then this is not an error, just a warning
294 if [ "x${1}" = "x" ]; then
302 CONF="--with-amlibdir=/${amlibdir} \
304 --with-libcurl=/opt/csw \
305 CC=/usr/sfw/bin/gcc \
306 PERL=/opt/csw/bin/perl \
307 MTX=/opt/csw/sbin/mtx" ; export CONF