diff --git a/install-trapos.lua b/install-trapos.lua index 9b22607..c1b11d4 100644 --- a/install-trapos.lua +++ b/install-trapos.lua @@ -1,4 +1,4 @@ -local _VERSION = '6.0.0'; +local _VERSION = '6.0.1'; local REPO_BASE = 'https://git.trapcloud.fr/guillaumearm/cc-libs/raw/branch/master/'; local LOCAL_STATE_DIR = '/trapos'; @@ -224,11 +224,10 @@ end -- Full install: sync the registry and install the TrapOS meta-package. shell.execute('ccpm', 'update'); shell.execute('ccpm', 'install', 'trapos'); +shell.execute('trapos-postinstall'); if fs.exists('/startup/servers.lua') then shell.execute('/startup/servers.lua'); end -shell.execute('trapos-postinstall'); - shell.setDir(previousDir); diff --git a/tests/install-trapos.lua b/tests/install-trapos.lua index ff1fb69..7834bf4 100644 --- a/tests/install-trapos.lua +++ b/tests/install-trapos.lua @@ -119,6 +119,17 @@ local function findExecute(calls, program, firstArg) return false; end +local function findExecuteIndex(calls, program, firstArg) + for i, call in ipairs(calls.executes) do + if call.program == program then + if firstArg == nil or call.args[1] == firstArg then + return i; + end + end + end + return nil; +end + testlib.test('programs path resolves the ccpm command', function() local previous = shell.path(); shell.setPath('/rom/programs:/programs'); @@ -150,6 +161,18 @@ testlib.test('default install runs update, install trapos and postinstall', func testlib.assertTrue(findExecute(calls, 'trapos-postinstall')); end); +testlib.test('default install runs postinstall before startup servers', function() + local root = '/install-trapos-test/order'; + local calls = runInstall(root, {}); + local postinstallIndex = findExecuteIndex(calls, 'trapos-postinstall'); + local startupIndex = findExecuteIndex(calls, '/startup/servers.lua'); + + testlib.assertTrue(postinstallIndex ~= nil, 'postinstall was not run'); + if startupIndex ~= nil then + testlib.assertTrue(postinstallIndex < startupIndex, 'postinstall must run before startup servers'); + end +end); + testlib.test('--cpm-only stops after the ccpm bootstrap', function() local root = '/install-trapos-test/cpm-only'; local calls = runInstall(root, { '--cpm-only' });