From e571a84de2f4e81349649ca829f781d242d6ed5e Mon Sep 17 00:00:00 2001
From: Dan Johansen <strit@manjaro.org>
Date: Thu, 30 Jan 2020 19:53:52 +0100
Subject: [PATCH] remove sync first option add sync filesystem patch add
 makepkg seccomp fix patch Signed-off-by: Dan Johansen <strit@manjaro.org>

---
 0001-Sychronize-filesystem.patch              |  32 +++++
 PKGBUILD                                      |  18 ++-
 makepkg-fix-one-more-file-seccomp-issue.patch |  30 +++++
 pacman-init.service                           |   2 +-
 pacman-sync-first-option.patch                | 127 ------------------
 pacman.conf                                   |   2 +-
 6 files changed, 76 insertions(+), 135 deletions(-)
 create mode 100644 0001-Sychronize-filesystem.patch
 create mode 100644 makepkg-fix-one-more-file-seccomp-issue.patch
 delete mode 100644 pacman-sync-first-option.patch

diff --git a/0001-Sychronize-filesystem.patch b/0001-Sychronize-filesystem.patch
new file mode 100644
index 0000000..c6daa6e
--- /dev/null
+++ b/0001-Sychronize-filesystem.patch
@@ -0,0 +1,32 @@
+From 2eb709681537fed1156b2e1dc134e194e7b5c762 Mon Sep 17 00:00:00 2001
+From: Kevin Mihelich <kevin@archlinuxarm.org>
+Date: Sat, 13 Sep 2014 18:58:16 -0600
+Subject: [PATCH 1/3] Sychronize filesystem
+
+Since many problems arise from improper flushing of the filesystem,
+particularly package installations followed by a reboot very shorly after,
+this will perform a sync() after installations and removals to ensure a
+consistent filesystem state after package operations.
+
+Signed-off-by: Kevin Mihelich <kevin@archlinuxarm.org>
+---
+ lib/libalpm/trans.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
+index 4d97921f..531dbbe4 100644
+--- a/lib/libalpm/trans.c
++++ b/lib/libalpm/trans.c
+@@ -230,6 +230,9 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
+ 
+ 	trans->state = STATE_COMMITED;
+ 
++	_alpm_log(handle, ALPM_LOG_DEBUG, "synchronizing filesystem\n");
++	sync();
++
+ 	return 0;
+ }
+ 
+-- 
+2.22.0
+
diff --git a/PKGBUILD b/PKGBUILD
index 4e5a0c7..5b7b523 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -10,7 +10,7 @@
 pkgname=pacman
 pkgver=5.2.1
 _pkgver=1.2.0
-pkgrel=1
+pkgrel=2
 pkgdesc="A library-based package manager with dependency support"
 arch=('i686' 'x86_64' 'armv7h' 'aarch64')
 url="http://www.archlinux.org/pacman/"
@@ -31,7 +31,9 @@ source=(https://sources.archlinux.org/other/pacman/$pkgname-$pkgver.tar.gz
         https://sources.archlinux.org/other/community/pacman-contrib/pacman-contrib-$_pkgver.tar.gz
         pacman.conf
         makepkg.conf
-        pacman-sync-first-option.patch
+        #pacman-sync-first-option.patch
+        0001-Sychronize-filesystem.patch
+        makepkg-fix-one-more-file-seccomp-issue.patch
         etc-pacman.d-gnupg.mount
         pacman-init.service)
 
