From dec7628ea9e8d99bb8ea0cecfb5b9732b43bcfc5 Mon Sep 17 00:00:00 2001
From: Eneas U de Queiroz <cote2004-github@yahoo.com>
Date: Thu, 7 Jun 2018 18:16:02 -0300
Subject: [PATCH] squid: Upgrade to 4.0.24 beta

This beta version brings compatibility with openssl 1.1

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
---
 net/squid/Makefile                        | 19 ++++++++++---------
 net/squid/files/squid.init                |  4 ++--
 net/squid/patches/001-cross_compile.patch | 15 +++------------
 3 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/net/squid/Makefile b/net/squid/Makefile
index b9cedd7eae..6e5c0027d1 100644
--- a/net/squid/Makefile
+++ b/net/squid/Makefile
@@ -8,17 +8,17 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=squid
-PKG_VERSION:=3.5.27
+PKG_VERSION:=4.0.24
 PKG_RELEASE:=1
 
 PKG_LICENSE:=GPL-2.0
 PKG_MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr>
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
-PKG_SOURCE_URL:=http://www3.us.squid-cache.org/Versions/v3/3.5/ \
-	http://www2.pl.squid-cache.org/Versions/v3/3.5/ \
-	http://www.squid-cache.org/Versions/v3/3.5/
-PKG_HASH:=5ddb4367f2dc635921f9ca7a59d8b87edb0412fa203d1543393ac3c7f9fef0ec
+PKG_SOURCE_URL:=http://www3.us.squid-cache.org/Versions/v4/ \
+	http://www2.pl.squid-cache.org/Versions/v4/ \
+	http://www.squid-cache.org/Versions/v4/
+PKG_HASH:=091da0d763307dcc0f5c784ab07ea0c5a093f6dfac60f17ff26e2a6d50f76a07
 
 PKG_BUILD_PARALLEL:=1
 PKG_INSTALL:=1
@@ -35,7 +35,7 @@ endef
 
 define Package/squid
   $(call Package/squid/Default)
-  DEPENDS:=+libopenssl +libpthread +librt +libltdl +libstdcpp
+  DEPENDS:=+libopenssl +libpthread +librt +libltdl +libstdcpp +libatomic +USE_GLIBC:libbsd
   TITLE:=full-featured Web proxy cache
 endef
 
@@ -93,8 +93,9 @@ CONFIGURE_ARGS += \
 
 CONFIGURE_VARS += \
 	ac_cv_header_linux_netfilter_ipv4_h=yes \
-	ac_cv_epoll_works=yes \
-	squid_cv_gnu_atomics=no
+	ac_cv_epoll_works=yes
+
+EXTRA_CFLAGS += -Wno-error
 
 define Build/Compile
 	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/lib all
@@ -108,7 +109,7 @@ define Package/squid/install
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/squid $(1)/usr/sbin/
 
 	$(INSTALL_DIR) $(1)/usr/lib/squid
-	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/squid/ssl_crtd $(1)/usr/lib/squid
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/squid/security_file_certgen $(1)/usr/lib/squid/
 
 	$(INSTALL_DIR) $(1)/etc/config
 	$(INSTALL_CONF) ./files/squid.config $(1)/etc/config/squid
diff --git a/net/squid/files/squid.init b/net/squid/files/squid.init
index 711347ba58..7c5552f316 100644
--- a/net/squid/files/squid.init
+++ b/net/squid/files/squid.init
@@ -33,7 +33,7 @@ start_service() {
 	config_dir=$(dirname $CONFIGFILE)
 	[ -d $config_dir ] || mkdir -p $config_dir && chown nobody:nogroup $config_dir
 	[ -d $coredump_dir ] || mkdir -p $coredump_dir && chown nobody:nogroup $coredump_dir
-	[ "$ssldb" ] && ( [ -f "$ssldb"/size ] || /usr/lib/squid/ssl_crtd -c -s $ssldb && chown -R nobody:nogroup $ssldb )
+	[ "$ssldb" ] && ( [ -f "$ssldb"/size ] || /usr/lib/squid/security_file_certgen -c -s $ssldb $ssldb_options && chown -R nobody:nogroup $ssldb )
 
 	cat $config_file > $CONFIGFILE
 	echo http_port $http_port $http_port_options >> $CONFIGFILE
@@ -42,7 +42,7 @@ start_service() {
 	echo pinger_enable $pinger_enable >> $CONFIGFILE
 	cat $mime_table > $MIMETABLE
 	echo mime_table $MIMETABLE >> $CONFIGFILE
-	[ "$ssldb" ] && echo sslcrtd_program /usr/lib/squid/ssl_crtd -s $ssldb $ssldb_options >> $CONFIGFILE
+	[ "$ssldb" ] && echo sslcrtd_program /usr/lib/squid/security_file_certgen -s $ssldb $ssldb_options >> $CONFIGFILE
 	$PROG -s -f $CONFIGFILE -N -z 2>/dev/null
 
 	procd_open_instance
diff --git a/net/squid/patches/001-cross_compile.patch b/net/squid/patches/001-cross_compile.patch
index be9fdcd25d..849fce82ee 100644
--- a/net/squid/patches/001-cross_compile.patch
+++ b/net/squid/patches/001-cross_compile.patch
@@ -1,6 +1,6 @@
 --- a/src/Makefile.in
 +++ b/src/Makefile.in
-@@ -7984,7 +7984,7 @@ cache_cf.o: cf_parser.cci
+@@ -7642,7 +7642,7 @@ cache_cf.o: cf_parser.cci
  
  # cf_gen builds the configuration files.
  cf_gen$(EXEEXT): $(cf_gen_SOURCES) $(cf_gen_DEPENDENCIES) cf_gen_defines.cci
@@ -11,16 +11,7 @@
  squid.conf.default squid.conf.documented: cf_parser.cci
 --- a/configure
 +++ b/configure
-@@ -20842,7 +20842,7 @@ else
- if test "$cross_compiling" = yes; then :
-   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
- $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
--as_fn_error $? "cannot run test program while cross compiling
-+_as_fn_error $? "cannot run test program while cross compiling
- See \`config.log' for more details" "$LINENO" 5; }
- else
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -29142,7 +29142,7 @@ else
+@@ -30695,7 +30695,7 @@ else
      if test "$cross_compiling" = yes; then :
    { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
  $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -29,7 +20,7 @@
  See \`config.log' for more details" "$LINENO" 5; }
  else
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-@@ -29167,7 +29167,7 @@ else
+@@ -30720,7 +30720,7 @@ else
      if test "$cross_compiling" = yes; then :
    { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
  $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-- 
2.30.2