shadow/PKGBUILD
2024-10-25 00:16:49 +08:00

138 lines
3.9 KiB
Bash

# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
# Maintainer: Future Linux Team <future_linux@163.com>
pkgname=shadow
pkgver=4.16.0
pkgrel=2
pkgdesc="Password and account management tool suite with support for shadow files and PAM"
arch=('x86_64')
url="https://github.com/shadow-maint/shadow/"
license=('BSD-3-Clause')
groups=('base')
depends=('glibc' 'attr' 'acl' 'libxcrypt' 'linux-pam'
'cracklib' 'libpwquality' 'libcap')
backup=(etc/default/useradd
etc/pam.d/login
etc/pam.d/passwd
etc/pam.d/su
etc/pam.d/chpasswd
etc/pam.d/newusers
etc/pam.d/chage)
options=('!emptydirs')
install=${pkgname}.install
source=(https://github.com/shadow-maint/shadow/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz
chage
chpasswd
login
passwd
su)
sha256sums=(b78e3921a95d53282a38e90628880624736bf6235e36eea50c50835f59a3530b
656fc19e0e36740399f9d10773ac30254b48d5327aaddd89f47127acf99ccfb5
fbaed8b9d2bad9278da32f6747491ef291b332d0f977009aadb993436b2084c9
216eb2abc095566afa0ed5394f5b32765d3e3b63295c0e972ecd8ebda1a734d2
586820a13a54e92023ad3aa5dbf2ee4e2cfe470996ebb9ee5433e60abd5d8c01
f0182f4cf929c6adb5e13e8691787a8778828f5ea18911b7b7febb3e1b138c54)
prepare() {
cd ${pkgname}-${pkgver}
sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' etc/login.defs
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 / /' {} \;
sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD YESCRYPT:' \
-e 's:/var/spool/mail:/var/mail:' \
-e '/PATH=/{s@/sbin:@@;s@/bin:@@}' \
-i etc/login.defs
}
build() {
cd ${pkgname}-${pkgver}
export CFLAGS="${CFLAGS} -DEXTRA_CHECK_HOME_DIR"
${CONFIGURE} \
--sysconfdir=/etc \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--disable-static \
--without-libbsd \
--with-libpam \
--with-libcrack \
--with-{b,yes}crypt \
--with-group-name-max-length=32
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
}
package() {
cd ${pkgname}-${pkgver}
#make DESTDIR=${pkgdir} pamddir= install
make DESTDIR=${pkgdir} install
make -C man DESTDIR=${pkgdir} install-man
install -vdm755 ${pkgdir}/etc/default
cat > ${pkgdir}/etc/default/useradd << EOF
# useradd defaults file
GROUP=999
GROUPS=
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
USRSKEL=/usr/etc/skel
CREATE_MAIL_SPOOL=yes
LOG_INIT=yes
EOF
install -v -m644 ${pkgdir}/etc/login.defs ${pkgdir}/etc/login.defs.orig
for FUNCTION in FAIL_DELAY \
FAILLOG_ENAB \
LASTLOG_ENAB \
MAIL_CHECK_ENAB \
LASTLOG_ENAB \
MAIL_CHECK_ENAB \
OBSCURE_CHECKS_ENAB \
PORTTIME_CHECKS_ENAB \
QUOTAS_ENAB \
OBSCURE_CHECKS_ENAB \
PORTTIME_CHECKS_ENAB \
QUOTAS_ENAB \
CONSOLE MOTD_FILE \
FTMP_FILE NOLOGINS_FILE \
ENV_HZ PASS_MIN_LEN \
SU_WHEEL_ONLY \
CRACKLIB_DICTPATH \
PASS_CHANGE_TRIES \
PASS_ALWAYS_WARN \
CHFN_AUTH ENCRYPT_METHOD \
ENVIRON_FILE
do
sed -i "s/^${FUNCTION}/# &/" ${pkgdir}/etc/login.defs
done
install -vdm755 ${pkgdir}/etc/pam.d
for F in chage chpasswd login passwd su
do
install -vm644 ${srcdir}/${F} ${pkgdir}/etc/pam.d/
done
sed -e s/chpasswd/newusers/ ${pkgdir}/etc/pam.d/chpasswd >${pkgdir}/etc/pam.d/newusers
for PROGRAM in chfn chgpasswd chsh groupadd groupdel \
groupmems groupmod useradd userdel usermod
do
install -v -m644 ${pkgdir}/etc/pam.d/chage ${pkgdir}/etc/pam.d/${PROGRAM}
sed -i "s/chage/$PROGRAM/" ${pkgdir}/etc/pam.d/${PROGRAM}
done
}