kind: autotools
depends:
- gnu-toolchain.bst
- core/autoconf.bst
- core/automake.bst
- core/gettext-tarball.bst
- core/libtool.bst
- core/bison.bst
- core/attr.bst
- core/acl.bst
- core/linux-pam.bst
- core/libcap2.bst
- core/perl.bst
sources:
- kind: git
  url: upstream:shadow
  track: upstream/4.2.1
  ref: bfaa59229d61adb7fa0c570f0d94fd324c6e05aa
config:
  pre-configure-commands:
  - autoreconf -vfi
  configure-commands:
  - |
    ./configure  --with-selinux=no \
                 --sysconfdir=/etc \
                 --with-libpam=yes \
                 --prefix="%{prefix}"
  post-install-commands:
  - |
    for OPTION in FAIL_DELAY \
                  FAILLOG_ENAB \
                  LASTLOG_ENAB \
                  MAIL_CHECK_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 \
                  ENVIRON_FILE
    do
      sed -i -e "s/^${OPTION}.*/# & #This option is handled by PAM instead./" \
          "%{install-root}/etc/login.defs"
    done
  - |
    if grep -q '[\s#]ENCRYPT_METHOD' "%{install-root}/etc/login.defs"; then
        sed -i -e '/^[\s#]*ENCRYPT_METHOD /s/.*/ENCRYPT_METHOD SHA512/g' "%{install-root}/etc/login.defs"
    else
        echo 'ENCRYPT_METHOD SHA512' >>"%{install-root}/etc/login.defs"
    fi
  - sed -i -e 's/\(.*\)required\(.*pam_selinux.so.*\)/\1optional\2/' "%{install-root}"/etc/pam.d/*
