From dd4b9c4a2b0e2e32ef6150c488f2ca8d14daf173 Mon Sep 17 00:00:00 2001
From: Dominik Schrempf
Date: Wed, 6 May 2020 13:18:14 +0200
Subject: patch pid file

---
 .SRCINFO          |  4 +++-
 100-pidfile.patch | 11 +++++++++++
 PKGBUILD          | 11 ++++++-----
 3 files changed, 20 insertions(+), 6 deletions(-)
 create mode 100644 100-pidfile.patch

diff --git a/.SRCINFO b/.SRCINFO
index d0a3b4a..443ff96 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
 pkgbase = htpdate
 	pkgdesc = A client for time synchronisation
 	pkgver = 1.2.2
-	pkgrel = 2
+	pkgrel = 3
 	url = http://www.vervest.org/htp/
 	arch = i686
 	arch = x86_64
@@ -9,8 +9,10 @@ pkgbase = htpdate
 	depends = glibc
 	source = http://www.vervest.org/htp/archive/c/htpdate-1.2.2.tar.xz
 	source = htpdate.service
+	source = 100-pidfile.patch
 	md5sums = aad8c33933648532ac8716c809b15be1
 	md5sums = d00fce722a88150cffb1b322e6cc8869
+	md5sums = f4612bb44274ed571117724a49abb3c1
 
 pkgname = htpdate
 
diff --git a/100-pidfile.patch b/100-pidfile.patch
new file mode 100644
index 0000000..a56aba4
--- /dev/null
+++ b/100-pidfile.patch
@@ -0,0 +1,11 @@
+--- htpdate.c	2019-07-12 19:10:17.000000000 +0200
++++ htpdate.c.patched	2020-05-06 13:15:51.419075086 +0200
+@@ -499,7 +499,7 @@
+ 			printlog( 1, "Error writing pid file" );
+ 			exit(1);
+ 		} else {
+-			fprintf( pid_file, "%u\n", (unsigned short)pid );
++			fprintf( pid_file, "%d\n", (signed int)pid );
+ 			fclose( pid_file );
+ 		}
+ 		printlog( 0, "htpdate version "VERSION" started" );
diff --git a/PKGBUILD b/PKGBUILD
index 1ec24cd..ee6d7b5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
 # Contributor: Hussam Al-Tayeb <hussam at visp dot net dot lb>
 pkgname=htpdate
 pkgver=1.2.2
-pkgrel=2
+pkgrel=3
 pkgdesc="A client for time synchronisation"
 arch=(i686 x86_64)
 url="http://www.vervest.org/htp/"
@@ -12,14 +12,15 @@ depends=('glibc')
 # TODO: In the process of adding two patches from OpenWRT, but they are rejected.
 # See https://aur.archlinux.org/packages/htpdate/.
 source=("http://www.vervest.org/htp/archive/c/${pkgname}-${pkgver}.tar.xz"
-        "htpdate.service")
+        "htpdate.service"
+        "100-pidfile.patch")
 md5sums=('aad8c33933648532ac8716c809b15be1'
-         'd00fce722a88150cffb1b322e6cc8869')
-        # "100-adjtimex.patch"
-        # "101-daemon-run-in-foreground.patch")
+         'd00fce722a88150cffb1b322e6cc8869'
+         'f4612bb44274ed571117724a49abb3c1')
 
 build() {
   cd ${pkgname}-${pkgver}
+  patch htpdate.c 100-pidfile.patch
   make
 }
 
-- 
cgit v1.2.3-70-g09d2