From 6416fbc2d6fb5dbfa4a84982737312eea1ce2bef Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 23 Jan 2017 16:59:02 +0100
Subject: [PATCH] main/samba: upgrade to 4.5.4

---
 main/samba/APKBUILD        |  12 ++--
 main/samba/gen-bin-list.sh |  12 ++++
 main/samba/split-pkg.lua   | 123 +++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+), 6 deletions(-)
 create mode 100644 main/samba/gen-bin-list.sh
 create mode 100644 main/samba/split-pkg.lua

diff --git a/main/samba/APKBUILD b/main/samba/APKBUILD
index 938bdac44c39..a488c30f1426 100644
--- a/main/samba/APKBUILD
+++ b/main/samba/APKBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=samba
-pkgver=4.5.3
-pkgrel=1
+pkgver=4.5.4
+pkgrel=0
 pkgdesc="Tools to access a server's filespace and printers via SMB"
 url="http://www.samba.org"
 arch="all"
@@ -43,7 +43,7 @@ makedepends="popt-dev ncurses-dev openldap-dev e2fsprogs-dev
 	talloc-dev tdb-dev py-tdb ldb-dev cups-dev python2-dev libcap-dev
 	tevent-dev py-tevent iniparser-dev perl subunit-dev docbook-xsl
 	libarchive-dev"
-source="http://us1.samba.org/samba/ftp/stable/samba-$pkgver.tar.gz
+source="https://us1.samba.org/samba/ftp/stable/samba-$pkgver.tar.gz
 	uclibc-xattr-create.patch
 	domain.patch
 	getpwent_r.patch
@@ -506,7 +506,7 @@ libs() {
 		|| return 1
 }
 
-md5sums="6f30eed6dfbd036dfde023e03ed8b311  samba-4.5.3.tar.gz
+md5sums="20f4af15f409efd6ddca5544e1d7d84a  samba-4.5.4.tar.gz
 f9ee1f13e59c60ee7e481f51329bf7d4  uclibc-xattr-create.patch
 f0d10a87a2067d0d3accdcb6c9b64ea9  domain.patch
 6a220b2471764e6e189829ac9cc81996  getpwent_r.patch
@@ -514,7 +514,7 @@ f0d10a87a2067d0d3accdcb6c9b64ea9  domain.patch
 c1702b2ad7b68f7d704f50a1bfef3ad3  samba.initd
 c150433426e18261e6e3eed3930e1a76  samba.confd
 b7cafabfb4fa5b3ab5f2e857d8d1c733  samba.logrotate"
-sha256sums="f06dc454a1bb72b21a329e1ad75a14795886401671ec7439d69a6b824c492eca  samba-4.5.3.tar.gz
+sha256sums="1800d10ea14cabef67c83cc56a0f37f4f30ba5df218b3a1e7c874069a08c0f40  samba-4.5.4.tar.gz
 dcf6a7118297d6567d8ff31c9eff1afffdf2f548db36fd17d00cdf0ffc555fe3  uclibc-xattr-create.patch
 5554fff0df5d31e67a705c60d97e187b4109c79c8a4063c8ea7ebe1e0e4a7e7e  domain.patch
 7956274b412a268339abb63f8e1bd63b5049cd4ab7c6270235d9d0b9bcf6c81a  getpwent_r.patch
@@ -522,7 +522,7 @@ d4a17891a14d9a4290750097cc28279059e6d971fadf132085e857ed4400d5ed  netdb-defines.
 3866a15ab73a9fd704ec8315cff48caf98937c490ba8dc40ce3701cef5ca22c9  samba.initd
 1d12f98a7727967b04eb123109b34cfffef320822dc0e8059286b6e3394c3fc0  samba.confd
 4c2b7d529126b2fc4f62fb09d99e49a87632d723a2d9d289a61e37dd84145be1  samba.logrotate"
-sha512sums="3ba4002131a5d7db35a62bc5841ed7aa7c43d85f7f3509237aa97bd1ff8bac6358eb3acec178ddfa6e8fa9c390dadb947fa90eec27d1299e2a9ccdecc5e9bc16  samba-4.5.3.tar.gz
+sha512sums="7b24227e17ab091e6165c605f28af19fa846de63f3f24508411db2b509d942e599702dd278c8430481d7a404c5a97005148286ea4e94a35b57a1ec303b1a4409  samba-4.5.4.tar.gz
 b43809d7ecbf3968f5154c2ded6ed47dae36921f1895ea98bcce50557eb2ad39b736345ffb4214655ed3154c143c20431d248cde828285380bafbf4d2627df9b  uclibc-xattr-create.patch
 62d373dbaee75121a1d73f2c09cdca7239705808ff807b171d1d5a28fd4ffc66bdb52494b62786d7aaba8aeece5c08433b532ca96a28d712452fe9daac8d8d2e  domain.patch
 0d4fd9862191554dc9c724cec0b94fd19afbfd0c4ed619e4c620c075e849cb3f3d44db1e5f119d890da23a3dd0068d9873703f3d86c47b91310521f37356208b  getpwent_r.patch
