From deae945a8b54b2cc1cec51474cf865bb9f18b9e8 Mon Sep 17 00:00:00 2001
From: Eduard Braun <eduard.braun2@gmx.de>
Date: Sat, 10 Feb 2018 23:24:18 +0100
Subject: [PATCH] pacman: change default answer of all queries to yes

This allows to use pacman completely unattended using the
--noconfirm switch which automatically accepts the default answer.

Fixes #1141
---
 pacman/0008-answer-yes-by-default.patch | 72 +++++++++++++++++++++++++
 pacman/PKGBUILD                         | 12 +++--
 2 files changed, 80 insertions(+), 4 deletions(-)
 create mode 100644 pacman/0008-answer-yes-by-default.patch

diff --git a/pacman/0008-answer-yes-by-default.patch b/pacman/0008-answer-yes-by-default.patch
new file mode 100644
index 00000000000..e52cdf810f3
--- /dev/null
+++ b/pacman/0008-answer-yes-by-default.patch
@@ -0,0 +1,72 @@
+From 09ad07d05d61d3c15409eae9297493d633aaeecd Mon Sep 17 00:00:00 2001
+From: Eduard Braun <eduard.braun2@gmx.de>
+Date: Sat, 10 Feb 2018 22:39:35 +0100
+Subject: [PATCH] Change default answer of all queries to yes
+
+This allows to use pacman completely unattended using the
+--noconfirm switch which automatically accepts the default answer.
+
+See https://github.com/Alexpux/MSYS2-packages/issues/1141
+---
+ src/pacman/callback.c | 6 +++---
+ src/pacman/remove.c   | 2 +-
+ src/pacman/sync.c     | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/pacman/callback.c b/src/pacman/callback.c
+index c1679e37..cbb01092 100644
+--- a/src/pacman/callback.c
++++ b/src/pacman/callback.c
+@@ -416,12 +416,12 @@ void cb_question(alpm_question_t *question)
+ 				/* print conflict only if it contains new information */
+ 				if(strcmp(q->conflict->package1, q->conflict->reason->name) == 0
+ 						|| strcmp(q->conflict->package2, q->conflict->reason->name) == 0) {
+-					q->remove = noyes(_("%s and %s are in conflict. Remove %s?"),
++					q->remove = yesno(_("%s and %s are in conflict. Remove %s?"),
+ 							q->conflict->package1,
+ 							q->conflict->package2,
+ 							q->conflict->package2);
+ 				} else {
+-					q->remove = noyes(_("%s and %s are in conflict (%s). Remove %s?"),
++					q->remove = yesno(_("%s and %s are in conflict (%s). Remove %s?"),
+ 							q->conflict->package1,
+ 							q->conflict->package2,
+ 							q->conflict->reason->name,
+@@ -445,7 +445,7 @@ void cb_question(alpm_question_t *question)
+ 							count));
+ 				list_display("     ", namelist, getcols());
+ 				printf("\n");
+-				q->skip = noyes(_n(
++				q->skip = yesno(_n(
+ 							"Do you want to skip the above package for this upgrade?",
+ 							"Do you want to skip the above packages for this upgrade?",
+ 							count));
+diff --git a/src/pacman/remove.c b/src/pacman/remove.c
+index 73b48c36..a25d73af 100644
+--- a/src/pacman/remove.c
++++ b/src/pacman/remove.c
+@@ -146,7 +146,7 @@ int pacman_remove(alpm_list_t *targets)
+ 			holdpkg = 1;
+ 		}
+ 	}
+-	if(holdpkg && (noyes(_("HoldPkg was found in target list. Do you want to continue?")) == 0)) {
++	if(holdpkg && (yesno(_("HoldPkg was found in target list. Do you want to continue?")) == 0)) {
+ 		retval = 1;
+ 		goto cleanup;
+ 	}
+diff --git a/src/pacman/sync.c b/src/pacman/sync.c
+index 0f41fad9..62749aae 100644
+--- a/src/pacman/sync.c
++++ b/src/pacman/sync.c
+@@ -194,7 +194,7 @@ static int sync_cleancache(int level)
+ 			}
+ 			printf(_("removing old packages from cache...\n"));
+ 		} else {
+-			if(!noyes(_("Do you want to remove ALL files from cache?"))) {
++			if(!yesno(_("Do you want to remove ALL files from cache?"))) {
+ 				printf("\n");
+ 				continue;
+ 			}
+-- 
+2.16.1.windows.4
+
diff --git a/pacman/PKGBUILD b/pacman/PKGBUILD
index 0640ac72291..10043fa0aa7 100644
--- a/pacman/PKGBUILD
+++ b/pacman/PKGBUILD
@@ -4,7 +4,7 @@
 
 pkgname=pacman
 pkgver=5.0.1
-pkgrel=4
+pkgrel=5
 pkgdesc="A library-based package manager with dependency support (MSYS2 port)"
 arch=('i686' 'x86_64')
 url="https://www.archlinux.org/pacman/"
@@ -37,7 +37,8 @@ makedepends=('asciidoc'
              'libarchive-devel'
              'libcurl-devel'
              'libgpgme-devel'
-             'libsqlite-devel')
+             'libsqlite-devel'
+             'libunistring-devel')
 provides=('pacman-contrib')
 conflicts=('pacman-contrib')
 replaces=('pacman-contrib')
@@ -59,7 +60,8 @@ source=(https://sources.archlinux.org/other/pacman/${pkgname}-${pkgver}.tar.gz{,
         "0004-Link-pacman-with-static-libraries.patch"
         "0005-Hack-gettext-libalpm-pkg-config-static-link.patch"
         "0006-makepkg-avoid-creating-.tar-files-with-extended-attr.patch"
-        "0007-exe-interp-ignore-file-conflict.patch")
+        "0007-exe-interp-ignore-file-conflict.patch"
+        "0008-answer-yes-by-default.patch")
 sha256sums=('8bd5f407ce8e05c4be8f1c4be4d8dcc8550ea5e494937da5220ea2c23cbb8e04'
             'SKIP'
             '6024bbf50cc92236b7b437430cb9e4180da91925cdc19a5a7910fe172931cfb6'
@@ -74,7 +76,8 @@ sha256sums=('8bd5f407ce8e05c4be8f1c4be4d8dcc8550ea5e494937da5220ea2c23cbb8e04'
             '1ec59e4262546a4f25432a9194adadd039641f61225c71e56464dc641ae4a299'
             '1c71c5f38a408fbc027db164730739e644047706a0ea3f8330ea1666a58e3e91'
             '3422115a859547b25babb5181301a0e9a485d6bc5de5169c828d59fd88486952'
-            'a88d4531283d5b85cde5793c8867bb554fdac7513f948f172c0d64ea0ca544f9')
+            'a88d4531283d5b85cde5793c8867bb554fdac7513f948f172c0d64ea0ca544f9'
+            'e4f6e17af19e17e745a9f1c6b8402f5896229062c82167cb61f8e7d29eda716c')
 
 prepare() {
   cd ${srcdir}/${pkgname}-${pkgver}
@@ -86,6 +89,7 @@ prepare() {
   patch -p1 -i ${srcdir}/0005-Hack-gettext-libalpm-pkg-config-static-link.patch
   patch -p1 -i ${srcdir}/0006-makepkg-avoid-creating-.tar-files-with-extended-attr.patch
   patch -p1 -i ${srcdir}/0007-exe-interp-ignore-file-conflict.patch
+  patch -p1 -i ${srcdir}/0008-answer-yes-by-default.patch
 
   autoreconf -fi
 }