aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2022-05-22 20:13:41 +0000
committerStefan Eßer <se@FreeBSD.org>2022-05-22 20:13:41 +0000
commit1f357cdb9252a62151de9903f52397374ad1d322 (patch)
tree4a63040ae100df4ce43ab64e37a7fab15bcb27fb /Tools
parent104ba18b124cb4deb39e62632e109d89a8fdb6c6 (diff)
downloadports-1f357cdb9252a62151de9903f52397374ad1d322.tar.gz
ports-1f357cdb9252a62151de9903f52397374ad1d322.zip
Tools/scripts: update port_conflicts_check.lua
Check that the package file database exists and that it is up-to-date.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/port_conflicts_check.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/Tools/scripts/port_conflicts_check.lua b/Tools/scripts/port_conflicts_check.lua
index ed81ad008298..c5265af19a5a 100755
--- a/Tools/scripts/port_conflicts_check.lua
+++ b/Tools/scripts/port_conflicts_check.lua
@@ -55,6 +55,7 @@ require "lfs"
-------------------------------------------------------------------
local file_pattern = "."
local database = "/var/db/pkg/provides/provides.db"
+local max_age = 1 * 24 * 3600 -- maximum age of database file in seconds
-------------------------------------------------------------------
local function table_sorted_keys(t)
@@ -154,6 +155,20 @@ end
-------------------------------------------------------------------
local function read_files(pattern)
local files_table = {}
+ local now = os.time()
+ local modification_time = lfs.attributes(database, "modification")
+ if not modification_time then
+ print("# Aborting: package file database " .. database .. " does not exist.")
+ print("# Install the 'pkg-provides' package and add it as a module to 'pkg.conf'.")
+ print("# Then fetch the database with 'pkg update' or 'pkg provides -u'.")
+ os.exit(1)
+ end
+ if now - modification_time > max_age then
+ print("# Aborting: package file database " .. database)
+ print("# is older than " .. max_age .. " seconds.")
+ print("# Use 'pkg provides -u' to update the database.")
+ os.exit(2)
+ end
local pipe = io.popen("locate -d " .. database .. " " .. pattern)
if pipe then
for line in pipe:lines() do