Skip to content

Commit 1e1163f

Browse files
committed
add symlinks to /usr/local/bin on install
1 parent 3572386 commit 1e1163f

File tree

11 files changed

+34
-18
lines changed

11 files changed

+34
-18
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ install(
8888
install(DIRECTORY ${OpenEnclave_DIR}/../debugger DESTINATION ${CMAKE_INSTALL_LIBDIR}/openenclave)
8989
install(DIRECTORY _ertgo/ DESTINATION go USE_SOURCE_PERMISSIONS)
9090

91+
if(CMAKE_INSTALL_PREFIX STREQUAL /opt/ego)
92+
install(
93+
FILES
94+
src/symlinks/ego
95+
src/symlinks/ego-gdb
96+
src/symlinks/ego-go
97+
DESTINATION /usr/local/bin)
98+
endif()
99+
91100
set(CPACK_PACKAGE_CONTACT "contact@edgeless.systems​")
92101
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
93102
set(CPACK_DEBIAN_PACKAGE_DEPENDS

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ ego run hello
1414
```
1515

1616
## Quick Start
17-
If you are on Ubuntu 18.04 and do not want to build EGo from source, you can install the binary release:
17+
If you are on Ubuntu 18.04 or above and do not want to build EGo from source, you can install the binary release:
1818
```bash
1919
wget -qO- https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add
2020
sudo add-apt-repository 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu bionic main'
2121
wget https://github.com/edgelesssys/ego/releases/download/v0.1.0/ego_0.1.0_amd64.deb
2222
sudo apt install ./ego_0.1.0_amd64.deb
2323
```
24-
Then proceed with [Use](#use).
24+
Now you are ready to build applications with EGo! To start, check out the [samples](#samples).
2525

2626
## Build and Install
2727
*Prerequisite*: [Edgeless RT](https://github.com/edgelesssys/edgelessrt) is installed and sourced.
@@ -34,14 +34,7 @@ make
3434
make install
3535
```
3636

37-
## Use
38-
To use EGo, its `bin` directory must be in the PATH:
39-
```sh
40-
export PATH="$PATH:/opt/ego/bin"
41-
```
42-
Now you are ready to build applications with EGo!
43-
44-
### Samples
37+
## Samples
4538
* [helloworld](samples/helloworld) is a minimal example of an enclave application.
4639
* [remote_attestation](samples/remote_attestation) shows how to do remote attestation in EGo.
4740
* [vault](samples/vault) demonstrates how to port a Go application exemplified by Hashicorp Vault.

internal/cli/cli.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ func (c *Cli) run(cmd *exec.Cmd) int {
5353
}
5454
return c.runner.ExitCode(cmd)
5555
}
56+
57+
func (c *Cli) getOesignPath() string {
58+
return filepath.Join(c.egoPath, "bin", "ego-oesign")
59+
}

internal/cli/run.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ func (c *Cli) Run(filename string, args []string) int {
1717
enclaves := filepath.Join(c.egoPath, "share", "ego-enclave") + ":" + filename
1818
args = append([]string{enclaves}, args...)
1919
os.Setenv("EDG_EGO_PREMAIN", "0")
20-
cmd := exec.Command("ego-host", args...)
20+
cmd := exec.Command(c.getEgoHostPath(), args...)
2121
return c.run(cmd)
2222
}
2323

2424
// Marblerun runs a signed executable as a Marblerun Marble.
2525
func (c *Cli) Marblerun(filename string) int {
2626
enclaves := filepath.Join(c.egoPath, "share", "ego-enclave") + ":" + filename
2727
os.Setenv("EDG_EGO_PREMAIN", "1")
28-
cmd := exec.Command("ego-host", enclaves)
28+
cmd := exec.Command(c.getEgoHostPath(), enclaves)
2929
return c.run(cmd)
3030
}
31+
32+
func (c *Cli) getEgoHostPath() string {
33+
return filepath.Join(c.egoPath, "bin", "ego-host")
34+
}

internal/cli/sign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (c *Cli) signWithJSON(conf *config) error {
8181
c.createDefaultKeypair(conf.Key)
8282

8383
enclavePath := filepath.Join(c.egoPath, "share", "ego-enclave")
84-
cmd := exec.Command("ego-oesign", "sign", "-e", enclavePath, "-c", file.Name(), "-k", conf.Key, "--payload", conf.Exe)
84+
cmd := exec.Command(c.getOesignPath(), "sign", "-e", enclavePath, "-c", file.Name(), "-k", conf.Key, "--payload", conf.Exe)
8585
out, err := c.runner.CombinedOutput(cmd)
8686
if _, ok := err.(*exec.ExitError); ok {
8787
return errors.New(string(out))

internal/cli/sign_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package cli
99
import (
1010
"errors"
1111
"os/exec"
12+
"path/filepath"
1213
"testing"
1314

1415
"github.com/google/go-cmp/cmp"
@@ -120,8 +121,9 @@ func (signRunner) Output(cmd *exec.Cmd) ([]byte, error) {
120121
}
121122

122123
func (s signRunner) CombinedOutput(cmd *exec.Cmd) ([]byte, error) {
123-
if !cmp.Equal(cmd.Args[:3], []string{"ego-oesign", "sign", "-e"}) ||
124-
!cmp.Equal(cmd.Args[6:], []string{"-k", "keyfile", "--payload", "exefile"}) {
124+
if !(filepath.Base(cmd.Path) == "ego-oesign" &&
125+
cmp.Equal(cmd.Args[1:3], []string{"sign", "-e"}) &&
126+
cmp.Equal(cmd.Args[6:], []string{"-k", "keyfile", "--payload", "exefile"})) {
125127
return nil, errors.New("unexpected cmd: " + cmd.Path)
126128
}
127129
data, err := s.fs.ReadFile(cmd.Args[5])

internal/cli/signerid.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type eradump struct {
2121
}
2222

2323
func (c *Cli) signeridByKey(path string) (string, error) {
24-
out, err := c.runner.Output(exec.Command("ego-oesign", "signerid", "-k", path))
24+
out, err := c.runner.Output(exec.Command(c.getOesignPath(), "signerid", "-k", path))
2525
if err != nil {
2626
if err, ok := err.(*exec.ExitError); ok {
2727
return "", errors.New(string(err.Stderr))
@@ -32,7 +32,7 @@ func (c *Cli) signeridByKey(path string) (string, error) {
3232
}
3333

3434
func (c *Cli) readEradumpJSONtoStruct(path string) (*eradump, error) {
35-
data, err := c.runner.Output(exec.Command("ego-oesign", "eradump", "-e", path))
35+
data, err := c.runner.Output(exec.Command(c.getOesignPath(), "eradump", "-e", path))
3636

3737
if err != nil {
3838
if err, ok := err.(*exec.ExitError); ok {

internal/cli/signerid_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package cli
99
import (
1010
"errors"
1111
"os/exec"
12+
"path/filepath"
1213
"testing"
1314

1415
"github.com/spf13/afero"
@@ -46,7 +47,7 @@ func (signeridRunner) Run(cmd *exec.Cmd) error {
4647
}
4748

4849
func (signeridRunner) Output(cmd *exec.Cmd) ([]byte, error) {
49-
if cmd.Path != "ego-oesign" || len(cmd.Args) != 4 {
50+
if filepath.Base(cmd.Path) != "ego-oesign" || len(cmd.Args) != 4 {
5051
return nil, errors.New("unexpected cmd")
5152
}
5253
if cmd.Args[1] == "signerid" && cmd.Args[2] == "-k" {

src/symlinks/ego

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/opt/ego/bin/ego

src/symlinks/ego-gdb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/opt/ego/bin/ego-gdb

src/symlinks/ego-go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/opt/ego/bin/ego-go

0 commit comments

Comments
 (0)