From e06f417f863b147dd54ab7fd5b9033b5a169b87d Mon Sep 17 00:00:00 2001
From: Sodface <sod@sodface.com>
Date: Sat, 19 Mar 2022 18:05:49 -0400
Subject: [PATCH] community/althttpd: upgrade to 202203180956

---
 .../10-allow-filename-plus-sign.patch         |  2 +-
 community/althttpd/20-force-GMT-headers.patch | 14 ---------
 community/althttpd/APKBUILD                   | 30 +++++++++++--------
 community/althttpd/althttpd.confd             | 23 ++++++++++----
 4 files changed, 35 insertions(+), 34 deletions(-)
 delete mode 100644 community/althttpd/20-force-GMT-headers.patch

diff --git a/community/althttpd/10-allow-filename-plus-sign.patch b/community/althttpd/10-allow-filename-plus-sign.patch
index 15e111374bd0..44dd2be66a66 100644
--- a/community/althttpd/10-allow-filename-plus-sign.patch
+++ b/community/althttpd/10-allow-filename-plus-sign.patch
@@ -4,7 +4,7 @@ adds the plus sign (0x2b) to the list of characters allowed by upstream
 which are 0-9a-zA-Z,-./:_~
 --- src/althttpd.c.orig
 +++ src/althttpd.c
-@@ -1213,7 +1213,7 @@
+@@ -1632,7 +1632,7 @@
        /*  x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */
  /* 0x */   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  /* 1x */   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
diff --git a/community/althttpd/20-force-GMT-headers.patch b/community/althttpd/20-force-GMT-headers.patch
deleted file mode 100644
index 44e9783ee976..000000000000
--- a/community/althttpd/20-force-GMT-headers.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-The strftime %Z format specifier returns UTC on musl in this
-context, force use of GMT to prevent client errors.
-See https://gitlab.alpinelinux.org/alpine/aports/-/issues/12979
---- src/althttpd.c.orig
-+++ src/althttpd.c
-@@ -617,7 +617,7 @@
-   struct tm *tm;
-   static char zDate[100];
-   tm = gmtime(&t);
--  strftime(zDate, sizeof(zDate), "%a, %d %b %Y %H:%M:%S %Z", tm);
-+  strftime(zDate, sizeof(zDate), "%a, %d %b %Y %H:%M:%S GMT", tm);
-   return zDate;
- }
- 
diff --git a/community/althttpd/APKBUILD b/community/althttpd/APKBUILD
index 7cd1d2f1b26a..e9be18b4a8ef 100644
--- a/community/althttpd/APKBUILD
+++ b/community/althttpd/APKBUILD
@@ -1,23 +1,25 @@
 # Contributor: Sodface <sod@sodface.com>
 # Maintainer: Sodface <sod@sodface.com>
 pkgname=althttpd
-pkgver=202108141729
-pkgrel=1
+pkgver=202203180956
+pkgrel=0
 pkgdesc="Small, simple, stand-alone HTTP server"
 url="https://sqlite.org/althttpd/doc/trunk/althttpd.md"
 arch="all"
 license="Public-Domain"
+makedepends="openssl-dev"
 options="!check" # no test suite
-subpackages="$pkgname-openrc"
-source="$pkgname-$pkgver.zip::https://sqlite.org/althttpd/zip?in=althttpd.c&r=$pkgver
+subpackages="$pkgname-doc $pkgname-openrc"
+source="
+	$pkgname-$pkgver.tar.gz::https://sqlite.org/althttpd/tarball?r=$pkgver
 	10-allow-filename-plus-sign.patch
-	20-force-GMT-headers.patch
 	$pkgname.confd
