[4/5] clamav-databases: New package

Message ID 20230214081540.125883-4-stefan.schantl@ipfire.org
State Accepted
Commit bb7ea011b988a510c381b19c4331cab82e934a62
Headers
Series [1/5] clamav: Change user/group to clamav |

Commit Message

Stefan Schantl Feb. 14, 2023, 8:15 a.m. UTC
  This package just provide a base set of
clamav virus databases to start.

The database may be outdated very soon but
automatically got updated by freshclam.

This package only needs to be touched in case
clamav got a new (incompatible) database file format.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 clamav-databases/clamav-databases.nm | 64 ++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 clamav-databases/clamav-databases.nm
  

Patch

diff --git a/clamav-databases/clamav-databases.nm b/clamav-databases/clamav-databases.nm
new file mode 100644
index 000000000..30a386c37
--- /dev/null
+++ b/clamav-databases/clamav-databases.nm
@@ -0,0 +1,64 @@ 
+###############################################################################
+# IPFire.org    - An Open Source Firewall Solution                            #
+# Copyright (C) - IPFire Development Team <info@ipfire.org>                   #
+###############################################################################
+
+name       = clamav-databases
+version    = 1
+release    = 1
+arch       = noarch
+
+groups     = System Environment/Daemons
+url        = https://www.clamav.net
+license    = GPLv2
+summary    = Clamav Virus Databases
+
+description
+	This package contains an initial set of databases used by Clamav.
+end
+
+# Using the clamav server is not permitted, so the files have to be
+# downloaded manually and uploaded to our source server.
+#source_dl  = https://database.clamav.net/
+sources = \
+	main.cvd \
+	daily.cvd
+
+build
+	prepare
+		%{create_users}
+	end
+
+	build = # Nothing to do
+
+	install
+		# Create directory.
+		mkdir -pv %{BUILDROOT}%{sharedstatedir}/clamav
+
+		# Install the databases.
+		cp -avf %{DIR_DL}/*.cvd %{BUILDROOT}%{sharedstatedir}/clamav/
+
+		# Own the database foler and files to this user/group.
+		chown -R clamav:clamav %{BUILDROOT}%{sharedstatedir}/clamav/
+	end
+end
+
+create_users
+	# Create user and group for clamav.
+	getent group clamav >/dev/null || groupadd -g 496 -r clamav || :
+	getent passwd clamav >/dev/null || useradd -u 496 -r -s /sbin/nologin \
+	-d / -M -g clamav clamav || :
+end
+
+packages
+	package %{name}
+		datafiles
+			%{sharedstatedir}/clamav/daily.cvd
+			%{sharedstatedir}/clamav/main.cvd
+		end
+
+		script prein
+			%{create_users}
+		end
+	end
+end