All pastes #384106 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-06 20:43 UTC
rendered paste body
#!/bin/sh
#
# Copyright 2005 Paul Blazejowski and Zach Borgerding <zborgerd@gmail.com>
# Available under the terms of the GNU GPL.
#

NAME="pam"
VERSION="0.99.6.2"
REVISION="1"
REDHAT_VERSION="2"
PKG_SOURCEURL='http://www.kernel.org/pub/linux/libs/pam/pre/library/Linux-PAM-$VERSION.tar.bz2'
PKG_SOURCEMD5=''

PKG_DISABLESMP="yupyup"

PKG_PATCH[0]="pam-0.99.3.0-cracklib-try-first-pass.patch"
PKG_PATCH[1]="pam-0.99.3.0-tally-fail-close.patch"
PKG_PATCH[2]="pam-0.99.4.0-dbpam.patch"
PKG_PATCH[3]="pam-0.99.5.0-redhat-modules.patch"
PKG_PATCH[4]="pam-0.99.6.0-succif-session.patch"
PKG_PATCH[5]="pam-0.99.6.2-dropline-50-default.perms.patch"
# Not really "patches" here.  Just keeping the extra build stuff in the package.
PKG_PATCH[6]="doinst.sh"
PKG_PATCH[7]="config-util.5"
PKG_PATCH[8]="config-util.pamd"
PKG_PATCH[9]="dlopen.sh"
PKG_PATCH[10]="other.pamd"
PKG_PATCH[11]="pam-redhat-0.99.6.2-2.tar.bz2"
PKG_PATCH[12]="system-auth.5"
PKG_PATCH[13]="system-auth.pamd"


. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

cflags
cxxflags
export CFLAGS="-fPIC"
PKG_NEEDSTATIC=1
prepare

spewdo "cd $PKG_SRCROOT"
findpatch filename pam-redhat-$VERSION-$REDHAT_VERSION.tar.bz2
spewdo "tar xjf $filename"

echo "Yay for patches!"

applypatch 0 1
applypatch 1 1
applypatch 2 1
applypatch 3 1
applypatch 4 0
applypatch 5 1

# Let's copy the PAM module README files to /usr/doc/pam-$VERSION/
mkdir -p $PKG_STAGEROOT$PKG_PREFIX/doc/pam-$VERSION/
for readme in modules/pam_*/README ; do
        cp -f ${readme} $PKG_STAGEROOT$PKG_PREFIX/doc/pam-$VERSION/README.`dirname ${readme} | sed -e 's|^modules/||'`
done

analyzesource

# Non threaded build of BDB
(
TOPDIR=$DLG_WORKROOT/pam-instroot

if [ -d $DLG_WORKROOT/pam-instroot ]; then
        rm -rf $DLG_WORKROOT/pam-instroot
fi

createdir $TOPDIR/lib64
PKG_BUILDDIR="build_unix"
PKG_SRCREL="../dist"

NAME="db"
VERSION="4.3.29"
PKG_SOURCEURL='http://download.oracle.com/berkeley-db/$NAME-$VERSION.tar.gz'

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

cflags
cxxflags
PKG_NEEDSTATIC=1
prepare
analyzesource
spewdo "echo db_cv_mutex=UNIX/fcntl > $PKG_WORKROOT/$NAME-$VERSION/$PKG_BUILDDIR/config.cache"
configure -C \
	--disable-compat185 \
        --disable-cxx \
        --disable-diagnostic \
        --disable-dump185 \
        --disable-java \
        --disable-rpc \
        --disable-tcl \
        --disable-shared \
        --with-pic \
        --with-uniquename=_pam \
        --with-mutex="UNIX/fcntl" \
        --prefix=$TOPDIR \
        --includedir=$TOPDIR/include \
        --libdir=$TOPDIR/lib64	
make
PKG_DESTDIRVAR=$TOPDIR
makeinstall
cleanup
)

# And finally we're building PAM, yay!
TOPDIR=$DLG_WORKROOT/pam-instroot
CPPFLAGS=-I$TOPDIR/include ; export CPPFLAGS
export LIBNAME="lib64"
LDFLAGS=-L$TOPDIR/lib64 ; export LDFLAGS
# autoconf is needed due to our pacheroos
autoreconf
configure --libdir=/lib64 \
        --enable-static-libpam \
        --enable-fakeroot=$PKG_STAGEROOT \
        --enable-isadir=../../lib64/security
        
