From 7108cf5024e8a9491c1269e95426889736472d0a Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Tue, 7 Aug 2012 14:05:10 -0500
Subject: util-linux 2.21.2 includes our patch for agetty

---
 abs/core/util-linux/PKGBUILD                    | 70 +++++++++++++++------
 abs/core/util-linux/__changelog                 |  1 +
 abs/core/util-linux/mount-segfault-2.19.1.patch | 84 -------------------------
 abs/core/util-linux/pam-common                  |  6 ++
 abs/core/util-linux/pam-login                   |  7 +++
 abs/core/util-linux/term_utils-agetty.patch     | 17 +++++
 abs/core/util-linux/util-linux.install          | 10 +++
 7 files changed, 91 insertions(+), 104 deletions(-)
 create mode 100644 abs/core/util-linux/__changelog
 delete mode 100644 abs/core/util-linux/mount-segfault-2.19.1.patch
 create mode 100644 abs/core/util-linux/pam-common
 create mode 100644 abs/core/util-linux/pam-login
 create mode 100644 abs/core/util-linux/term_utils-agetty.patch
 create mode 100644 abs/core/util-linux/util-linux.install

diff --git a/abs/core/util-linux/PKGBUILD b/abs/core/util-linux/PKGBUILD
index 877e013..bfa1517 100644
--- a/abs/core/util-linux/PKGBUILD
+++ b/abs/core/util-linux/PKGBUILD
@@ -1,38 +1,68 @@
-# $Id: PKGBUILD 123897 2011-05-14 09:14:06Z tpowa $
-# Maintainer:
+# $Id: PKGBUILD 163535 2012-07-15 00:25:36Z tomegun $
+# Maintainer: Tom Gundersen <teg@jklm.no>
 # Contributor: judd <jvinet@zeroflux.org>
 
 pkgname=util-linux
-pkgver=2.19.1
-pkgrel=2
+pkgver=2.21.2
+pkgrel=5
 pkgdesc="Miscellaneous system utilities for Linux"
-url="http://userweb.kernel.org/~kzak/util-linux-ng/"
+url="http://www.kernel.org/pub/linux/utils/util-linux/"
 arch=('i686' 'x86_64')
 groups=('base')
-depends=('bash' 'ncurses>=5.7' 'zlib' 'filesystem')
-replaces=('linux32' 'util-linux-ng')
-conflicts=('linux32' 'util-linux-ng' 'e2fsprogs<1.41.8-2')
-provides=('linux32' "util-linux-ng=${pkgver}")
+depends=('pam')
+conflicts=('util-linux-ng')
+provides=("util-linux-ng=${pkgver}")
 license=('GPL2')
 options=('!libtool')
-source=(ftp://ftp.kernel.org/pub/linux/utils/${pkgname}/v2.19/${pkgname}-${pkgver}.tar.bz2
-       mount-segfault-2.19.1.patch)
-optdepends=('perl: for chkdupexe support')
-md5sums=('3eab06f05163dfa65479c44e5231932c'
-         '3247b52f0e4b8044f23f2f7218e2fdea')
+source=(ftp://ftp.kernel.org/pub/linux/utils/${pkgname}/v2.21/${pkgname}-${pkgver}.tar.xz
+        pam-login
+        pam-common
+	term_utils-agetty.patch)
+backup=(etc/pam.d/chfn etc/pam.d/chsh etc/pam.d/login)
+install=util-linux.install
 
 build() {
   cd "${srcdir}/${pkgname}-${pkgver}"
-  # fix https://bugs.archlinux.org/task/24261
-  patch -Np1 -i ../mount-segfault-2.19.1.patch
-  # hardware clock
-  sed -e 's%etc/adjtime%var/lib/hwclock/adjtime%' -i hwclock/hwclock.c
-  ./configure --enable-arch --enable-write --enable-raw --disable-wall --enable-partx
+
+  ./configure --prefix=/usr \
+              --libdir=/usr/lib \
+              --enable-fs-paths-extra=/usr/bin:/usr/sbin \
+              --enable-write \
+              --enable-raw \
+              --disable-wall \
+              --enable-new-mount \
+              --enable-login-utils
+
   make
 }
 
