You are not logged in.

#1 2023-06-15 17:05:03

loqs
Member
Registered: 2014-03-06
Posts: 16,535

[SOLVED] patch failing to apply

Updating zettlr to 3.0.0. beta.4 a patch I created with git diff is being rejected by the patch command.  I can not spot anything wrong in the diff and it applies with git apply.

zettlr-3.0.0_beta.4-1-x86_64-prepare.log

Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/package.json b/package.json
|index 3cb302a..97cdf00 100644
|--- a/package.json
|+++ b/package.json
--------------------------
patching file package.json
Using Plan A...
Hunk #1 succeeded at 156.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/yarn.lock b/yarn.lock
|index 3297493..797dc16 100644
|--- a/yarn.lock
|+++ b/yarn.lock
--------------------------
patching file yarn.lock
Using Plan A...
Hunk #1 succeeded at 5213.
Hunk #2 succeeded at 13398.
done
Checking patch package.json...
error: while searching for:
    "cross-env": "^7.0.3",
    "css-loader": "^6.7.3",
    "csso": "^5.0.5",
    "electron": "^24.1.2",
    "electron-builder": "^23.6.0",
    "electron-devtools-installer": "^3.2.0",
    "eslint": "^8.38.0",

error: patch failed: package.json:156
error: package.json: patch does not apply
Checking patch yarn.lock...
error: while searching for:
  languageName: node
  linkType: hard

"electron@npm:^24.1.2":
  version: 24.1.2
  resolution: "electron@npm:24.1.2"
  dependencies:
    "@electron/get": ^2.0.0
    "@types/node": ^18.11.18
    extract-zip: ^2.0.1
  bin:
    electron: cli.js
  checksum: 54b012bed51c0cadcb8cc7bc2bdd9c46969214bc2532d57699da2c9ec6fbfeb8b5752c56c1c05c8d8ab46b3d6856db861a23a1124012024ae0131e5df9acc269
  languageName: node
  linkType: hard


