See https://git.io/vuDJY
Showing the changes to tools/build-pkg.lua (1 of 1 file). Show all
Unified · Split
| @@ -241,6 +241,18 @@ local function getItems() · 240 unmodified lines | ||
| 241 | 241 | return items, item2deps, item2ver |
| 242 | 242 | end |
| 243 | 243 | |
| 244 | +local function getInstalled() | |
| 245 | + local installed = {} | |
| 246 | + local f = io.popen('ls usr/*/installed/*') | |
| 247 | + local pattern = '/([^/]+)/installed/([^/]+)' | |
| 248 | + for file in f:lines() do | |
| 249 | + local target, pkg = assert(file:match(pattern)) | |
| 250 | + table.insert(installed, makeItem(target, pkg)) | |
| 251 | + end | |
| 252 | + f:close() | |
| 253 | + return installed | |
| 254 | +end | |
| 255 | + | |
| 244 | 256 | -- graph is a map from item to a list of destinations |
| 245 | 257 | local function transpose(graph) |
| 246 | 258 | local transposed = {} |
| @@ -373,7 +385,7 @@ local function gitCommit(message) · 126 unmodified lines | ||
| 373 | 385 | assert(execute(cmd:format(message))) |
| 374 | 386 | end |
| 375 | 387 | |
| 376 | −local function gitCheckout(new_branch, deps) | |
| 388 | +local function gitCheckout(new_branch, deps, item2index) | |
| 377 | 389 | local main_dep = deps[1] |
| 378 | 390 | if main_dep then |
| 379 | 391 | main_dep = itemToBranch(main_dep) |
| @@ -401,7 +413,17 @@ local function gitCheckout(new_branch, deps) · 21 unmodified lines | ||
| 401 | 413 | end |
| 402 | 414 | if #deps > 0 then |
| 403 | 415 | -- prevent accidental rebuilds |
| 404 | − assert(execute('touch usr/*/installed/*')) | |
| 416 | + -- touch usr/*/installed/* files in build order | |
| 417 | + -- see https://git.io/vuDJY | |
| 418 | + local installed = getInstalled() | |
| 419 | + table.sort(installed, function(x, y) | |
| 420 | + return item2index[x] < item2index[y] | |
| 421 | + end) | |
| 422 | + for _, item in ipairs(installed) do | |
| 423 | + local target, pkg = assert(parseItem(item)) | |
| 424 | + local cmd4 = 'touch -c usr/%s/installed/%s' | |
| 425 | + execute(cmd4:format(target, pkg)) | |
| 426 | + end | |
| 405 | 427 | end |
| 406 | 428 | end |
| 407 | 429 | |
| @@ -510,8 +532,8 @@ local function checkFileList(files, item) · 102 unmodified lines | ||
| 510 | 532 | end |
| 511 | 533 | |
| 512 | 534 | -- builds package, returns list of new files |
| 513 | −local function buildItem(item, item2deps, file2item) | |
| 514 | − gitCheckout(itemToBranch(item), item2deps[item]) | |
| 535 | +local function buildItem(item, item2deps, file2item, item2index) | |
| 536 | + gitCheckout(itemToBranch(item), item2deps[item], item2index) | |
| 515 | 537 | local target, pkg = parseItem(item) |
| 516 | 538 | local cmd = '%s %s MXE_TARGETS=%s --jobs=1' |
| 517 | 539 | os.execute(cmd:format(tool 'make', pkg, target)) |
| @@ -747,10 +769,12 @@ local function buildPackages(items, item2deps) · 229 unmodified lines | ||
| 747 | 769 | end |
| 748 | 770 | return false |
| 749 | 771 | end |
| 772 | + local item2index = makeItem2Index(items) | |
| 750 | 773 | local progress_printer = progressPrinter(items) |
| 751 | 774 | for i, item in ipairs(items) do |
| 752 | 775 | if not brokenDep(item) then |
| 753 | − local files = buildItem(item, item2deps, file2item) | |
| 776 | + local files = buildItem(item, item2deps, | |
| 777 | + file2item, item2index) | |
| 754 | 778 | findForeignInstalls(item, files) |
| 755 | 779 | if isBuilt(item, files) then |
| 756 | 780 | item2files[item] = files |
| @@ -896,7 +920,7 @@ local build_list = sortForBuild(items, item2deps) · 139 unmodified lines | ||
| 896 | 920 | assert(isTopoOrdered(build_list, items, item2deps)) |
| 897 | 921 | build_list = sliceArray(build_list, max_items) |
| 898 | 922 | local unbroken, item2files = buildPackages(build_list, item2deps) |
| 899 | −gitCheckout(GIT_ALL, unbroken) | |
| 923 | +gitCheckout(GIT_ALL, unbroken, makeItem2Index(build_list)) | |
| 900 | 924 | makeDebs(unbroken, item2deps, item2ver, item2files) |
| 901 | 925 | if not no_debs then |
| 902 | 926 | makeMxeRequirementsPackage('wheezy') |