# Python stuff in docs gives sandbox problems
sed -i -e 's|modules doc examples|modules|' Makefile
	
sed -i -e "s:^HAVE_NDBM_H=yes:HAVE_NDBM_H=no:" \
			-e "s:^HAVE_LIBNDBM=yes:HAVE_LIBNDBM=no:" \
			Make.Rules
make

make check

make install DESTDIR=$PKG_STAGEROOT LDCONFIG=""

# Forcibly strip binaries.
spewdo "strip $PKG_STAGEROOT/sbin/*"

# /sbin/unix_chkpwd has to be set setgid shadow, or else apps that use
# it, like xscreensaver, cannot auth when checking the password.
spewdo "chown root.shadow $PKG_STAGEROOT/sbin/unix_chkpwd"
spewdo "chmod 2755 $PKG_STAGEROOT/sbin/unix_chkpwd"

# /sbin/pam_timestamp_check needs to be setuid root, or it throws errors.
spewdo "chown root.root $PKG_STAGEROOT/sbin/pam_timestamp_check"
spewdo "chmod 4755 $PKG_STAGEROOT/sbin/pam_timestamp_check"

createdir $PKG_STAGEROOT/etc/pam.d
findpatch filename other.pamd
spewdo "cp $filename $PKG_STAGEROOT/etc/pam.d/other"

findpatch filename system-auth.pamd
spewdo "cp $filename $PKG_STAGEROOT/etc/pam.d/system-auth"

# Install man pages.
install -d -m 755 $PKG_STAGEROOT$PKG_PREFIX/man/man{3,5,8}
install -m 644 doc/man/*.3 $PKG_STAGEROOT$PKG_PREFIX/man/man3
install -m 644 doc/man/*.5 $PKG_STAGEROOT$PKG_PREFIX/man/man5
install -m 644 doc/man/*.8 $PKG_STAGEROOT$PKG_PREFIX/man/man8

# We'll make all of this prettier later on...  Copying over the module
# manfiles as well... There are no module man3's, so we won't bother.
install -m 644 modules/pam_*/*.5 $PKG_STAGEROOT$PKG_PREFIX/man/man5
install -m 644 modules/pam_*/*.8 $PKG_STAGEROOT$PKG_PREFIX/man/man8

# And a few we use for pam.d configs.
install -m 644 $DLG_COREREPOS/$NAME/*.5 $PKG_STAGEROOT$PKG_PREFIX/man/man5

# Let's first remove that pam_selinux module dir because we don't use it,
# and its presence breaks our module checks.
echo "Removing pam_selinux"
spewdo "rm -rf $PKG_BUILDROOT/modules/pam_selinux"

# Let's do the same thing for pam_keyinit and pam_namespace until we figure out
# why they won't build.
echo "Removing pam_keyinit and pam_namespace"
spewdo "rm -rf $PKG_BUILDROOT/modules/pam_keyinit"
spewdo "rm -rf $PKG_BUILDROOT/modules/pam_namespace"

# Make sure every module subdirectory gave us a module.  Yes, this is hackish.
for dir in modules/pam_* ; do
if [ -d ${dir} ] ; then
        if ! ls -1 $PKG_STAGEROOT/lib64/security/`basename ${dir}`*.so ; then
		echo ERROR `basename ${dir}` did not build a module.
                die "Module missing"
        fi
fi
done

# Kill duplicate doc file sets.
spewdo "rm -fr $PKG_STAGEROOT$PKG_PREFIX/doc/Linux-PAM $PKG_STAGEROOT$PKG_PREFIX/share/doc/pam"
                                                                                
# Check for module problems.  Specifically, check that every module we just
# installed can actually be loaded by a minimal PAM-aware application.
for module in $PKG_STAGEROOT/lib64/security/pam*.so ; do
        if ! $DLG_COREREPOS/$NAME/dlopen.sh -lpam -ldl ${module} ; then
                die "Could not load module"
        fi
# And for good measure, make sure that none of the modules pull in threading
# libraries, which if loaded in a non-threaded application, can cause Very
# Bad Things to happen.
        if env LD_PRELOAD=$PKG_STAGEROOT/lib64/libpam.so ldd -r ${module} | fgrep -q libpthread ; then
                die "Module pulled in threading lib"
        fi
done

tidydocumentation
analyzebinaries
finalizepackage
packagize
removedir $TOPDIR
cleanup