error: patch failed: yarn.lock:5213
error: yarn.lock: patch does not apply
[1m[31m==> ERROR:(B[m[1m A failure occurred in prepare().(B[m
[1m    Aborting...(B[m

PKGBUILD

# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: BrLi <brli at chakralinux dot org>

pkgname=zettlr
_pkgname=${pkgname^}
pkgver=3.0.0_beta.4
_pkgver=3.0.0-beta.4
pkgrel=1
pkgdesc='A Markdown Editor for the 21st century'
arch=(x86_64)
url=https://www.zettlr.com
_url="https://github.com/$_pkgname/$_pkgname"
license=(GPL)
_electron=electron24
depends=(crimson-font
         $_electron
         pandoc
         ttf-inconsolata
         ttf-liberation)
makedepends=(gendesk
             git
             nodejs-lts-gallium # grep NODE_VERSION .github/workflows/build.yml
             node-gyp
             yarn)
optdepends=('texlive-bin: For Latex support')
# Migration path for soon to be deleted AUR package; remove if ever reinstated
replaces=(zettlr-bin)
_archive="$_pkgname-$_pkgver"
source=("$_url/archive/v$_pkgver/$_archive.tar.gz"
        'temp.patch'
        "$pkgname.sh"
        "$pkgname.xml")
sha256sums=('9482a6d3e8f578c892fb55a7ea6c0f843e46540f500edf0fc8a4581f8841d48c'
            'd1c9e1b27241b8fb9adecca4f4112e6bd8043ce9443bfe7b139bc82a5bde2a12'
            'e300f2cac217f98ab5c365dccc7581410bc296f2842d52f7f1520dd6679d20cf'
            'c3ecbb490a1d4fa5bc42f7166cc375e5629a452d25bb1d4facb5541938681292')

#_yarnargs="--cache-folder '$srcdir/cache' --link-folder '$srcdir/link'"

prepare() {
	local _electronVersion=$($_electron --version | sed -e 's/^v//')
#	yarn info electron@24.5.1
#	false
	gendesk -q -f -n \
		--pkgname "$pkgname" \
		--pkgdesc "$pkgdesc" \
		--name "$_pkgname" \
		--categories 'Office' \
		--mimetypes 'text/markdown' \
		--custom StartupWMClass="$_pkgname"
	cd "$_archive"
	patch -Np1 --verbose -i "$srcdir"/temp.patch
	git apply -v "$srcdir"/temp.patch
	echo -ne '#!/usr/bin/env bash\n\nexit 0' > scripts/get-pandoc.sh
	sed -e "s/@ELECTRON@/$_electron/" "../${source[1]}" > $pkgname.sh
	yarn $_yarnargs install --immutable # postinstall script installs electron-builder deps
	ln -sf /usr/bin/pandoc resources/pandoc-linux-x64
}

build() {
	cd "$_archive"
	local NODE_ENV=''
	yarn $_yarnargs package:linux-x64
}

package() {
	install -Dm0644 -t "$pkgdir/usr/share/applications/" "$pkgname.desktop"
	cd "$_archive"
	install -Dm0755 "$pkgname.sh" "$pkgdir/usr/bin/$pkgname"
	local _destdir="usr/lib/$pkgname"
	install -Dm0644 -t "$pkgdir/$_destdir/" \
		"out/$_pkgname-linux-x64/resources/"{app.asar,icon.code.icns}
	for px in 16 24 32 48 64 96 128 256 512 1024; do
		install -Dm0644 "resources/icons/png/${px}x${px}.png" \
			"$pkgdir/usr/share/icons/hicolor/${px}x${px}/apps/$pkgname.png"
	done
	install -Dm0644 -t "$pkgdir/usr/share/mime/packages/" "../${source[2]}"
}

temp.patch

diff --git a/package.json b/package.json
index 3cb302a..97cdf00 100644
--- a/package.json
+++ b/package.json
@@ -156,7 +156,7 @@
     "cross-env": "^7.0.3",
     "css-loader": "^6.7.3",
     "csso": "^5.0.5",
-    "electron": "^24.1.2",
+    "electron": "^24.5.1",
     "electron-builder": "^23.6.0",
     "electron-devtools-installer": "^3.2.0",
     "eslint": "^8.38.0",
diff --git a/yarn.lock b/yarn.lock
index 3297493..797dc16 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5213,16 +5213,16 @@ __metadata:
   languageName: node
   linkType: hard
 
-"electron@npm:^24.1.2":
-  version: 24.1.2
-  resolution: "electron@npm:24.1.2"
+"electron@npm:^24.5.1":
+  version: 24.5.1
+  resolution: "electron@npm:24.5.1"
   dependencies:
     "@electron/get": ^2.0.0
     "@types/node": ^18.11.18
     extract-zip: ^2.0.1
   bin:
     electron: cli.js
-  checksum: 54b012bed51c0cadcb8cc7bc2bdd9c46969214bc2532d57699da2c9ec6fbfeb8b5752c56c1c05c8d8ab46b3d6856db861a23a1124012024ae0131e5df9acc269
+  checksum: 4910d2b89bf114dcaad0f3a1f26aae1f89ab88dcab7d7ea13faf61a133182d1131d66e2180e1ff45eb18eaaf8ad378b92eb1d21159a1ba140a94eb29f159a4a4
   languageName: node
   linkType: hard
 
@@ -13398,7 +13398,7 @@ __metadata:
     css-loader: ^6.7.3
     csso: ^5.0.5
     d3: ^7.8.4
-    electron: ^24.1.2
+    electron: ^24.5.1
     electron-builder: ^23.6.0
     electron-devtools-installer: ^3.2.0
     eslint: ^8.38.0

Last edited by loqs (2023-06-15 19:53:30)

Offline

#2 2023-06-15 18:04:11

seth
Member
Registered: 2012-09-03
Posts: 42,878

Re: [SOLVED] patch failing to apply

Try "patch -F3" (fuzz, ignore context) - can you upload the two to-be-patched files you get in the source dir as well as the patch (no copypasta)
There could be something stupid like some stray CRLF that's sanitized in the patch…

Offline

#3 2023-06-15 18:29:57

loqs
Member
Registered: 2014-03-06
Posts: 16,535

Re: [SOLVED] patch failing to apply

seth wrote:

Try "patch -F3" (fuzz, ignore context) - can you upload the two to-be-patched files you get in the source dir as well as the patch (no copypasta)

https://drive.google.com/file/d/1jVnx5u … sp=sharing zettlr-3.0.0_beta.4-1.src.tar.gz
https://github.com/Zettlr/Zettlr/archiv … a.4.tar.gz
http://ix.io/4ylf package.json
http://ix.io/4ylf yarn.lock

sha256sum package.json yarn.lock 
01fb3787ccfe44cd0034590f985b6468515cb303b528180c35592c0b07c29896  package.json
6a5706105bb6f308fcf58e4d776e01005e91b1cbf11c7c37d4f2467823ef6805  yarn.lock

Offline

#4 2023-06-15 18:37:34

seth
Member
Registered: 2012-09-03
Posts: 42,878

Re: [SOLVED] patch failing to apply

package.json and yarn.lock are the same URL (it's the package.json, sha256 is correct)
I can regularily apply the temp.patch  from the google-drive archive (well, succeeds  on package.json, fails on yarn.lock)

Are the files the one from the actual prepare step (did you sha256sum those)?

Offline

#5 2023-06-15 18:43:01

loqs
Member
Registered: 2014-03-06
Posts: 16,535

Re: [SOLVED] patch failing to apply

http://ix.io/4yle yarn.lock
From prepare() in the clean chroot

sha256sum package.json yarn.lock "$srcdir"/temp.patch
01fb3787ccfe44cd0034590f985b6468515cb303b528180c35592c0b07c29896  package.json
6a5706105bb6f308fcf58e4d776e01005e91b1cbf11c7c37d4f2467823ef6805  yarn.lock
d1c9e1b27241b8fb9adecca4f4112e6bd8043ce9443bfe7b139bc82a5bde2a12  /build/zettlr/src/temp.patch

Offline

#6 2023-06-15 18:48:02

seth
Member
Registered: 2012-09-03
Posts: 42,878

Re: [SOLVED] patch failing to apply

Applies, sha256sum's fit.

Can you patch the files (not git apply) outside the build context?

◉ patch --version
GNU patch 2.7.6
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

But it's gnu patch 2.7.6-9

Offline

#7 2023-06-15 18:58:01

loqs
Member
Registered: 2014-03-06
Posts: 16,535

Re: [SOLVED] patch failing to apply

Yes works outside the clean chroot.  Rebulding the chroot,  no change.
The following is all from within prepare() in the clean chroot:

$ which patch
/usr/bin/patch
$ patch --version
GNU patch 2.7.6
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert
$ env
SHELL=/bin/bash
BUILDTOOL=devtools
SUDO_GID=0
PYTHONHASHSEED=0
TEXTDOMAINDIR=/usr/share/locale
SUDO_COMMAND=/bin/bash -c bash -c cd\ /startdir;\ makepkg\ "$@" -bash --syncdeps --noconfirm --log --holdver --skipinteg --install
SUDO_USER=root
PWD=/build/zettlr/src/Zettlr-3.0.0-beta.4
SOURCE_DATE_EPOCH=1686855157
LOGNAME=builduser
COMMAND_MODE=legacy
HOME=/build
LANG=C.UTF-8
TERM=xterm-256color
USER=builduser
SHLVL=1
DEBUGINFOD_URLS=https://debuginfod.archlinux.org 
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
SUDO_UID=0
MAIL=/var/mail/builduser
BUILDTOOLVER=1:1.0.1-1-any
OLDPWD=/build/zettlr/src
TEXTDOMAIN=pacman-scripts
_=/usr/bin/env
$ locale
LANG=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

Edit:
Swapping to the following works:

	patch -Np1 -F0 -i "$srcdir"/temp.patch -d "$_archive"

Last edited by loqs (2023-06-15 19:21:50)

Offline

#8 2023-06-15 19:22:58

seth
Member
Registered: 2012-09-03
Posts: 42,878

Re: [SOLVED] patch failing to apply

My gut tells me that seek/lseek or getrandom somehow fail but I can't say why (filesystem? no devfs? urandom blocks?)

strace -o patch.strace patch -Np1 --verbose -i "$srcdir"/temp.patch

Edit: that was before the fuzzy adjustment.
Edit #2… or dir change.

Which one is actually relevant?

Last edited by seth (2023-06-15 19:25:31)

Offline

#9 2023-06-15 19:35:20

loqs
Member
Registered: 2014-03-06
Posts: 16,535

Re: [SOLVED] patch failing to apply

I removed -F0 so it should be down to the path difference.
Edit:
It has started working now.

Last edited by loqs (2023-06-15 19:50:03)

Offline

#10 2023-06-15 19:55:34

seth
Member
Registered: 2012-09-03
Posts: 42,878

Re: [SOLVED] patch failing to apply

So the cd fails…?
Did you check the pwd after the cd/before patch?

Edit: for clarification, I've basically infinite curiosity and a lazy way to the answers - you don't have to ckeck this if you personally don't care wink

Last edited by seth (2023-06-15 19:57:31)

Offline

#11 2023-06-15 20:18:30

loqs
Member
Registered: 2014-03-06
Posts: 16,535

Re: [SOLVED] patch failing to apply

I did check the pwd,  it is listed in the env output in post #7.  makepkg also runs with set -e.  My guess it something must have been broken in the chroot and I had messed with the PKGBUILD too much by the time I rebuilt it that I had broken the PKGBUILD.

Offline

Board footer

Powered by FluxBB