Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Nov 2021 16:38:56 GMT
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: bfb64865610a - main - misc/shared-mime-info: fix cleanup
Message-ID:  <202111041638.1A4Gcu9H044034@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=bfb64865610ab98c0bfdb30a7cef4e8f3f8d3b84

commit bfb64865610ab98c0bfdb30a7cef4e8f3f8d3b84
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2021-11-04 09:38:08 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2021-11-04 16:38:33 +0000

    misc/shared-mime-info: fix cleanup
    
    update-mime-database generates tons of xml files during the trigger
    execution, cleanup should remove them
    
    Reported by:    many
---
 misc/shared-mime-info/Makefile                      |  2 +-
 misc/shared-mime-info/files/shared-mime-info.ucl.in | 21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/misc/shared-mime-info/Makefile b/misc/shared-mime-info/Makefile
index bc81d9447691..a76c9a38c9a2 100644
--- a/misc/shared-mime-info/Makefile
+++ b/misc/shared-mime-info/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	shared-mime-info
 DISTVERSION=	2.0
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	misc gnome
 
 MAINTAINER=	desktop@FreeBSD.org
diff --git a/misc/shared-mime-info/files/shared-mime-info.ucl.in b/misc/shared-mime-info/files/shared-mime-info.ucl.in
index 38d1d2cfec04..2049db0caa5e 100644
--- a/misc/shared-mime-info/files/shared-mime-info.ucl.in
+++ b/misc/shared-mime-info/files/shared-mime-info.ucl.in
@@ -4,7 +4,7 @@ cleanup: {
 	script: <<EOS
 local mimedir = "%%PREFIX%%/share/mime/"
 local files = { "XMLnamespaces", "aliases", "generic-icons", "globs", "globs2", "icons", "mime.cache", "subclasses", "treemagic", "types", "version"}
-for _,filename in pairs(files) do
+for _,filename in ipairs(files) do
 	local fpath = mimedir .. filename
 	local st = pkg.stat(fpath)
 	if st then
@@ -12,9 +12,24 @@ for _,filename in pairs(files) do
 	end
 end
 local res = pkg.readdir(mimedir)
-if #res == 0 then
-	os.remove(mimedir)
+if res == nil then goto cleanmime end
+
+for _,dir in ipairs(res) do
+	if  dir == "packages" then goto continue end
+
+	local directory = mimedir .. "/" .. dir
+	local r = pkg.readdir(directory)
+	if r == nil then goto cleandir end
+	for _,file in ipairs(r) do
+		os.remove(directory .. "/" .. file)
+	end
+	::cleandir::
+	os.remove(directory)
+
+	::continue::
 end
+::cleanmime::
+os.remove(mimedir)
 EOS
 }
 trigger: {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111041638.1A4Gcu9H044034>