@@ -39,7 +41,10 @@ prepare() {
   cd $srcdir/$pkgname-$pkgver
 
   # Manjaro patches
-  patch -p1 -i $srcdir/pacman-sync-first-option.patch
+  #patch -p1 -i $srcdir/pacman-sync-first-option.patch
+  # Arch Linux ARM patches
+  patch -p1 -i $srcdir/0001-Sychronize-filesystem.patch
+  patch -p1 -i $srcdir/makepkg-fix-one-more-file-seccomp-issue.patch
 
   ./configure --prefix=/usr --sysconfdir=/etc \
     --localstatedir=/var --enable-doc \
@@ -114,8 +119,9 @@ esac
 
 sha256sums=('1930c407265fd039cb3a8e6edc82f69e122aa9239d216d9d57b9d1b9315af312'
             '317f53819e35647a19138cb0d68e16206af4a80f52115a7cd622c4a367f914b7'
-            'b6eb027e753e6b0532247d6f2c334d73032a8c9eae138f88865ed18397a67377'
+            '837f01bbc419a9ef20c5b649ed76f9602e349feb78c6fb4aba115c0720fe77e5'
             'f187a5919f06c6e3d3e67f2d4b9ac14217accaae1ce7e226ff133bcbfde3f03d'
-            '8167155d3a3e15fc4a1b1e989fdb826779e7b3690a52e2ca9d307ae0b1550e1d'
+            '187bef40b14461ef7caba83e8124b6725e0cc9d46fa84353dae3b2afdc013589'
+            'e481a161bba76729cd434c97e0b319ddfcb1d93b2e4890d72b4e8a32982531d9'
             'b6d14727ec465bb66d0a0358163b1bbfafcb4eaed55a0f57c30aabafae7eed68'
-            '65d8bdccdcccb64ae05160b5d1e7f3e45e1887baf89dda36c1bd44c62442f91b')
+            '862a0c30d1a1824b446a9400feba165d5cd5871491a4b7aeb5595d99db47ca93')
diff --git a/makepkg-fix-one-more-file-seccomp-issue.patch b/makepkg-fix-one-more-file-seccomp-issue.patch
new file mode 100644
index 0000000..7b077ad
--- /dev/null
+++ b/makepkg-fix-one-more-file-seccomp-issue.patch
@@ -0,0 +1,30 @@
+From 00cfc6c5c9700b597c384743c2f057a2ba7125e2 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz@archlinux.org>
+Date: Thu, 9 Jan 2020 20:49:17 -0500
+Subject: [pacman-dev] [PATCH] makepkg: fix one more file-seccomp issue
+
+When file is called via fakeroot, it doesn't matter whether you use -z
+or not, it is still incompatible with seccomp. Fix by configuring it
+with FILECMD when used in the fakeroot 'tidy' run.
+
+Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
+---
+ scripts/libmakepkg/tidy/strip.sh.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
+index 1bd810f0..876f00f0 100644
+--- a/scripts/libmakepkg/tidy/strip.sh.in
++++ b/scripts/libmakepkg/tidy/strip.sh.in
+@@ -111,7 +111,7 @@ tidy_strip() {
+ 
+ 		local binary strip_flags
+ 		find . -type f -perm -u+w -print0 2>/dev/null | while IFS= read -rd '' binary ; do
+-			case "$(file -bi "$binary")" in
++			case "$(@FILECMD@ -bi "$binary")" in
+ 				*application/x-sharedlib*)  # Libraries (.so)
+ 					strip_flags="$STRIP_SHARED";;
+ 				*application/x-archive*)    # Libraries (.a)
+-- 
+2.24.1
+
diff --git a/pacman-init.service b/pacman-init.service
index 45485a5..073ee14 100644
--- a/pacman-init.service
+++ b/pacman-init.service
@@ -9,7 +9,7 @@ After=etc-pacman.d-gnupg.mount
 Type=oneshot
 RemainAfterExit=yes
 ExecStart=/usr/bin/pacman-key --init
-ExecStart=/usr/bin/pacman-key --populate archlinux manjaro
+ExecStart=/usr/bin/pacman-key --populate archlinux archlinuxarm manjaro manjaro-arm
 
 [Install]
 WantedBy=multi-user.target
