[sdk] Clean up path handling, make failures nonfatal
As a convenience makesdk tries to make the path entries in the ids.txt
for kernel debug info relative. This fails on the bot, likely due to
non-canonical paths. This makes the handling a bit more robust and
allows the SDK packaging to continue even if it can't figure out how to
turn some paths into relative paths.
Change-Id: I83e804e1523fe4ac60abb6bb8285d80478b47b94
diff --git a/makesdk.go b/makesdk.go
index 3598860..479e2a3 100755
--- a/makesdk.go
+++ b/makesdk.go
@@ -13,7 +13,6 @@
"log"
"os"
"os/exec"
- "path"
"path/filepath"
"runtime"
"strings"
@@ -185,12 +184,16 @@
defer dstIds.Close()
scanner := bufio.NewScanner(srcIds)
cwd, _ := os.Getwd()
- absSrc := path.Join(cwd, src)
+ absBase := filepath.Join(cwd, src)
for scanner.Scan() {
s := strings.Split(scanner.Text(), " ")
id, absPath := s[0], s[1]
- relPath := absPath[len(absSrc):]
- fmt.Fprintln(dstIds, id, relPath)
+ relPath, err := filepath.Rel(absBase, absPath)
+ if err != nil {
+ log.Warning("could not create relative path from absolute path", absPath, "and base", absBase, "skipping entry")
+ } else {
+ fmt.Fprintln(dstIds, id, relPath)
+ }
}
}