Skip to content

Commit

Permalink
[sb2] Add mapping for aligned workspace mount points. JB#49476
Browse files Browse the repository at this point in the history
Applies when sb2 is used under the SDK build engine.

Workspace directories used to be mounted at fixed paths under /home.
Now the mount point paths are chosen in a way that they align with the
source paths on host (e.g. "/home/user/work" -> "/home/user/work",
"C:\Users\user\work" -> "/c/Users/user/work").
  • Loading branch information
martyone committed Nov 16, 2020
1 parent 395a762 commit c5b22ca
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scratchbox2/modes/obs-rpm-build+pp/config.lua
Expand Up @@ -23,6 +23,9 @@ exec_policy_selection = {
-- the home directory is expected to contain target binaries:
{dir = sbox_user_home_dir, exec_policy_name = "Target"},

-- the workspace directory is expected to contain target binaries:
{dir = sbox_user_workspace, exec_policy_name = "Target"},

{prefix = tools, exec_policy_name = "Tools"},

-- DEFAULT RULE (must exist):
Expand Down
6 changes: 6 additions & 0 deletions scratchbox2/modes/obs-rpm-build+pp/fs_rules.lua
Expand Up @@ -803,6 +803,12 @@ import_from_fs_rule_library("user_rules")
-- path convention
use_outside_path("/parentroot")

-- Define sbox_user_workspace as being outside like /home, this is a Mer SDK
-- path convention. Take care to not override /home rules accidentally as those may overlap
if sbox_user_workspace ~= "/home" then
use_outside_path(sbox_user_workspace)
end

-- Now run ~/.sbrules
run_user_sbrules()

Expand Down
3 changes: 3 additions & 0 deletions scratchbox2/modes/obs-rpm-build/config.lua
Expand Up @@ -22,6 +22,9 @@ exec_policy_selection = {
-- the home directory is expected to contain target binaries:
{dir = sbox_user_home_dir, exec_policy_name = "Target"},

-- the workspace directory is expected to contain target binaries:
{dir = sbox_user_workspace, exec_policy_name = "Target"},

-- DEFAULT RULE (must exist):
{prefix = "/", exec_policy_name = "Host"}
}
6 changes: 6 additions & 0 deletions scratchbox2/modes/obs-rpm-build/fs_rules.lua
Expand Up @@ -659,6 +659,12 @@ import_from_fs_rule_library("user_rules")
-- path convention
use_outside_path("/parentroot")

-- Define sbox_user_workspace as being outside like /home, this is a Mer SDK
-- path convention. Take care to not override /home rules accidentally as those may overlap
if sbox_user_workspace ~= "/home" then
use_outside_path(sbox_user_workspace)
end

-- Now run ~/.sbrules
run_user_sbrules()

Expand Down
3 changes: 3 additions & 0 deletions scratchbox2/modes/obs-rpm-install/config.lua
Expand Up @@ -22,6 +22,9 @@ exec_policy_selection = {
-- the home directory is expected to contain target binaries:
{dir = sbox_user_home_dir, exec_policy_name = "Target"},

-- the workspace directory is expected to contain target binaries:
{dir = sbox_user_workspace, exec_policy_name = "Target"},

-- DEFAULT RULE (must exist):
{prefix = "/", exec_policy_name = "Host"}
}
6 changes: 6 additions & 0 deletions scratchbox2/modes/obs-rpm-install/fs_rules.lua
Expand Up @@ -487,6 +487,12 @@ import_from_fs_rule_library("user_rules")
-- path convention
use_outside_path("/parentroot")

-- Define sbox_user_workspace as being outside like /home, this is a Mer SDK
-- path convention. Take care to not override /home rules accidentally as those may overlap
if sbox_user_workspace ~= "/home" then
use_outside_path(sbox_user_workspace)
end

-- Now run ~/.sbrules
run_user_sbrules()

Expand Down
8 changes: 8 additions & 0 deletions scratchbox2/rule_lib/fs_rules/user_rules.lua
Expand Up @@ -3,6 +3,14 @@
fs_rule_lib_interface_version = "105"
----------------------------------

-- Workspace root from sbox' point of view is not the mount point but already
-- the immediate subdirectory of the root directory, which is always one of
-- "/home", "/Home", "/Users", "/[a-z]" or "/_*" (that's how the mount point
-- is derived from the workspace path on host), none of which is to be mapped.
-- Use home dir as a fallback for easier use.
sbox_user_workspace = string.match(os.getenv("SAILFISH_SDK_SRC1_MOUNT_POINT") or sbox_user_home_dir,
"^/[^/]+")

-- http://stackoverflow.com/a/4991602/337649
function user_file_readable(name)
local f=io.open(name,"r")
Expand Down

0 comments on commit c5b22ca

Please sign in to comment.