kind: autotools

depends:
- filename: gnu-toolchain.bst
  type: build
- filename: core/autoconf.bst
  type: build
- filename: core/automake.bst
  type: build
- filename: core/gettext-tarball.bst
  type: build
- filename: core/libtool.bst
  type: build
- filename: core/bison.bst
  type: build
- filename: core/attr.bst
  type: build
- filename: core/acl.bst
  type: build
- filename: core/linux-pam.bst
  type: build
- filename: core/libcap2.bst
  type: build

sources:
- kind: git
  url: upstream:shadow
  track: upstream/4.2.1
  ref: bfaa59229d61adb7fa0c570f0d94fd324c6e05aa

config:
  configure-commands:
  - autoreconf -vfi
  - |
    ./configure  --with-selinux=no \
                 --sysconfdir=/etc \
                 --with-libpam=yes \
                 --prefix="%{prefix}"
  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/*
