X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=packaging%2Fsun-pkg%2Fbuildpkg;fp=packaging%2Fsun-pkg%2Fbuildpkg;h=af5d0a3b886cc986e123698a8847f6761a51e067;hb=8eb7e8e19f1373f6be7f1f7837b997748ce31d0e;hp=0000000000000000000000000000000000000000;hpb=75cec888bd949240e5ba6780d513ada25a7e5caa;p=debian%2Famanda diff --git a/packaging/sun-pkg/buildpkg b/packaging/sun-pkg/buildpkg new file mode 100755 index 0000000..af5d0a3 --- /dev/null +++ b/packaging/sun-pkg/buildpkg @@ -0,0 +1,303 @@ +#!/bin/sh +# This is useful for debugging +#set -x + +#### CHECKS +if [ ! -f common-src/amanda.h ]; then + echo "Error: 'buildpkg' must be run from the root of an otherwise unused amanda source" + echo " directory." >&2 + exit 1 +fi + +if [ ! -f configure ]; then + echo "Error: The source directory has not been autogen'd -- please download a source" + echo " distribution tarball or run ./autogen. You will need autoconf, automake," + echo " and libtool to run autogen (but not to compile from a distribution tarball)." + exit 1 +fi + +# Until we get package revisioning in community. +[ -f "PKG_REV" ] || echo "1" > PKG_REV + +pkg_root=packaging/sun-pkg +get_version() { + # Get our version using substitute.pl + echo "%%VERSION%%" > ${pkg_root}/version.src + /opt/csw/bin/perl packaging/common/substitute.pl ${pkg_root}/version.src ${pkg_root}/version || exit 1 + VERSION=`cat ${pkg_root}/version` + rm ${pkg_root}/version.src ${pkg_root}/version || exit 1 +} + +do_substitution() { + file_list="client/pkginfo \ + client/preinstall \ + client/postinstall \ + client/postremove \ + server/pkginfo \ + server/preinstall \ + server/postinstall \ + server/postremove" + for file in ${file_list}; do + /opt/csw/bin/perl packaging/common/substitute.pl \ + ${pkg_root}/${file}.src \ + ${pkg_root}/${file} || exit 1 + done + chmod ug+x ${pkg_root}/*/pre* ${pkg_root}/*/post* +} + +do_build() { + # Run for each server and client package. .pkg files don't get whacked. + # $1 must be "client" or "server" + [ x"$1" = x"client" ] || [ x"$1" = x"server" ] || \ + { echo "client or server not given" && exit 1; } + rm -rf ${INSTALL_DEST} ${PKG_DEST} + mkdir ${INSTALL_DEST} ${PKG_DEST} || exit 1 + make distclean + echo "Running configure.." + CONF="$CONF \ + STAR=/opt/csw/bin/star \ + GNUTAR=/opt/csw/bin/gtar \ + --quiet \ + --with-user=amandabackup \ + --with-group=disk \ + --prefix=/${PREFIX} \ + --exec-prefix=/${PREFIX} \ + --sbindir=/${PREFIX}/sbin \ + --sysconfdir=/${ETCDIR} \ + --with-amandates=/${ETCDIR}/amandates \ + --mandir=/${PREFIX}/share/man \ + --with-amlibexecdir=/${amlibdir}/amanda \ + --with-amperldir=/${amlibdir}/amanda/perl \ + --localstatedir=/${LOCALSTATEDIR} \ + --with-amdatadir=/${AMSTATEDIR} \ + --with-gnutar-listdir=/${AMSTATEDIR}/gnutar-lists \ + --with-index-server=localhost \ + --with-tape-server=localhost \ + --with-fqdn \ + --with-bsd-security \ + --with-bsdtcp-security \ + --with-bsdudp-security \ + --with-udpportrange=800,840 \ + --with-tcpportrange=11000,11040 \ + --with-low-tcpportrange=800,840 \ + --with-ssh-security \ + --with-debugging=/${DBGDIR} \ + --with-assertions \ + --with-readline \ + --disable-installperms \ + --disable-syntax-checks \ + --disable-static" + + # PKG_CONFIG_PATH was exported, so is in the environment. + ./configure CFLAGS="${CFLAGS}" \ + CPPFLAGS="${CPPFLAGS}" \ + LDFLAGS="${LDFLAGS}" \ + GLIB_CFLAGS="${GLIB_CFLAGS}" \ + GLIB_LIBS="${GLIB_LIBS}" \ + GLIB_GENMARSHAL=glib-genmarshal \ + GOBJECT_QUERY=gobject-query \ + GLIB_MKENUMS=glib-mkenums \ + ${CONF} || exit 1 + + echo "Building.." + + # rpcgen should be run natively on solaris, linux generated XDR stubs + # are not compatible. Specially when being compiled in 64 bit mode. + # Ideally this should be part of Make. + + (cd ndmp-src;rpcgen ndmp0.x;rpcgen ndmp2.x;rpcgen ndmp3.x;rpcgen ndmp4.x; rpcgen ndmp9.x) + + make || exit 1 + make DESTDIR=${INSTALL_DEST} install || exit 1 + + # the gnulib makefiles create $amlibdir/charset.alias in hopes of "merging" + # it with a similar file from other applications. This doesn't work with + # DESTDIR, and anyway Amanda doesn't need this kind of fanciness because it + # doesn't really use gettext. So we just kill the file. See bug 10955 for + # more detail. + rm -f ${INSTALL_DEST}/${amlibdir}/charset.alias + + echo "Amanda Enterprise Edition - version ${VERSION}" > ${INSTALL_DEST}/${PREFIX}/amanda-release || exit 1 +} + +do_package() { + # First parameter is the subpkg, in all lower case. + subpkg=${1} + gnu_triplet=`/bin/sh ${src_dir}/config/config.guess` + # Some but not all solaris packages have arch-plat-os dependent depend + # files. + if [ -f ${src_dir}/${pkg_root}/${subpkg}/depend-${gnu_triplet} ]; then + # Move the arch-plat-os specific depend file to "depend" + mv ${src_dir}/${pkg_root}/${subpkg}/depend-${gnu_triplet} \ + ${src_dir}/${pkg_root}/${subpkg}/depend || exit 1 + # Delete extra depend-${gnu_triplet} files + rm ${src_dir}/${pkg_root}/${subpkg}/depend-* + fi + cp ${src_dir}/${pkg_root}/${subpkg}/* ${PKG_DEST} || exit 1 + cd ${INSTALL_DEST} || exit 1 + + # amanda does not create /etc/amanda + mkdir -p ${AMSTATEDIR} || exit 1 + mkdir -p ${ETCDIR}/amanda || exit 1 + + # Add the contents of 'pkgproto' along with all installed files to + # 'prototype'. pkgproto will generate file list for provided base + # directories including the base dir. Including base dir in the pkg should + # be avoided as the pkg installation will try to alter the base directory + # permissions and ownership per pkg settings if included. + cat "${PKG_DEST}/pkgproto" \ + >> ${PKG_DEST}/prototype || exit 1 + pkgproto $PREFIX >> ${PKG_DEST}/prototype || exit 1 + + # Using --disable-installperms creates installperms.sh, which this bit of + # perl will merge into the prototype. Note that this perl script is + # perl-5.4 compatible + cat > "${src_dir}/process_proto" <<'EOF' +# make a hash from installperms +open(INSTPERM, "<" . shift @ARGV) or die("open installperms.sh: $!"); +my %installperms = map { + my ($u, $g, $m, $fn) = ($_ =~ /^installperm "([^:"]+)(?:([^:"]+))?" "([^"]*)" "(.*)"/); + $fn =~ s{^/}{}; # pkgproto has files without the leading slash + ($fn, [ $u, $g, $m ]); +} ; +# set user/group/mode from installperms, defaulting to amandabackup:disk +open(PROTO, "<" . shift @ARGV) or die("open proto: $!"); +for my $line () { + if ($line !~ /^[df]/) { + print $line; + next; + } + my ($type, $class, $file, $mode, $user, $group) = split(/ /, $line); + # default to amandabackup:disk, without changing mode + ($user, $group) = ( "amandabackup", "disk" ); + if (exists $installperms{$file}) { + ($u, $g, $m) = @{$installperms{$file}}; + $user = $u if $u; + $group = $g if $g; + $mode = $m if $m; + } + print "$type $class $file $mode $user $group\n"; +} +EOF + + perl "${src_dir}/process_proto" \ + "${src_dir}/installperms.sh" \ + "${PKG_DEST}/prototype" \ + > "${PKG_DEST}/prototype~" || exit 1 + mv "${PKG_DEST}/prototype~" "${PKG_DEST}/prototype" + + # Look for installed files in ${INSTALL_DEST}, send package to ${PKG_DEST} + pkgmk -r ${INSTALL_DEST} -o -f ${PKG_DEST}/prototype -d ${PKG_DEST} \ + || exit 1 + # pkgtrans puts the package back in our src_dir, where I would expected + # it, and "translates" it into a .pkg file at the same time. + + pkgtrans -s ${PKG_DEST} ${src_dir}/AMANamanda-${subpkg}-${VERSION}-${gnu_triplet}.pkg<