+check() {
+  make -C "$pkgname-$pkgver" check
+}
+
 package() {
   cd "${srcdir}/${pkgname}-${pkgver}"
-  install -dm755 "${pkgdir}/var/lib/hwclock"
+  patch -p0 < ${srcdir}/term_utils-agetty.patch || return 1
+
   make DESTDIR="${pkgdir}" install
+
+  cd "${pkgdir}"
+
+  # broken tool, going away in next major release, so just remove it now
+  rm "${pkgdir}"/usr/{bin/chkdupexe,share/man/man1/chkdupexe.1}
+
+  # delete stray empty dir, fixed upstream
+  rm -r usr/share/man/ru
+
+  # setuid chfn and chsh
+  chmod 4755 "$pkgdir"/usr/bin/ch{sh,fn}
+
+  # install PAM files for login-utils
+  install -Dm644 "$srcdir/pam-common" "$pkgdir/etc/pam.d/chfn"
+  install -m644 "$srcdir/pam-common" "$pkgdir/etc/pam.d/chsh"
+  install -m644 "$srcdir/pam-login" "$pkgdir/etc/pam.d/login"
 }
+md5sums=('54ba880f1d66782c2287ee2c898520e9'
+         '4368b3f98abd8a32662e094c54e7f9b1'
+         'a31374fef2cba0ca34dfc7078e2969e4'
+         'da1e8645a7cff8fbc08e861466e2727e')
diff --git a/abs/core/util-linux/__changelog b/abs/core/util-linux/__changelog
new file mode 100644
index 0000000..5a06d16
--- /dev/null
+++ b/abs/core/util-linux/__changelog
@@ -0,0 +1 @@
+utils-agetty-patch
diff --git a/abs/core/util-linux/mount-segfault-2.19.1.patch b/abs/core/util-linux/mount-segfault-2.19.1.patch
deleted file mode 100644
index 7bcb3bc..0000000
--- a/abs/core/util-linux/mount-segfault-2.19.1.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From f53edda83ebcfd7015c3f35196d6cbd7bc2d8369 Mon Sep 17 00:00:00 2001
-From: Karel Zak <kzak@redhat.com>
-Date: Wed, 11 May 2011 16:57:27 +0200
-Subject: [PATCH] mount: -a segfaults when 4th field is omitted (mount
- options)
-
- # echo 'tmpd /tmp/x tmpfs' >> /etc/fstab
- # mkdir /tmp/x
- # mount -a
- segfault
-
-Reported-by: Mike Frysinger <vapier@gentoo.org>
-Signed-off-by: Karel Zak <kzak@redhat.com>
----
- mount/mount.c        |    8 +++++---
- mount/mount_mntent.c |    5 +++--
- mount/sundries.c     |    2 ++
- 3 files changed, 10 insertions(+), 5 deletions(-)
-
-diff --git a/mount/mount.c b/mount/mount.c
-index ba71149..29963c2 100644
---- a/mount/mount.c
-+++ b/mount/mount.c
-@@ -1163,7 +1163,9 @@ is_mounted_same_loopfile(const char *node0, const char *loopfile, unsigned long
- 			res = loopfile_used_with((char *) mnt->m.mnt_fsname,
- 					loopfile, offset);
- 
--		else if ((p = strstr(mnt->m.mnt_opts, "loop="))) {
-+		else if (mnt->m.mnt_opts &&
-+			 (p = strstr(mnt->m.mnt_opts, "loop=")))
-+		{
- 			char *dev = xstrdup(p+5);
- 			if ((p = strchr(dev, ',')))
- 				*p = '\0';
-@@ -2052,8 +2054,8 @@ is_fstab_entry_mounted(struct mntentchn *mc, int verbose)
- 		goto yes;
- 
- 	/* extra care for loop devices */
--	if ((strstr(mc->m.mnt_opts, "loop=") ||
--	     (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) {
-+	if ((mc->m.mnt_opts && strstr(mc->m.mnt_opts, "loop=")) ||
-+	    (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode))) {
- 
- 		char *p = get_option_value(mc->m.mnt_opts, "offset=");
- 		uintmax_t offset = 0;
-diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c
-index d90def3..f42c0ad 100644
---- a/mount/mount_mntent.c
-+++ b/mount/mount_mntent.c
-@@ -70,7 +70,7 @@ my_addmntent (mntFILE *mfp, struct my_mntent *mnt) {
- 	m1 = mangle(mnt->mnt_fsname);
- 	m2 = mangle(mnt->mnt_dir);
- 	m3 = mangle(mnt->mnt_type);
--	m4 = mangle(mnt->mnt_opts);
-+	m4 = mnt->mnt_opts ? mangle(mnt->mnt_opts) : "rw";
- 
- 	res = fprintf (mfp->mntent_fp, "%s %s %s %s %d %d\n",
- 		       m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno);
-@@ -78,7 +78,8 @@ my_addmntent (mntFILE *mfp, struct my_mntent *mnt) {
- 	free(m1);
- 	free(m2);
- 	free(m3);
--	free(m4);
-+	if (mnt->mnt_opts)
-+		free(m4);
- 	return (res < 0) ? 1 : 0;
- }
- 
-diff --git a/mount/sundries.c b/mount/sundries.c
-index ae4501a..2dec37f 100644
---- a/mount/sundries.c
-+++ b/mount/sundries.c
-@@ -217,6 +217,8 @@ matching_opts (const char *options, const char *test_opts) {
- 
-      if (test_opts == NULL)
- 	  return 1;
-+     if (options == NULL)
-+	  options = "";
- 
-      len = strlen(test_opts);
-      q = alloca(len+1);
--- 
-1.7.5.1
-
diff --git a/abs/core/util-linux/pam-common b/abs/core/util-linux/pam-common
new file mode 100644
index 0000000..a7bf8a4
--- /dev/null
+++ b/abs/core/util-linux/pam-common
@@ -0,0 +1,6 @@
+#%PAM-1.0
+auth		sufficient	pam_rootok.so
+auth		required	pam_unix.so
+account		required	pam_unix.so
+session		required	pam_unix.so
+password	required	pam_permit.so
diff --git a/abs/core/util-linux/pam-login b/abs/core/util-linux/pam-login
new file mode 100644
index 0000000..1960d94
--- /dev/null
+++ b/abs/core/util-linux/pam-login
@@ -0,0 +1,7 @@
+#%PAM-1.0
+
+auth       required     pam_securetty.so
+auth       requisite    pam_nologin.so
+auth       include      system-local-login
+account    include      system-local-login
+session    include      system-local-login
diff --git a/abs/core/util-linux/term_utils-agetty.patch b/abs/core/util-linux/term_utils-agetty.patch
new file mode 100644
index 0000000..f0b37b3
--- /dev/null
+++ b/abs/core/util-linux/term_utils-agetty.patch
@@ -0,0 +1,17 @@
+--- term-utils/agetty.orig	2012-08-02 19:44:36.234757299 +0000
++++ term-utils/agetty.c	2012-08-02 19:47:15.464752505 +0000
+@@ -961,12 +961,12 @@
+ 		 */
+ 
+ 		if ((fcntl(STDIN_FILENO, F_GETFL, 0) & O_RDWR) != O_RDWR)
+-			log_err(_("%s: not open for read/write"), tty);
++			log_warn(_("%s: not open for read/write"), tty);
+ 
+ 	}
+ 
+ 	if (tcsetpgrp(STDIN_FILENO, pid))
+-		log_err("/dev/%s: cannot set process group: %m", tty);
++		log_warn("/dev/%s: cannot set process group: %m", tty);
+ 
+ 	/* Get rid of the present outputs. */
+ 	close(STDOUT_FILENO);
diff --git a/abs/core/util-linux/util-linux.install b/abs/core/util-linux/util-linux.install
new file mode 100644
index 0000000..90ce5bd
--- /dev/null
+++ b/abs/core/util-linux/util-linux.install
@@ -0,0 +1,10 @@
+post_upgrade() {
+  if [ "$(vercmp $2 2.21.2-4)" -lt 0 ]; then
+    if [ -f /var/lib/hwclock/adjtime ]; then
+      mv /var/lib/hwclock/adjtime /etc/adjtime
+    fi
+    if [ -d /var/lib/hwclock ]; then
+      rmdir /var/lib/hwclock
+    fi
+  fi
+}
-- 
cgit v0.12

