view security/shadow/shadow.sh @ 745:59a2fa6992bc

vanilla: re-enable static libraries
author David Demelier <markand@malikania.fr>
date Wed, 07 Aug 2019 20:05:00 +0200
parents 9de04ddc6f6d
children a73b34fe66ec
line wrap: on
line source

#!/bin/sh
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

PKGNAME=shadow
PKGVERSION=4.6
PKGREVISION=1
PKGLICENSE="BSD"
PKGSUMMARY="password and account management"
PKGDOWNLOAD="https://github.com/shadow-maint/shadow/releases/download/$PKGVERSION/$PKGNAME-$PKGVERSION.tar.xz"
PKGOPTIONS="ACL ATTR NLS PAM SELINUX"
PKGPROTECT="etc/login.defs"

: ${CHOST:=$(uname -m)-linux-musl}
: ${CBUILD:=$(uname -m)-linux-musl}
: ${CC:=clang}
: ${CFLAGS:=-O2}
: ${LDFLAGS:=}
: ${LIBS:=}
: ${ACL:=yes}
: ${ATTR:=yes}
: ${NLS:=yes}
: ${PAM:=yes}
: ${SELINUX:=no}

if [ "$ACL" = "yes" ]; then
	PKGDEPENDS="core/acl $PKGDEPENDS"
	with_acl="--with-acl"
else
	with_acl="--without-acl"
fi

if [ "$ATTR" = "yes" ]; then
	PKGDEPENDS="core/acl $PKGDEPENDS"
	with_attr="--with-attr"
else
	with_attr="--without-attr"
fi

if [ "$NLS" = "yes" ]; then
	PKGDEPENDS="core/gettext:build $PKGDEPENDS"
	with_nls="--enable-nls"
else
	with_nls="--disable-nls"
fi

if [ "$PAM" = "yes" ]; then
	PKGDEPENDS="security/pam $PKGDEPENDS"
	with_pam="--with-libpam"
else
	with_pam="--without-libpam"
fi

if [ "$SELINUX" = "yes" ]; then
	with_selinux="--with-selinux"
else
	with_selinux="--without-selinux"
fi

build()
{
	rm -rf $PKGNAME-$PKGVERSION
	tar xvf $PKGNAME-$PKGVERSION.tar.xz
	cd $PKGNAME-$PKGVERSION

	#
	# disable groups, it's provided by busybox/coreutils and documentation
	# by man-pages.
	#
	sed -i 's/groups$(EXEEXT) //' src/Makefile.in
	find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
	find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
	find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;

	CC="$CC" \
	CFLAGS="$CFLAGS" \
	LDFLAGS="$LDFLAGS" \
	LIBS="$LIBS" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix= \
		--bindir=/bin \
		--sbindir=/bin \
		--enable-shared \
		$with_acl \
		$with_attr \
		$with_nls \
		$with_pam \
		$with_selinux
	make ubindir=/bin usbindir=/bin
	make DESTDIR=$DESTDIR ubindir=/bin usbindir=/bin install

	if [ "$PAM" = "yes" ]; then
		# --disable-selinux does not update pam.d files
		if [ "$SELINUX" = "no" ]; then
			sed -i -e "/pam_selinux.so/d"           \
				$DESTDIR/etc/pam.d/login        \
				$DESTDIR/etc/pam.d/su
		fi

		# pam_console.so isn't shipped with linux-pam.
		sed -i -e "/pam_console.so/d" $DESTDIR/etc/pam.d/login
	fi

	cd ..
	rm -rf $PKGNAME-$PKGVERSION
}