diff --git a/pacman-sync-first-option.patch b/pacman-sync-first-option.patch
deleted file mode 100644
index fe904e3..0000000
--- a/pacman-sync-first-option.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -Nur a/etc/pacman.conf.in b/etc/pacman.conf.in
---- a/etc/pacman.conf.in	2013-04-30 13:05:45.000000000 +0200
-+++ b/etc/pacman.conf.in	2014-12-23 11:43:38.039141449 +0100
-@@ -15,6 +15,8 @@
- #LogFile     = @localstatedir@/log/pacman.log
- #GPGDir      = @sysconfdir@/pacman.d/gnupg/
- HoldPkg     = pacman glibc
-+# If upgrades are available for these packages they will be asked for first
-+SyncFirst   = pacman
- #XferCommand = /usr/bin/curl -L -C - -f -o %o %u
- #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
- #CleanMethod = KeepInstalled
-diff -Nur a/src/pacman/conf.c b/src/pacman/conf.c
---- a/src/pacman/conf.c	2014-12-19 04:48:00.000000000 +0100
-+++ b/src/pacman/conf.c	2014-12-23 11:45:05.435334649 +0100
-@@ -132,6 +132,7 @@
- 	alpm_list_free(oldconfig->explicit_removes);
- 
- 	FREELIST(oldconfig->holdpkg);
-+	FREELIST(oldconfig->syncfirst);
- 	FREELIST(oldconfig->ignorepkg);
- 	FREELIST(oldconfig->ignoregrp);
- 	FREELIST(oldconfig->assumeinstalled);
-@@ -513,6 +514,8 @@
- 			setrepeatingoption(value, "IgnoreGroup", &(config->ignoregrp));
- 		} else if(strcmp(key, "HoldPkg") == 0) {
- 			setrepeatingoption(value, "HoldPkg", &(config->holdpkg));
-+		} else if(strcmp(key, "SyncFirst") == 0) {
-+			setrepeatingoption(value, "SyncFirst", &(config->syncfirst));
- 		} else if(strcmp(key, "CacheDir") == 0) {
- 			setrepeatingoption(value, "CacheDir", &(config->cachedirs));
- 		} else if(strcmp(key, "Architecture") == 0) {
-diff -Nur a/src/pacman/conf.h b/src/pacman/conf.h
---- a/src/pacman/conf.h	2014-10-14 02:44:20.000000000 +0200
-+++ b/src/pacman/conf.h	2014-12-23 11:45:38.021824780 +0100
-@@ -99,6 +99,7 @@
- 	/* select -Sc behavior */
- 	unsigned short cleanmethod;
- 	alpm_list_t *holdpkg;
-+	alpm_list_t *syncfirst;
- 	alpm_list_t *ignorepkg;
- 	alpm_list_t *ignoregrp;
- 	alpm_list_t *assumeinstalled;
-diff -Nur a/src/pacman/sync.c b/src/pacman/sync.c
---- a/src/pacman/sync.c	2014-12-19 04:48:00.000000000 +0100
-+++ b/src/pacman/sync.c	2014-12-23 11:51:26.049939350 +0100
-@@ -548,6 +548,26 @@
- 	return ret;
- }
- 
-+static alpm_list_t *syncfirst(void) {
-+	alpm_list_t *i, *res = NULL;
-+	alpm_db_t *db_local = alpm_get_localdb(config->handle);
-+	alpm_list_t *syncdbs = alpm_get_syncdbs(config->handle);
-+
-+	for(i = config->syncfirst; i; i = alpm_list_next(i)) {
-+		const char *pkgname = i->data;
-+		alpm_pkg_t *pkg = alpm_db_get_pkg(db_local, pkgname);
-+		if(pkg == NULL) {
-+			continue;
-+		}
-+
-+		if(alpm_sync_get_new_version(pkg, syncdbs)) {
-+			res = alpm_list_add(res, strdup(pkgname));
-+		}
-+	}
-+
-+	return res;
-+}
-+
- static alpm_db_t *get_db(const char *dbname)
- {
- 	alpm_list_t *i;
-@@ -959,6 +979,53 @@
- 		}
- 	}
- 
-+	/* check for syncfirsts */
-+	if(!config->op_s_downloadonly && !config->print) {
-+		/* check for newer versions of packages to be upgraded first */
-+		alpm_list_t *i, *j, *syncfirsts = syncfirst();
-+		if(syncfirsts) {
-+			/* Do not ask user if all the -S targets are SyncFirst packages, see FS#15810 */
-+			alpm_list_t *targets_diff = alpm_list_diff(targets, syncfirsts, (alpm_list_fn_cmp)strcmp);
-+			if(config->op_s_upgrade || targets_diff) {
-+				int syncfirst_ret = 1;
-+				colon_printf(_("Some packages should be upgraded first...\n"));
-+				if(trans_init(0, 1) == 0) {
-+					for(i = syncfirsts; i; i = alpm_list_next(i)) {
-+						syncfirst_ret = process_targname(alpm_get_syncdbs(config->handle), i->data, 0);
-+						if (syncfirst_ret == 1) {
-+							break;
-+						}
-+					}
-+				}
-+				if (syncfirst_ret == 0) {
-+					syncfirst_ret = sync_prepare_execute();
-+				} else {
-+					trans_release();
-+				}
-+				if (syncfirst_ret == 0) {
-+					/* reinitialize handle to take care of changes */
-+					parseconfig(config->configfile);
-+					/* remove syncfirsts from targets */
-+					alpm_list_t *i = targets;
-+					while(i) {
-+						for(j = syncfirsts; j; j = alpm_list_next(j)) {
-+							if(strcmp(i->data, j->data) == 0) {
-+								targets = alpm_list_remove_item(targets, i);
-+								break;
-+							}
-+						}
-+						i = i->next;
-+					}
-+				}
-+				printf("\n");
-+			} else {
-+				pm_printf(ALPM_LOG_DEBUG, "skipping SyncFirst\n");
-+			}
-+			alpm_list_free(targets_diff);
-+			FREELIST(syncfirsts);
-+		}
-+	}
-+
- 	return sync_trans(targets);
- }
- 
diff --git a/pacman.conf b/pacman.conf
index ca0abc9..8d9fb28 100644
--- a/pacman.conf
+++ b/pacman.conf
@@ -16,7 +16,7 @@
 #GPGDir      = /etc/pacman.d/gnupg/
 HoldPkg      = pacman glibc manjaro-system
 # If upgrades are available for these packages they will be asked for first
-SyncFirst    = manjaro-system manjaro-keyring manjaro-arm-keyring
+#SyncFirst    = manjaro-system manjaro-keyring manjaro-arm-keyring
 #XferCommand = /usr/bin/curl -C - -f %u > %o
 #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
 #CleanMethod = KeepInstalled
-- 
GitLab