Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/pkgbase-stage.lua
| Show All 12 Lines | |||||
| local function capture(command) | local function capture(command) | ||||
| local p = io.popen(command) | local p = io.popen(command) | ||||
| local output = p:read("*a") | local output = p:read("*a") | ||||
| assert(p:close()) | assert(p:close()) | ||||
| -- Strip exactly one trailing newline from the output, if there is one | -- Strip exactly one trailing newline from the output, if there is one | ||||
| return output:match("(.-)\n$") or output | return output:match("(.-)\n$") or output | ||||
| end | end | ||||
| local function append_list(list, other) | |||||
| for _, item in ipairs(other) do | |||||
| table.insert(list, item) | |||||
| end | |||||
| end | |||||
| -- Returns a list of packages to be included in the given media | -- Returns a list of packages to be included in the given media | ||||
| local function select_packages(pkg, media, all_libcompats) | local function select_packages(pkg, media, all_libcompats) | ||||
| local components = { | local components = {} | ||||
| kernel = {}, | |||||
| kernel_dbg = {}, | |||||
| base = {}, | |||||
| base_dbg = {}, | |||||
| src = {}, | |||||
| tests = {}, | |||||
| } | |||||
| for compat in all_libcompats:gmatch("%S+") do | |||||
| components["lib" .. compat] = {} | |||||
| components["lib" .. compat .. "_dbg"] = {} | |||||
| end | |||||
| local rquery = capture(pkg .. "rquery -U -r FreeBSD-base %n") | local rquery = capture(pkg .. "rquery -U -r FreeBSD-base %n") | ||||
| for package in rquery:gmatch("[^\n]+") do | for package in rquery:gmatch("[^\n]+") do | ||||
| if package == "FreeBSD-src" or package:match("^FreeBSD%-src%-.*") then | local set = package:match("^FreeBSD%-set%-(.*)$") | ||||
| table.insert(components["src"], package) | if set then | ||||
| elseif package == "FreeBSD-tests" or package:match("^FreeBSD%-tests%-.*") then | components[set] = package | ||||
| table.insert(components["tests"], package) | |||||
| elseif package:match("^FreeBSD%-kernel%-.*") and | |||||
| package ~= "FreeBSD-kernel-man" | |||||
| then | |||||
| -- Kernels other than FreeBSD-kernel-generic are ignored | -- Kernels other than FreeBSD-kernel-generic are ignored | ||||
| -- Note that on powerpc64 and powerpc64le the names are | -- Note that on powerpc64 and powerpc64le the names are | ||||
| -- slightly different. | -- slightly different. | ||||
| if package:match("^FreeBSD%-kernel%-generic.*%-dbg") then | elseif package:match("^FreeBSD%-kernel%-generic.*-dbg") then | ||||
| table.insert(components["kernel_dbg"], package) | components["kernel-dbg"] = package | ||||
| elseif package:match("^FreeBSD%-kernel%-generic.*") then | elseif package:match("^FreeBSD%-kernel%-generic.*") then | ||||
| table.insert(components["kernel"], package) | components["kernel"] = package | ||||
| end | end | ||||
| elseif package:match(".*%-dbg$") then | |||||
| table.insert(components["base_dbg"], package) | |||||
| else | |||||
| local found = false | |||||
| for compat in all_libcompats:gmatch("%S+") do | |||||
| if package:match(".*%-dbg%-lib" .. compat .. "$") then | |||||
| table.insert(components["lib" .. compat .. "_dbg"], package) | |||||
| found = true | |||||
| break | |||||
| elseif package:match(".*%-lib" .. compat .. "$") then | |||||
| table.insert(components["lib" .. compat], package) | |||||
| found = true | |||||
| break | |||||
| end | end | ||||
| end | assert(components["kernel"]) | ||||
| if not found then | assert(components["base"]) | ||||
| table.insert(components["base"], package) | |||||
| end | |||||
| end | |||||
| end | |||||
| assert(#components["kernel"] == 1) | |||||
| assert(#components["base"] > 0) | |||||
| local selected = {} | local selected = {} | ||||
| if media == "disc" then | if media == "disc" then | ||||
| append_list(selected, components["base"]) | table.insert(selected, components["base"]) | ||||
| append_list(selected, components["kernel"]) | table.insert(selected, components["kernel"]) | ||||
| append_list(selected, components["kernel_dbg"]) | table.insert(selected, components["kernel-dbg"]) | ||||
| append_list(selected, components["src"]) | table.insert(selected, components["src"]) | ||||
| append_list(selected, components["tests"]) | table.insert(selected, components["tests"]) | ||||
| for compat in all_libcompats:gmatch("%S+") do | for compat in all_libcompats:gmatch("%S+") do | ||||
| append_list(selected, components["lib" .. compat]) | table.insert(selected, components["lib" .. compat]) | ||||
| end | end | ||||
| else | else | ||||
| assert(media == "dvd") | assert(media == "dvd") | ||||
| append_list(selected, components["base"]) | table.insert(selected, components["base"]) | ||||
| append_list(selected, components["base_dbg"]) | table.insert(selected, components["base-dbg"]) | ||||
| append_list(selected, components["kernel"]) | table.insert(selected, components["kernel"]) | ||||
| append_list(selected, components["kernel_dbg"]) | table.insert(selected, components["kernel-dbg"]) | ||||
| append_list(selected, components["src"]) | table.insert(selected, components["src"]) | ||||
| append_list(selected, components["tests"]) | table.insert(selected, components["tests"]) | ||||
| for compat in all_libcompats:gmatch("%S+") do | for compat in all_libcompats:gmatch("%S+") do | ||||
| append_list(selected, components["lib" .. compat]) | table.insert(selected, components["lib" .. compat]) | ||||
| append_list(selected, components["lib" .. compat .. "_dbg"]) | table.insert(selected, components["lib" .. compat .. "-dbg"]) | ||||
| end | end | ||||
| end | end | ||||
| return selected | return selected | ||||
| end | end | ||||
| local function main() | local function main() | ||||
| -- Determines package subset selected | -- Determines package subset selected | ||||
| Show All 21 Lines | local function main() | ||||
| local pkg = "pkg -o ASSUME_ALWAYS_YES=yes -o IGNORE_OSVERSION=yes " .. | local pkg = "pkg -o ASSUME_ALWAYS_YES=yes -o IGNORE_OSVERSION=yes " .. | ||||
| "-o ABI=" .. ABI .. " " .. | "-o ABI=" .. ABI .. " " .. | ||||
| "-o INSTALL_AS_USER=1 -o PKG_DBDIR=./pkgdb -R ./pkgbase-repo-conf " | "-o INSTALL_AS_USER=1 -o PKG_DBDIR=./pkgdb -R ./pkgbase-repo-conf " | ||||
| assert(os.execute(pkg .. "update")) | assert(os.execute(pkg .. "update")) | ||||
| local packages = select_packages(pkg, media, all_libcompats) | local packages = select_packages(pkg, media, all_libcompats) | ||||
| assert(os.execute(pkg .. "fetch -o " .. target .. " " .. table.concat(packages, " "))) | assert(os.execute(pkg .. "fetch -d -o " .. target .. " " .. table.concat(packages, " "))) | ||||
| assert(os.execute(pkg .. "repo " .. target)) | assert(os.execute(pkg .. "repo " .. target)) | ||||
| end | end | ||||
| main() | main() | ||||