diff --git a/main/samba/gen-bin-list.sh b/main/samba/gen-bin-list.sh
new file mode 100644
index 000000000000..b5c64081829d
--- /dev/null
+++ b/main/samba/gen-bin-list.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# generate file lists for each subpackage that has /usr/bin or /usr/sbin
+
+for i in pkg/*/usr/bin/*  pkg/*/usr/sbin/*  pkg/*/usr/lib/samba/*/*.so; do
+	[ -f "$i" ] || continue
+	n=${i#pkg/}
+	n=${n%%/*}
+
+	f=${i#pkg/*/}
+	echo "$n $f"
+done
diff --git a/main/samba/split-pkg.lua b/main/samba/split-pkg.lua
new file mode 100644
index 000000000000..e2de7b84e3ec
--- /dev/null
+++ b/main/samba/split-pkg.lua
@@ -0,0 +1,123 @@
+
+rev = {}
+--[[ read from subpkgname.list file ]]--
+--[[
+for i = 1,#arg do
+	pname = arg[i]
+	local f = io.popen(([[
+		xargs lddtree -l < %s | sort -u | while read f; do
+			if [ -e pkg/*"$f" ]; then
+				echo $f
+			fi
+		done
+	] ]):format(pname))
+
+	for filename in f:lines() do
+		if rev[filename] == nil then
+			rev[filename] = {}
+		end
+		table.insert(rev[filename], (pname:gsub(".list", "")))
+	end
+	f:close()
+end
+--]]
+
+
+function shell_escape(args)
+	local ret = {}
+	for _,a in pairs(args) do
+		s = tostring(a)
+		if s:match("[^A-Za-z0-9_/:=-]") then
+			s = "'"..s:gsub("'", "'\\''").."'"
+		end
+		table.insert(ret,s)
+	end
+	return table.concat(ret, " ")
+end
+
+-- read lines from stdin with: <subpackage> <filename>
+pkgs = {}
+revhash = {}
+for line in io.lines() do
+	local p, filename = line:match("(.*) (.*)")
+	if pkgs[p] == nil then
+		pkgs[p] = {bins={}, hasfile={}, needsfile={}}
+	end
+	table.insert(pkgs[p].bins, filename)
+	pkgs[p].hasfile[filename] = true
+end
+
+for pkg, r in pairs(pkgs) do
+	print("### ".. pkg)
+	for _,binfile in pairs(r.bins) do
+		local f = io.popen(([[
+			lddtree -l %s | sort -u | while read f; do
+				if [ -e pkg/*"$f" ]; then
+					echo $f
+				fi
+			done
+		]]):format(("pkg/"..pkg.."/"..binfile)))
+
+		for filename in f:lines() do
+			if rev[filename] == nil then
+				rev[filename] = {}
+				revhash[filename] = {}
+			end
+			if not revhash[filename][pkg] then
+				revhash[filename][pkg]=true
+				table.insert(rev[filename], pkg)
+			end
+			r.needsfile[filename]=true
+		end
+	end
+end
+
+-- sort list
+keylist = {}
+for k,v in pairs(rev) do
+	table.insert(keylist, k)
+	print(":::: "..k)
+	table.sort(v)
+end
+
+combos = {}
+for _,filename in pairs(keylist) do
+	plist = rev[filename]
+	s = ""
+	for i = 1, #plist do
+		if plist[i] ~= "samba-test" then
+			s=s..plist[i]..":"
+		end
+	end
+	if combos[s] == nil then
+		combos[s] = {}
+	end
+	table.insert(combos[s], filename)
+--	print(#rev[filename], s, filename)
+end
+
+
+combokeys = {}
+for pn, filelist in pairs(combos) do
+	table.insert(combokeys, pn)
+	table.sort(filelist)
+end
+
+table.sort(combokeys, function(a,b)
+	local _, counta = a:gsub(":", "")
+	local _, countb = b:gsub(":", "")
+	if counta == countb then
+		return a < b
+	end
+	return counta < countb
+end)
+
+for i = 1,#combokeys do
+	pn = combokeys[i]
+	filelist = combos[pn]
+
+	print(pn)
+	for j = 1,#filelist do
+		print("", filelist[j])
+	end
+end
-- 
GitLab