diff options
author | Stefan Eßer <se@FreeBSD.org> | 2022-05-22 22:13:41 +0200 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2022-05-22 22:13:41 +0200 |
commit | 1f357cdb9252a62151de9903f52397374ad1d322 (patch) | |
tree | 4a63040ae100df4ce43ab64e37a7fab15bcb27fb | |
parent | math/dune-fem: Update 2.8.0rc1 -> 2.8.0.5 (diff) |
Tools/scripts: update port_conflicts_check.lua
Check that the package file database exists and that it is up-to-date.
-rwxr-xr-x | Tools/scripts/port_conflicts_check.lua | 15 |
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 |