Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
lpmx list
lpmx create
lpmx fastrun commands to add executable mapping support
  • Loading branch information
JasonYangShadow committed May 29, 2021
1 parent 7aa838c commit 5257958
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
debian/
.idea/
139 changes: 130 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/linux/x86_64/Linux-x86_64-lpmx
100644 → 100755
Binary file not shown.
33 changes: 21 additions & 12 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Container struct {
DataSyncFolder string //sync folder with host
DataSyncMap string //sync folder mapping info(host:contain)
Engine string //engine type used on the host
Execmaps string //executables mapping info
}

type RPC struct {
Expand Down Expand Up @@ -656,6 +657,12 @@ func Run(configmap *map[string]interface{}, args ...string) *Error {
}
con.ContainerName = (*configmap)["container_name"].(string)

//save execmaps
if _, eok := (*configmap)["execmaps"]; eok {
con.Execmaps = (*configmap)["execmaps"].(string)
envmap["execmaps"] = (*configmap)["execmaps"].(string)
}

//enable batch engine if needed
if _, eok := (*configmap)["enable_engine"]; eok {
envmap["engine"] = "TRUE"
Expand Down Expand Up @@ -696,6 +703,15 @@ func Run(configmap *map[string]interface{}, args ...string) *Error {
}
}

//here we need to inject executable mapping info
if len(con.Execmaps) > 0 {
for _, item := range strings.Split(con.Execmaps, ":") {
k := strings.Split(item, "=")[0]
v := strings.Split(item, "=")[1]
setExec(con.Id, ELFOP[6], v, k, "", false)
}
}

if passive {
con.RPCPort = RandomPort(MIN, MAX)
err := con.appendToSys()
Expand Down Expand Up @@ -2252,12 +2268,7 @@ func CommonFastRun(name, volume_map, command, engine, execmaps string) *Error {
}
id := (*configmap)["id"].(string)
if len(execmaps) > 0 {
for _, s := range strings.Split(execmaps, ":") {
k, v := strings.Split(s, "=")[0], strings.Split(s, "=")[1]
if len(k) > 0 && len(v) > 0 {
setExec(id, ELFOP[6], k, v, "", false)
}
}
(*configmap)["execmaps"] = execmaps
}
err = Run(configmap, command)
//remove container
Expand All @@ -2276,12 +2287,7 @@ func CommonCreate(name, container_name, volume_map, engine, execmaps string) *Er
return err
}
if len(execmaps) > 0 {
for _, s := range strings.Split(execmaps, ":") {
k, v := strings.Split(s, "=")[0], strings.Split(s, "=")[1]
if len(k) > 0 && len(v) > 0 {
setExec((*configmap)["id"].(string), ELFOP[6], k, v, "", false)
}
}
(*configmap)["execmaps"] = execmaps
}
err = Run(configmap)
return err
Expand Down Expand Up @@ -2537,6 +2543,9 @@ func (con *Container) genEnv(envmap map[string]string) (map[string]string, *Erro
env["BaseType"] = con.BaseType
env["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
env["ContainerConfigPath"] = con.ConfigPath
if len(con.Execmaps) > 0 {
env["FAKECHROOT_EXEC_SWITCH"] = "true"
}

//set default LD_LIBRARY_LPMX
var libs []string
Expand Down

0 comments on commit 5257958

Please sign in to comment.