[arch-commits] Commit in util-linux/repos (12 files)
Dave Reisner
dreisner at archlinux.org
Fri Jan 20 17:48:34 UTC 2017
Date: Friday, January 20, 2017 @ 17:48:34
Author: dreisner
Revision: 287026
archrelease: copy trunk to testing-i686, testing-x86_64
Added:
util-linux/repos/testing-i686/
util-linux/repos/testing-i686/0001-sfdisk-support-empty-label-use-case.patch
(from rev 287025, util-linux/trunk/0001-sfdisk-support-empty-label-use-case.patch)
util-linux/repos/testing-i686/PKGBUILD
(from rev 287025, util-linux/trunk/PKGBUILD)
util-linux/repos/testing-i686/pam-common
(from rev 287025, util-linux/trunk/pam-common)
util-linux/repos/testing-i686/pam-login
(from rev 287025, util-linux/trunk/pam-login)
util-linux/repos/testing-i686/pam-su
(from rev 287025, util-linux/trunk/pam-su)
util-linux/repos/testing-x86_64/
util-linux/repos/testing-x86_64/0001-sfdisk-support-empty-label-use-case.patch
(from rev 287025, util-linux/trunk/0001-sfdisk-support-empty-label-use-case.patch)
util-linux/repos/testing-x86_64/PKGBUILD
(from rev 287025, util-linux/trunk/PKGBUILD)
util-linux/repos/testing-x86_64/pam-common
(from rev 287025, util-linux/trunk/pam-common)
util-linux/repos/testing-x86_64/pam-login
(from rev 287025, util-linux/trunk/pam-login)
util-linux/repos/testing-x86_64/pam-su
(from rev 287025, util-linux/trunk/pam-su)
---------------------------------------------------------------+
testing-i686/0001-sfdisk-support-empty-label-use-case.patch | 223 ++++++++++
testing-i686/PKGBUILD | 104 ++++
testing-i686/pam-common | 6
testing-i686/pam-login | 7
testing-i686/pam-su | 9
testing-x86_64/0001-sfdisk-support-empty-label-use-case.patch | 223 ++++++++++
testing-x86_64/PKGBUILD | 104 ++++
testing-x86_64/pam-common | 6
testing-x86_64/pam-login | 7
testing-x86_64/pam-su | 9
10 files changed, 698 insertions(+)
Copied: util-linux/repos/testing-i686/0001-sfdisk-support-empty-label-use-case.patch (from rev 287025, util-linux/trunk/0001-sfdisk-support-empty-label-use-case.patch)
===================================================================
--- testing-i686/0001-sfdisk-support-empty-label-use-case.patch (rev 0)
+++ testing-i686/0001-sfdisk-support-empty-label-use-case.patch 2017-01-20 17:48:34 UTC (rev 287026)
@@ -0,0 +1,223 @@
+From 35ca51182782193f555fbdcb06bb10766550d017 Mon Sep 17 00:00:00 2001
+From: Karel Zak <kzak at redhat.com>
+Date: Wed, 30 Nov 2016 12:43:10 +0100
+Subject: [PATCH] sfdisk: support empty label use-case
+
+By default sfdisk creates partition table when a first partition is
+specified, otherwise the device is not modified. This force users to
+create at least one partition.
+
+This commit allows to create empty label without partitions if "label:
+<name>" header line is specified by script.
+
+The commit also modifies "New situation:" output to list label name
+and label identifier.
+
+Addresses: https://github.com/karelzak/util-linux/issues/374
+Signed-off-by: Karel Zak <kzak at redhat.com>
+---
+ disk-utils/fdisk-list.c | 23 +++++++++++++++--------
+ disk-utils/fdisk-list.h | 1 +
+ disk-utils/sfdisk.8 | 18 +++++++++++++++++-
+ disk-utils/sfdisk.c | 17 +++++++++++++++++
+ libfdisk/src/libfdisk.h.in | 1 +
+ libfdisk/src/libfdisk.sym | 5 +++++
+ libfdisk/src/script.c | 20 +++++++++++++++++++-
+ 7 files changed, 75 insertions(+), 10 deletions(-)
+
+diff --git a/disk-utils/fdisk-list.c b/disk-utils/fdisk-list.c
+index e6b2033..c9560f4 100644
+--- a/disk-utils/fdisk-list.c
++++ b/disk-utils/fdisk-list.c
+@@ -34,10 +34,23 @@ static int is_ide_cdrom_or_tape(char *device)
+ return ret;
+ }
+
++void list_disk_identifier(struct fdisk_context *cxt)
++{
++ struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
++ char *id = NULL;
++
++ if (fdisk_has_label(cxt))
++ fdisk_info(cxt, _("Disklabel type: %s"),
++ fdisk_label_get_name(lb));
++
++ if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) {
++ fdisk_info(cxt, _("Disk identifier: %s"), id);
++ free(id);
++ }
++}
+
+ void list_disk_geometry(struct fdisk_context *cxt)
+ {
+- char *id = NULL;
+ struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
+ uint64_t bytes = fdisk_get_nsectors(cxt) * fdisk_get_sector_size(cxt);
+ char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE
+@@ -71,14 +84,8 @@ void list_disk_geometry(struct fdisk_context *cxt)
+ if (fdisk_get_alignment_offset(cxt))
+ fdisk_info(cxt, _("Alignment offset: %lu bytes"),
+ fdisk_get_alignment_offset(cxt));
+- if (fdisk_has_label(cxt))
+- fdisk_info(cxt, _("Disklabel type: %s"),
+- fdisk_label_get_name(lb));
+
+- if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) {
+- fdisk_info(cxt, _("Disk identifier: %s"), id);
+- free(id);
+- }
++ list_disk_identifier(cxt);
+ }
+
+ void list_disklabel(struct fdisk_context *cxt)
+diff --git a/disk-utils/fdisk-list.h b/disk-utils/fdisk-list.h
+index eddab92..4ed5c25 100644
+--- a/disk-utils/fdisk-list.h
++++ b/disk-utils/fdisk-list.h
+@@ -2,6 +2,7 @@
+ #define UTIL_LINUX_FDISK_LIST_H
+
+ extern void list_disklabel(struct fdisk_context *cxt);
++extern void list_disk_identifier(struct fdisk_context *cxt);
+ extern void list_disk_geometry(struct fdisk_context *cxt);
+ extern void list_freespace(struct fdisk_context *cxt);
+
+diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8
+index fcde872..efe4a86 100644
+--- a/disk-utils/sfdisk.8
++++ b/disk-utils/sfdisk.8
+@@ -212,7 +212,10 @@ Deprecated option. Only the sector unit is supported.
+ .BR \-X , " \-\-label " \fItype
+ Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option
+ is not given, then \fBsfdisk\fR defaults to the existing label, but if there
+-is no label on the device yet, then the type defaults to \fBdos\fR.
++is no label on the device yet, then the type defaults to \fBdos\fR. The default
++or the current label may be overwritten by the "label: <name>" script header
++line. The option \fB\-\-label\fR does not force \fBsfdisk\fR to create empty
++disk label (see the \fBEMPTY DISK LABEL\fR section below).
+ .TP
+ .BR \-Y , " \-\-label\-nested " \fItype
+ Force editing of a nested disk label. The primary disk label has to exist already.
+@@ -404,6 +407,19 @@ For backward compatibility the \fBId=\fR field has the same meaning.
+ .RE
+ .RE
+
++.SH "EMPTY DISK LABEL"
++.B sfdisk
++does not create partition table without partitions by default. The lines with
++partitions are expected in the script by default. The empty partition table has
++to be explicitly requested by "label: <name>" script header line without any
++partitions lines. For example:
++.RS
++.sp
++.B "echo 'label: gpt' | sfdisk /dev/sdb"
++.sp
++.RE
++creates empty GPT partition table. Note that the \fB\-\-append\fR disables this feature.
++
+ .SH "BACKING UP THE PARTITION TABLE"
+ It is recommended to save the layout of your devices.
+ .B sfdisk
+diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
+index 10307ad..2d65974 100644
+--- a/disk-utils/sfdisk.c
++++ b/disk-utils/sfdisk.c
+@@ -1766,8 +1766,25 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
+ }
+ } while (1);
+
++ /* create empty disk label if label, but no partition specified */
++ if (rc == SFDISK_DONE_EOF && created == 0
++ && fdisk_script_has_force_label(dp) == 1
++ && fdisk_table_get_nents(tb) == 0
++ && fdisk_script_get_header(dp, "label")) {
++
++ int xrc = fdisk_apply_script_headers(sf->cxt, dp);
++ created = !xrc;
++ if (xrc) {
++ fdisk_warnx(sf->cxt, _(
++ "Failed to apply script headers, "
++ "disk label not created."));
++ rc = SFDISK_DONE_ABORT;
++ }
++ }
++
+ if (!sf->quiet && rc != SFDISK_DONE_ABORT) {
+ fdisk_info(sf->cxt, _("\nNew situation:"));
++ list_disk_identifier(sf->cxt);
+ list_disklabel(sf->cxt);
+ }
+
+diff --git a/libfdisk/src/libfdisk.h.in b/libfdisk/src/libfdisk.h.in
+index 9154f5b..59cce19 100644
+--- a/libfdisk/src/libfdisk.h.in
++++ b/libfdisk/src/libfdisk.h.in
+@@ -642,6 +642,7 @@ const char *fdisk_script_get_header(struct fdisk_script *dp, const char *name);
+ int fdisk_script_set_header(struct fdisk_script *dp, const char *name, const char *data);
+ struct fdisk_table *fdisk_script_get_table(struct fdisk_script *dp);
+ int fdisk_script_get_nlines(struct fdisk_script *dp);
++int fdisk_script_has_force_label(struct fdisk_script *dp);
+
+ int fdisk_script_set_userdata(struct fdisk_script *dp, void *data);
+ void *fdisk_script_get_userdata(struct fdisk_script *dp);
+diff --git a/libfdisk/src/libfdisk.sym b/libfdisk/src/libfdisk.sym
+index 02cd7a8..d6d4ac5 100644
+--- a/libfdisk/src/libfdisk.sym
++++ b/libfdisk/src/libfdisk.sym
+@@ -274,3 +274,8 @@ FDISK_2.29 {
+ fdisk_labelitem_is_number;
+ fdisk_gpt_set_npartitions;
+ } FDISK_2.28;
++
++
++FDISK_2.30 {
++ fdisk_script_has_force_label;
++} FDISK_2.29;
+diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
+index ae7e99a..0d1f260 100644
+--- a/libfdisk/src/script.c
++++ b/libfdisk/src/script.c
+@@ -36,7 +36,8 @@ struct fdisk_script {
+ size_t nlines;
+ struct fdisk_label *label;
+
+- unsigned int json : 1; /* JSON output */
++ unsigned int json : 1, /* JSON output */
++ force_label : 1; /* label: <name> specified */
+ };
+
+
+@@ -354,6 +355,22 @@ int fdisk_script_get_nlines(struct fdisk_script *dp)
+ }
+
+ /**
++ * fdisk_script_has_force_label:
++ * @dp: script
++ *
++ * Note that fdisk_script_set_header(dp, "label", name) does not modify
++ * force_label status. The label has to be specified by script.
++ *
++ * Returns: true if "label: <name>" has been parsed.
++ */
++int fdisk_script_has_force_label(struct fdisk_script *dp)
++{
++ assert(dp);
++ return dp->force_label;
++}
++
++
++/**
+ * fdisk_script_read_context:
+ * @dp: script
+ * @cxt: context
+@@ -706,6 +723,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
+ if (strcmp(name, "label") == 0) {
+ if (dp->cxt && !fdisk_get_label(dp->cxt, value))
+ goto done; /* unknown label name */
++ dp->force_label = 1;
+ } else if (strcmp(name, "unit") == 0) {
+ if (strcmp(value, "sectors") != 0)
+ goto done; /* only "sectors" supported */
+--
+2.10.2
+
Copied: util-linux/repos/testing-i686/PKGBUILD (from rev 287025, util-linux/trunk/PKGBUILD)
===================================================================
--- testing-i686/PKGBUILD (rev 0)
+++ testing-i686/PKGBUILD 2017-01-20 17:48:34 UTC (rev 287026)
@@ -0,0 +1,104 @@
+# $Id$
+# Maintainer: Tom Gundersen <teg at jklm.no>
+# Maintainer: Dave Reisner <dreisner at archlinux.org>
+# Contributor: judd <jvinet at zeroflux.org>
+
+pkgbase=util-linux
+pkgname=(util-linux libutil-linux)
+_pkgmajor=2.29
+pkgver=${_pkgmajor}.1
+pkgrel=1
+pkgdesc="Miscellaneous system utilities for Linux"
+url="https://www.kernel.org/pub/linux/utils/util-linux/"
+arch=('i686' 'x86_64')
+makedepends=('systemd' 'python')
+license=('GPL2')
+options=('strip' 'debug')
+validpgpkeys=('B0C64D14301CC6EFAEDF60E4E4B71D5EEC39C284') # Karel Zak
+source=("https://www.kernel.org/pub/linux/utils/util-linux/v$_pkgmajor/$pkgbase-$pkgver.tar."{xz,sign}
+ pam-{login,common,su}
+ '0001-sfdisk-support-empty-label-use-case.patch')
+md5sums=('0cbb6d16ab9c5736e5649ef1264bee6e'
+ 'SKIP'
+ '4368b3f98abd8a32662e094c54e7f9b1'
+ 'a31374fef2cba0ca34dfc7078e2969e4'
+ 'fa85e5cce5d723275b14365ba71a8aad'
+ '6d2e3915124938577f0ff18ef701c87f')
+
+prepare() {
+ cd "$pkgbase-$pkgver"
+
+ patch -Np1 <../0001-sfdisk-support-empty-label-use-case.patch
+}
+
+build() {
+ cd "$pkgbase-$pkgver"
+
+ ./configure --prefix=/usr \
+ --libdir=/usr/lib \
+ --bindir=/usr/bin \
+ --localstatedir=/run \
+ --enable-fs-paths-extra=/usr/bin \
+ --enable-raw \
+ --enable-vipw \
+ --enable-newgrp \
+ --enable-chfn-chsh \
+ --enable-write \
+ --enable-mesg \
+ --with-python=3
+
+ make
+}
+
+package_util-linux() {
+ conflicts=('util-linux-ng' 'eject' 'zramctl')
+ provides=("util-linux-ng=$pkgver" 'eject' 'zramctl')
+ replaces=('zramctl')
+ depends=('pam' 'shadow' 'coreutils' 'libsystemd' 'libutil-linux')
+ optdepends=('python: python bindings to libmount')
+ groups=('base' 'base-devel')
+ backup=(etc/pam.d/chfn
+ etc/pam.d/chsh
+ etc/pam.d/login
+ etc/pam.d/su
+ etc/pam.d/su-l)
+
+ cd "$pkgbase-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+ # setuid chfn and chsh
+ chmod 4755 "$pkgdir"/usr/bin/{newgrp,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"
+ install -m644 "$srcdir/pam-su" "$pkgdir/etc/pam.d/su"
+ install -m644 "$srcdir/pam-su" "$pkgdir/etc/pam.d/su-l"
+
+ # TODO(dreisner): offer this upstream?
+ sed -i '/ListenStream/ aRuntimeDirectory=uuidd' "$pkgdir/usr/lib/systemd/system/uuidd.socket"
+
+ # adjust for usrmove
+ # TODO(dreisner): fix configure.ac upstream so that this isn't needed
+ cd "$pkgdir"
+ mv {,usr/}sbin/* usr/bin
+ rmdir sbin usr/sbin
+
+ ### runtime libs are shipped as part of libutil-linux
+ rm "$pkgdir"/usr/lib/lib*.{a,so}*
+
+ ### tailf has been deprecated for a while. let's not include it anymore.
+ rm \
+ "$pkgdir"/usr/bin/tailf \
+ "$pkgdir"/usr/share/bash-completion/completions/tailf \
+ "$pkgdir"/usr/share/man/man1/tailf.1
+}
+
+package_libutil-linux() {
+ pkgdesc="util-linux runtime libraries"
+ provides=('libblkid.so' 'libfdisk.so' 'libmount.so' 'libsmartcols.so' 'libuuid.so')
+
+ make -C "$pkgbase-$pkgver" DESTDIR="$pkgdir" install-usrlib_execLTLIBRARIES
+}
Copied: util-linux/repos/testing-i686/pam-common (from rev 287025, util-linux/trunk/pam-common)
===================================================================
--- testing-i686/pam-common (rev 0)
+++ testing-i686/pam-common 2017-01-20 17:48:34 UTC (rev 287026)
@@ -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
Copied: util-linux/repos/testing-i686/pam-login (from rev 287025, util-linux/trunk/pam-login)
===================================================================
--- testing-i686/pam-login (rev 0)
+++ testing-i686/pam-login 2017-01-20 17:48:34 UTC (rev 287026)
@@ -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
Copied: util-linux/repos/testing-i686/pam-su (from rev 287025, util-linux/trunk/pam-su)
===================================================================
--- testing-i686/pam-su (rev 0)
+++ testing-i686/pam-su 2017-01-20 17:48:34 UTC (rev 287026)
@@ -0,0 +1,9 @@
+#%PAM-1.0
+auth sufficient pam_rootok.so
+# Uncomment the following line to implicitly trust users in the "wheel" group.
+#auth sufficient pam_wheel.so trust use_uid
+# Uncomment the following line to require a user to be in the "wheel" group.
+#auth required pam_wheel.so use_uid
+auth required pam_unix.so
+account required pam_unix.so
+session required pam_unix.so
Copied: util-linux/repos/testing-x86_64/0001-sfdisk-support-empty-label-use-case.patch (from rev 287025, util-linux/trunk/0001-sfdisk-support-empty-label-use-case.patch)
===================================================================
--- testing-x86_64/0001-sfdisk-support-empty-label-use-case.patch (rev 0)
+++ testing-x86_64/0001-sfdisk-support-empty-label-use-case.patch 2017-01-20 17:48:34 UTC (rev 287026)
@@ -0,0 +1,223 @@
+From 35ca51182782193f555fbdcb06bb10766550d017 Mon Sep 17 00:00:00 2001
+From: Karel Zak <kzak at redhat.com>
+Date: Wed, 30 Nov 2016 12:43:10 +0100
+Subject: [PATCH] sfdisk: support empty label use-case
+
+By default sfdisk creates partition table when a first partition is
+specified, otherwise the device is not modified. This force users to
+create at least one partition.
+
+This commit allows to create empty label without partitions if "label:
+<name>" header line is specified by script.
+
+The commit also modifies "New situation:" output to list label name
+and label identifier.
+
+Addresses: https://github.com/karelzak/util-linux/issues/374
+Signed-off-by: Karel Zak <kzak at redhat.com>
+---
+ disk-utils/fdisk-list.c | 23 +++++++++++++++--------
+ disk-utils/fdisk-list.h | 1 +
+ disk-utils/sfdisk.8 | 18 +++++++++++++++++-
+ disk-utils/sfdisk.c | 17 +++++++++++++++++
+ libfdisk/src/libfdisk.h.in | 1 +
+ libfdisk/src/libfdisk.sym | 5 +++++
+ libfdisk/src/script.c | 20 +++++++++++++++++++-
+ 7 files changed, 75 insertions(+), 10 deletions(-)
+
+diff --git a/disk-utils/fdisk-list.c b/disk-utils/fdisk-list.c
+index e6b2033..c9560f4 100644
+--- a/disk-utils/fdisk-list.c
++++ b/disk-utils/fdisk-list.c
+@@ -34,10 +34,23 @@ static int is_ide_cdrom_or_tape(char *device)
+ return ret;
+ }
+
++void list_disk_identifier(struct fdisk_context *cxt)
++{
++ struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
++ char *id = NULL;
++
++ if (fdisk_has_label(cxt))
++ fdisk_info(cxt, _("Disklabel type: %s"),
++ fdisk_label_get_name(lb));
++
++ if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) {
++ fdisk_info(cxt, _("Disk identifier: %s"), id);
++ free(id);
++ }
++}
+
+ void list_disk_geometry(struct fdisk_context *cxt)
+ {
+- char *id = NULL;
+ struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
+ uint64_t bytes = fdisk_get_nsectors(cxt) * fdisk_get_sector_size(cxt);
+ char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE
+@@ -71,14 +84,8 @@ void list_disk_geometry(struct fdisk_context *cxt)
+ if (fdisk_get_alignment_offset(cxt))
+ fdisk_info(cxt, _("Alignment offset: %lu bytes"),
+ fdisk_get_alignment_offset(cxt));
+- if (fdisk_has_label(cxt))
+- fdisk_info(cxt, _("Disklabel type: %s"),
+- fdisk_label_get_name(lb));
+
+- if (!fdisk_is_details(cxt) && fdisk_get_disklabel_id(cxt, &id) == 0 && id) {
+- fdisk_info(cxt, _("Disk identifier: %s"), id);
+- free(id);
+- }
++ list_disk_identifier(cxt);
+ }
+
+ void list_disklabel(struct fdisk_context *cxt)
+diff --git a/disk-utils/fdisk-list.h b/disk-utils/fdisk-list.h
+index eddab92..4ed5c25 100644
+--- a/disk-utils/fdisk-list.h
++++ b/disk-utils/fdisk-list.h
+@@ -2,6 +2,7 @@
+ #define UTIL_LINUX_FDISK_LIST_H
+
+ extern void list_disklabel(struct fdisk_context *cxt);
++extern void list_disk_identifier(struct fdisk_context *cxt);
+ extern void list_disk_geometry(struct fdisk_context *cxt);
+ extern void list_freespace(struct fdisk_context *cxt);
+
+diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8
+index fcde872..efe4a86 100644
+--- a/disk-utils/sfdisk.8
++++ b/disk-utils/sfdisk.8
+@@ -212,7 +212,10 @@ Deprecated option. Only the sector unit is supported.
+ .BR \-X , " \-\-label " \fItype
+ Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option
+ is not given, then \fBsfdisk\fR defaults to the existing label, but if there
+-is no label on the device yet, then the type defaults to \fBdos\fR.
++is no label on the device yet, then the type defaults to \fBdos\fR. The default
++or the current label may be overwritten by the "label: <name>" script header
++line. The option \fB\-\-label\fR does not force \fBsfdisk\fR to create empty
++disk label (see the \fBEMPTY DISK LABEL\fR section below).
+ .TP
+ .BR \-Y , " \-\-label\-nested " \fItype
+ Force editing of a nested disk label. The primary disk label has to exist already.
+@@ -404,6 +407,19 @@ For backward compatibility the \fBId=\fR field has the same meaning.
+ .RE
+ .RE
+
++.SH "EMPTY DISK LABEL"
++.B sfdisk
++does not create partition table without partitions by default. The lines with
++partitions are expected in the script by default. The empty partition table has
++to be explicitly requested by "label: <name>" script header line without any
++partitions lines. For example:
++.RS
++.sp
++.B "echo 'label: gpt' | sfdisk /dev/sdb"
++.sp
++.RE
++creates empty GPT partition table. Note that the \fB\-\-append\fR disables this feature.
++
+ .SH "BACKING UP THE PARTITION TABLE"
+ It is recommended to save the layout of your devices.
+ .B sfdisk
+diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
+index 10307ad..2d65974 100644
+--- a/disk-utils/sfdisk.c
++++ b/disk-utils/sfdisk.c
+@@ -1766,8 +1766,25 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
+ }
+ } while (1);
+
++ /* create empty disk label if label, but no partition specified */
++ if (rc == SFDISK_DONE_EOF && created == 0
++ && fdisk_script_has_force_label(dp) == 1
++ && fdisk_table_get_nents(tb) == 0
++ && fdisk_script_get_header(dp, "label")) {
++
++ int xrc = fdisk_apply_script_headers(sf->cxt, dp);
++ created = !xrc;
++ if (xrc) {
++ fdisk_warnx(sf->cxt, _(
++ "Failed to apply script headers, "
++ "disk label not created."));
++ rc = SFDISK_DONE_ABORT;
++ }
++ }
++
+ if (!sf->quiet && rc != SFDISK_DONE_ABORT) {
+ fdisk_info(sf->cxt, _("\nNew situation:"));
++ list_disk_identifier(sf->cxt);
+ list_disklabel(sf->cxt);
+ }
+
+diff --git a/libfdisk/src/libfdisk.h.in b/libfdisk/src/libfdisk.h.in
+index 9154f5b..59cce19 100644
+--- a/libfdisk/src/libfdisk.h.in
++++ b/libfdisk/src/libfdisk.h.in
+@@ -642,6 +642,7 @@ const char *fdisk_script_get_header(struct fdisk_script *dp, const char *name);
+ int fdisk_script_set_header(struct fdisk_script *dp, const char *name, const char *data);
+ struct fdisk_table *fdisk_script_get_table(struct fdisk_script *dp);
+ int fdisk_script_get_nlines(struct fdisk_script *dp);
++int fdisk_script_has_force_label(struct fdisk_script *dp);
+
+ int fdisk_script_set_userdata(struct fdisk_script *dp, void *data);
+ void *fdisk_script_get_userdata(struct fdisk_script *dp);
+diff --git a/libfdisk/src/libfdisk.sym b/libfdisk/src/libfdisk.sym
+index 02cd7a8..d6d4ac5 100644
+--- a/libfdisk/src/libfdisk.sym
++++ b/libfdisk/src/libfdisk.sym
+@@ -274,3 +274,8 @@ FDISK_2.29 {
+ fdisk_labelitem_is_number;
+ fdisk_gpt_set_npartitions;
+ } FDISK_2.28;
++
++
++FDISK_2.30 {
++ fdisk_script_has_force_label;
++} FDISK_2.29;
+diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
+index ae7e99a..0d1f260 100644
+--- a/libfdisk/src/script.c
++++ b/libfdisk/src/script.c
+@@ -36,7 +36,8 @@ struct fdisk_script {
+ size_t nlines;
+ struct fdisk_label *label;
+
+- unsigned int json : 1; /* JSON output */
++ unsigned int json : 1, /* JSON output */
++ force_label : 1; /* label: <name> specified */
+ };
+
+
+@@ -354,6 +355,22 @@ int fdisk_script_get_nlines(struct fdisk_script *dp)
+ }
+
+ /**
++ * fdisk_script_has_force_label:
++ * @dp: script
++ *
++ * Note that fdisk_script_set_header(dp, "label", name) does not modify
++ * force_label status. The label has to be specified by script.
++ *
++ * Returns: true if "label: <name>" has been parsed.
++ */
++int fdisk_script_has_force_label(struct fdisk_script *dp)
++{
++ assert(dp);
++ return dp->force_label;
++}
++
++
++/**
+ * fdisk_script_read_context:
+ * @dp: script
+ * @cxt: context
+@@ -706,6 +723,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
+ if (strcmp(name, "label") == 0) {
+ if (dp->cxt && !fdisk_get_label(dp->cxt, value))
+ goto done; /* unknown label name */
++ dp->force_label = 1;
+ } else if (strcmp(name, "unit") == 0) {
+ if (strcmp(value, "sectors") != 0)
+ goto done; /* only "sectors" supported */
+--
+2.10.2
+
Copied: util-linux/repos/testing-x86_64/PKGBUILD (from rev 287025, util-linux/trunk/PKGBUILD)
===================================================================
--- testing-x86_64/PKGBUILD (rev 0)
+++ testing-x86_64/PKGBUILD 2017-01-20 17:48:34 UTC (rev 287026)
@@ -0,0 +1,104 @@
+# $Id$
+# Maintainer: Tom Gundersen <teg at jklm.no>
+# Maintainer: Dave Reisner <dreisner at archlinux.org>
+# Contributor: judd <jvinet at zeroflux.org>
+
+pkgbase=util-linux
+pkgname=(util-linux libutil-linux)
+_pkgmajor=2.29
+pkgver=${_pkgmajor}.1
+pkgrel=1
+pkgdesc="Miscellaneous system utilities for Linux"
+url="https://www.kernel.org/pub/linux/utils/util-linux/"
+arch=('i686' 'x86_64')
+makedepends=('systemd' 'python')
+license=('GPL2')
+options=('strip' 'debug')
+validpgpkeys=('B0C64D14301CC6EFAEDF60E4E4B71D5EEC39C284') # Karel Zak
+source=("https://www.kernel.org/pub/linux/utils/util-linux/v$_pkgmajor/$pkgbase-$pkgver.tar."{xz,sign}
+ pam-{login,common,su}
+ '0001-sfdisk-support-empty-label-use-case.patch')
+md5sums=('0cbb6d16ab9c5736e5649ef1264bee6e'
+ 'SKIP'
+ '4368b3f98abd8a32662e094c54e7f9b1'
+ 'a31374fef2cba0ca34dfc7078e2969e4'
+ 'fa85e5cce5d723275b14365ba71a8aad'
+ '6d2e3915124938577f0ff18ef701c87f')
+
+prepare() {
+ cd "$pkgbase-$pkgver"
+
+ patch -Np1 <../0001-sfdisk-support-empty-label-use-case.patch
+}
+
+build() {
+ cd "$pkgbase-$pkgver"
+
+ ./configure --prefix=/usr \
+ --libdir=/usr/lib \
+ --bindir=/usr/bin \
+ --localstatedir=/run \
+ --enable-fs-paths-extra=/usr/bin \
+ --enable-raw \
+ --enable-vipw \
+ --enable-newgrp \
+ --enable-chfn-chsh \
+ --enable-write \
+ --enable-mesg \
+ --with-python=3
+
+ make
+}
+
+package_util-linux() {
+ conflicts=('util-linux-ng' 'eject' 'zramctl')
+ provides=("util-linux-ng=$pkgver" 'eject' 'zramctl')
+ replaces=('zramctl')
+ depends=('pam' 'shadow' 'coreutils' 'libsystemd' 'libutil-linux')
+ optdepends=('python: python bindings to libmount')
+ groups=('base' 'base-devel')
+ backup=(etc/pam.d/chfn
+ etc/pam.d/chsh
+ etc/pam.d/login
+ etc/pam.d/su
+ etc/pam.d/su-l)
+
+ cd "$pkgbase-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+ # setuid chfn and chsh
+ chmod 4755 "$pkgdir"/usr/bin/{newgrp,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"
+ install -m644 "$srcdir/pam-su" "$pkgdir/etc/pam.d/su"
+ install -m644 "$srcdir/pam-su" "$pkgdir/etc/pam.d/su-l"
+
+ # TODO(dreisner): offer this upstream?
+ sed -i '/ListenStream/ aRuntimeDirectory=uuidd' "$pkgdir/usr/lib/systemd/system/uuidd.socket"
+
+ # adjust for usrmove
+ # TODO(dreisner): fix configure.ac upstream so that this isn't needed
+ cd "$pkgdir"
+ mv {,usr/}sbin/* usr/bin
+ rmdir sbin usr/sbin
+
+ ### runtime libs are shipped as part of libutil-linux
+ rm "$pkgdir"/usr/lib/lib*.{a,so}*
+
+ ### tailf has been deprecated for a while. let's not include it anymore.
+ rm \
+ "$pkgdir"/usr/bin/tailf \
+ "$pkgdir"/usr/share/bash-completion/completions/tailf \
+ "$pkgdir"/usr/share/man/man1/tailf.1
+}
+
+package_libutil-linux() {
+ pkgdesc="util-linux runtime libraries"
+ provides=('libblkid.so' 'libfdisk.so' 'libmount.so' 'libsmartcols.so' 'libuuid.so')
+
+ make -C "$pkgbase-$pkgver" DESTDIR="$pkgdir" install-usrlib_execLTLIBRARIES
+}
Copied: util-linux/repos/testing-x86_64/pam-common (from rev 287025, util-linux/trunk/pam-common)
===================================================================
--- testing-x86_64/pam-common (rev 0)
+++ testing-x86_64/pam-common 2017-01-20 17:48:34 UTC (rev 287026)
@@ -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
Copied: util-linux/repos/testing-x86_64/pam-login (from rev 287025, util-linux/trunk/pam-login)
===================================================================
--- testing-x86_64/pam-login (rev 0)
+++ testing-x86_64/pam-login 2017-01-20 17:48:34 UTC (rev 287026)
@@ -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
Copied: util-linux/repos/testing-x86_64/pam-su (from rev 287025, util-linux/trunk/pam-su)
===================================================================
--- testing-x86_64/pam-su (rev 0)
+++ testing-x86_64/pam-su 2017-01-20 17:48:34 UTC (rev 287026)
@@ -0,0 +1,9 @@
+#%PAM-1.0
+auth sufficient pam_rootok.so
+# Uncomment the following line to implicitly trust users in the "wheel" group.
+#auth sufficient pam_wheel.so trust use_uid
+# Uncomment the following line to require a user to be in the "wheel" group.
+#auth required pam_wheel.so use_uid
+auth required pam_unix.so
+account required pam_unix.so
+session required pam_unix.so
More information about the arch-commits
mailing list