瀏覽代碼

init commit

Noah Vogt 3 年之前
當前提交
fa010525eb
共有 3 個文件被更改,包括 258 次插入0 次删除
  1. 29 0
      .SRCINFO
  2. 50 0
      PKGBUILD
  3. 179 0
      xdg-compliant-wget-hsts-file.patch

+ 29 - 0
.SRCINFO

@@ -0,0 +1,29 @@
+pkgbase = wget
+	pkgdesc = Network utility to retrieve files from the Web - but moving ~/.wget-hsts to $XDG_CACHE_HOME/wget/hsts
+	pkgver = 1.21.2
+	pkgrel = 1
+	url = https://www.gnu.org/software/wget/wget.html
+	arch = x86_64
+	license = GPL3
+	depends = glibc
+	depends = zlib
+	depends = gnutls
+	depends = libidn2
+	depends = libidn2.so
+	depends = util-linux-libs
+	depends = libuuid.so
+	depends = libpsl
+	depends = libpsl.so
+	depends = pcre2
+	depends = nettle
+	depends = libnettle.so
+	optdepends = ca-certificates: HTTPS downloads
+	backup = etc/wgetrc
+	source = https://ftp.gnu.org/gnu/wget/wget-1.21.2.tar.lz
+	source = xdg-compliant-wget-hsts-file.patch
+	sha256sums = 1727a330a86acacb3e57615ce268f5f29978bf7adec4abe6a30d370207bc91b3
+	sha256sums = e7f03d1f253e4b66c38271f4a47ae8d849ac6241c60728b56be1a10b94611293
+	b2sums = 9141b27f2db587bbd34cb97ecf4a6179e564817067b45c8168390cf1548c1a18f71723247d82b11f2edf3981a9b9f0d2097afe5d56397e033b0a86adae9482b1
+	b2sums = 0da265b080a193805605bb8705e69e43a07aef062205ae9cf3558ac5e1199b67275f406337153018af4ec1631ef066cdd6eebbd5ba8029b3855e8c71c5953b2e
+
+pkgname = wget

+ 50 - 0
PKGBUILD

@@ -0,0 +1,50 @@
+# Maintainer: Noah Vogt (noahvogt) noah@noahvogt.com
+# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
+# Maintainer: Eric Bélanger <eric@archlinux.org>
+
+pkgname=wget
+pkgver=1.21.2
+pkgrel=1
+pkgdesc='Network utility to retrieve files from the Web - but moving ~/.wget-hsts to $XDG_CACHE_HOME/wget/hsts'
+url='https://www.gnu.org/software/wget/wget.html'
+arch=('x86_64')
+license=('GPL3')
+depends=('glibc' 'zlib' 'gnutls' 'libidn2' 'libidn2.so' 'util-linux-libs' 'libuuid.so'
+         'libpsl' 'libpsl.so' 'pcre2' 'nettle' 'libnettle.so')
+optdepends=('ca-certificates: HTTPS downloads')
+backup=('etc/wgetrc')
+source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.lz
+        xdg-compliant-wget-hsts-file.patch)
+sha256sums=('1727a330a86acacb3e57615ce268f5f29978bf7adec4abe6a30d370207bc91b3'
+            'e7f03d1f253e4b66c38271f4a47ae8d849ac6241c60728b56be1a10b94611293')
+b2sums=(
+'9141b27f2db587bbd34cb97ecf4a6179e564817067b45c8168390cf1548c1a18f71723247d82b11f2edf3981a9b9f0d2097afe5d56397e033b0a86adae9482b1'
+'0da265b080a193805605bb8705e69e43a07aef062205ae9cf3558ac5e1199b67275f406337153018af4ec1631ef066cdd6eebbd5ba8029b3855e8c71c5953b2e')
+
+prepare() {
+  cd ${pkgname}-${pkgver}
+  patch -p1 -i ../xdg-compliant-wget-hsts-file.patch
+  cat >> doc/sample.wgetrc <<EOF
+# default root certs location
+ca_certificate=/etc/ssl/certs/ca-certificates.crt
+EOF
+}
+
+build() {
+  cd ${pkgname}-${pkgver}
+  ./configure \
+    --prefix=/usr \
+    --sysconfdir=/etc \
+    --disable-rpath \
+    --enable-nls \
+    --with-ssl=gnutls
+  make
+}
+
+
+package() {
+  cd ${pkgname}-${pkgver}
+  make DESTDIR="${pkgdir}" install
+}
+
+# vim: ts=2 sw=2 et:

+ 179 - 0
xdg-compliant-wget-hsts-file.patch

