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