-	$pkgname.initd"
-builddir="$srcdir/"
+	$pkgname.initd
+	"
+builddir="$srcdir"
 
 build() {
-	gcc $CFLAGS althttpd.c $LDFLAGS -o althttpd
+	make althttpsd
 }
 
 package() {
@@ -25,13 +27,15 @@ package() {
 		"$pkgdir"/etc/conf.d/althttpd
 	install -Dm 755 "$srcdir"/althttpd.initd \
 		"$pkgdir"/etc/init.d/althttpd
-	install -D althttpd "$pkgdir"/usr/bin/althttpd
+	install -D althttpsd \
+		"$pkgdir"/usr/bin/althttpd
+	install -Dm644 althttpd.md \
+		"$pkgdir"/usr/share/doc/$pkgname/althttpd.md
 }
 
 sha512sums="
-4b3fe1d2bd6eab1048f6329741322b9dee73493f070bcb84294b6e8150d093b934b01cae74778e22536330dd97f27a119181edfd32401333a020eb3df6e2935b  althttpd-202108141729.zip
-d31628a3b6617cc49156fe3680c3d4f964a0b2ed7570edc23b9d52ed6fe7693022067a051b60d2fcb5f695be5a3daa8589fa9ba3c1ac12bd03306925e8a10015  10-allow-filename-plus-sign.patch
-9c6acaaa259abb5a9f404d12b27e3b9659064f78f5951c10ee26c67de4f2c775e5223129f640916703a25a96517bd1eb84b7a76e3bc86341f73e12fc121d1e89  20-force-GMT-headers.patch
-aeb1252915176d11cddb1ff5f1c13f532bb3df8f52760f71ae087fde90a4d4422cc65570a59adac12232dacc5aed67a673790a019a3d53203899b7909ca8503b  althttpd.confd
+232b8eb0ddbf13036612969837ea4dd54b9a2cc23898e0c5b74000463b6ff18d9f5d9fdd1905be7a2b87ad42ac9541f811e3e04a410b0638739a5f47e40f86ed  althttpd-202203180956.tar.gz
+2ae6bb952a1d6e4e7b7f78c09e91d5b0fcf9b520dd6305c282f36c7e2e2c0280020947a3ce5fc0fb2961fc2db3689421b1ad81a1fe31ae5f4a0a0c0878bb7bfc  10-allow-filename-plus-sign.patch
+6bee7c54a75782d2112956e85b7105ddf47189d7c8b9f5a8609e6d20813ecba0e3331f85734faf350d6279bcc988ca2d34091cbcf98807b79564fa38e3ce4a29  althttpd.confd
 f21867430470b836d97d60215d9dda835125140cced3bb9c856349228572f2c73ac0574d3f705d72938879fc2b5a37855768a5f7de5c29943e3aa6ead5d72d9c  althttpd.initd
 "
diff --git a/community/althttpd/althttpd.confd b/community/althttpd/althttpd.confd
index 154f98c88887..f222185a5ba7 100644
--- a/community/althttpd/althttpd.confd
+++ b/community/althttpd/althttpd.confd
@@ -23,9 +23,10 @@
 #**                   FILE name is expanded using strftime() if it contains
 #**                   at least one '%' and is not too long.
 #**
-#**  --https          Indicates that input is coming over SSL and is being
-#**                   decoded upstream, perhaps by stunnel.  (This program
-#**                   only understands plaintext.)
+#**  --https BOOLEAN  Indicates that input is coming over SSL and is being
+#**                   decoded upstream, perhaps by stunnel. This option
+#**                   does *not* activate built-in TLS support.  Use --cert
+#**                   for that.
 #**
 #**  --family ipv4    Only accept input from IPV4 or IPV6, respectively.
 #**  --family ipv6    These options are only meaningful if althttpd is run
@@ -40,12 +41,22 @@
 #**                   120 seconds.
 #**
 #**  --max-cpu SEC    Maximum number of seconds of CPU time allowed per
-#**                   HTTP connection.  Default 30.  0 means no limit.
+#**                   HTTP connection.  Default 30 (build option:
+#**                   -DMAX_CPU=integer). 0 means no limit.
 #**
 #**  --debug          Disables input timeouts.  This is useful for debugging
-#**                   when inputs is being typed in manually.
+#**                   when inputs are being typed in manually.
+#**
+#** Additional command-line options available when compiling with ENABLE_TLS:
+#**
+#**  --cert FILE      The TLS certificate, the "fullchain.pem" file
+#**
+#**  --pkey FILE      The TLS private key, the "privkey.pem" file.  May be
+#**                   omitted if the --cert file is the concatenation of
+#**                   the fullchain.pem and the privkey.pem.
+#**
 #**
 #** Command-line options can take either one or two initial "-" characters.
 #** So "--debug" and "-debug" mean the same thing, for example.
-
+#**
 ALTHTTPD_OPTS=""
-- 
GitLab