Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71edc8b8 authored by Dan Willemsen's avatar Dan Willemsen
Browse files

Add BUILD_USERNAME and BUILD_HOSTNAME

As part of a future change to sandbox the build on Linux, the real
username will be switching to "nobody", and the hostname will be
switching to "android-build".

The USER environment variable will reflect the sandboxed value, so for
the build properties that want the external USER, they'll need to use
BUILD_USERNAME.

Similarly, BUILD_HOSTNAME will reflect the real value, while the
`hostname` tool will return "android-build"

Bug: 122270019
Test: check build.prop
Change-Id: I99604b9488732a63690b256dc4dd7894d369a32c
parent e2e13a5d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ import (
	"crypto/md5"
	"fmt"
	"io/ioutil"
	"os"
	"os/user"
	"path/filepath"
	"strings"

@@ -96,6 +98,22 @@ func runKati(ctx Context, config Config, extraSuffix string, args []string, envF

	envFunc(cmd.Environment)

	if _, ok := cmd.Environment.Get("BUILD_USERNAME"); !ok {
		u, err := user.Current()
		if err != nil {
			ctx.Println("Failed to get current user")
		}
		cmd.Environment.Set("BUILD_USERNAME", u.Username)
	}

	if _, ok := cmd.Environment.Get("BUILD_HOSTNAME"); !ok {
		hostname, err := os.Hostname()
		if err != nil {
			ctx.Println("Failed to read hostname")
		}
		cmd.Environment.Set("BUILD_HOSTNAME", hostname)
	}

	cmd.StartOrFatal()
	status.KatiReader(ctx.Status.StartTool(), pipe)
	cmd.WaitOrFatal()