@@ -0,0 +1,179 @@
+From b27917936c64ac9036509b3a67516738e924c9ea Mon Sep 17 00:00:00 2001
+From: Noah Vogt <noah@noahvogt.com>
+Date: Wed, 17 Nov 2021 23:32:37 +0100
+Subject: [PATCH] xdg compliant wget hsts file
+
+---
+ src/hsts.c |  4 ++--
+ src/main.c | 29 ++++++++++++++++++++++++-----
+ src/path.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ src/path.h |  5 +++++
+ 4 files changed, 85 insertions(+), 7 deletions(-)
+ create mode 100644 src/path.c
+ create mode 100644 src/path.h
+
+diff --git a/src/hsts.c b/src/hsts.c
+index 9aa97b4..2562327 100644
+--- a/src/hsts.c
++++ b/src/hsts.c
+@@ -630,7 +630,7 @@ get_hsts_store_filename (void)
+ 
+   if (opt.homedir)
+     {
+-      filename = ajoin_dir_file (opt.homedir, ".wget-hsts-test");
++      filename = ajoin_dir_file (get_hsts_file_dir(), HSTS_TEST_FILE);
+       fp = fopen (filename, "w");
+       if (fp)
+         fclose (fp);
+@@ -796,7 +796,7 @@ test_hsts_read_database (void)
+ 
+   if (opt.homedir)
+     {
+-      file = ajoin_dir_file (opt.homedir, ".wget-hsts-testing");
++      file = ajoin_dir_file (get_hsts_file_dir(), HSTS_TESTING_FILE);
+       fp = fopen (file, "w");
+       if (fp)
+         {
+diff --git a/src/main.c b/src/main.c
+index 0f7b6b1..39082bc 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -31,6 +31,8 @@ as that of the covered work.  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <sys/types.h>
++#include <sys/stat.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <signal.h>
+@@ -63,6 +65,7 @@ as that of the covered work.  */
+ #include <getopt.h>
+ #include <getpass.h>
+ #include <quote.h>
++#include "path.c"
+ 
+ #ifdef TESTING
+ /* Rename the main function so we can have a main() in fuzzing code
+@@ -178,8 +181,21 @@ get_hsts_database (void)
+ 
+   if (opt.homedir)
+     {
+-      char *dir = ajoin_dir_file(opt.homedir, ".wget-hsts");
+-      return dir;
++      char* dir = get_hsts_file_dir();
++      char* path = ajoin_dir_file(get_hsts_file_dir(), HSTS_FILE);
++      struct stat st = {0};
++
++      /* make directory for hsts file if it does not exist */
++      if (stat(dir, &st) == -1)
++        {
++        int mkdir_sucess = mkdir(dir, 0700);
++        if (!(stat(dir, &st) == 0 && S_ISDIR(st.st_mode)))
++          {
++          printf("Error: Could not create hsts file\n");
++          exit (WGET_EXIT_GENERIC_ERROR);
++        }
++      }
++      return path;
+     }
+ 
+   return NULL;
+@@ -206,7 +222,8 @@ load_hsts (void)
+       else
+         logprintf (LOG_NOTQUIET, "ERROR: could not open HSTS store. HSTS will be disabled.\n");
+ 
+-      xfree (filename);
++      /* TODO: get free() call working again */
++      // xfree (filename);
+     }
+ }
+ 
+@@ -224,9 +241,11 @@ save_hsts (void)
+         }
+ 
+       hsts_store_close (hsts_store);
+-      xfree (hsts_store);
++      /* TODO: get free() call working again */
++      // xfree (hsts_store);
+ 
+-      xfree (filename);
++      /* TODO: get free() call working again */
++      // xfree (filename);
+     }
+ }
+ #endif
+diff --git a/src/path.c b/src/path.c
+new file mode 100644
+index 0000000..51cc3f0
+--- /dev/null
++++ b/src/path.c
+@@ -0,0 +1,54 @@
++#include "wget.h"
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <limits.h>
++#include <string.h>
++
++#include "path.h"
++#include "exits.h"
++
++char*
++get_hsts_file_dir (void)
++{
++  char *home_dir;
++  char *default_xdg_dir = "/" DEDAULT_XDG_CACHE_DIR;
++  char *hsts_file_base_dir = "/" HSTS_FILE_DIR;
++  char* user_xdg_dir;
++  static char hsts_file_dir[_POSIX_PATH_MAX] = "";
++  const char *slash = "/";
++  char *check_multiple;
++
++  if (!(home_dir = getenv("HOME")))
++  {
++    printf("Error: Could not access home directory\n");
++    exit (WGET_EXIT_GENERIC_ERROR);
++  }
++
++  /* prevent the function from runnning multiple times by returning right away
++   * when a a "/" character is found in the hsts_file_dir variable
++   */
++  check_multiple = hsts_file_dir;
++  while (*check_multiple)
++  {
++    if (strchr(slash, *check_multiple))
++    {
++      return hsts_file_dir;
++    }
++    check_multiple++;
++  }
++
++  if ((user_xdg_dir = getenv("XDG_CACHE_HOME")))
++  {
++    strcat(hsts_file_dir, user_xdg_dir);
++  } else
++    {
++  strcat(hsts_file_dir, home_dir);
++      strcat(hsts_file_dir, default_xdg_dir);
++    }
++
++  strcat(hsts_file_dir, hsts_file_base_dir);
++
++  return hsts_file_dir;
++}
+diff --git a/src/path.h b/src/path.h
+new file mode 100644
+index 0000000..c9b1f7b
+--- /dev/null
++++ b/src/path.h
+@@ -0,0 +1,5 @@
++#define HSTS_FILE_DIR "wget"
++#define HSTS_FILE "hsts"
++#define HSTS_TEST_FILE "hsts-test"
++#define HSTS_TESTING_FILE "hsts-testing"
++#define DEDAULT_XDG_CACHE_DIR ".cache"
+-- 
+2.34.0
+