aports/testing/booster/0004-generator-use-filepath.IsAbs-to-check-for-absolute-p.patch

35 lines
1.1 KiB
Diff

From 665ebecfb7087d2b2a96d69ff62ca58f5182af63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Sat, 2 Apr 2022 03:42:44 +0200
Subject: [PATCH] generator: use filepath.IsAbs to check for absolute paths
The implementation of filepath.IsAbs also checks for a string prefix
so this doesn't entail any functional changes but seems a bit cleaner
IMHO.
---
generator/generator.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/generator/generator.go b/generator/generator.go
index d198a5a..0fedda5 100644
--- a/generator/generator.go
+++ b/generator/generator.go
@@ -5,7 +5,7 @@ import (
"fmt"
"net"
"os"
- "strings"
+ "path/filepath"
"time"
"github.com/cavaliergopher/cpio"
@@ -247,7 +247,7 @@ func (img *Image) appendInitBinary(initBinary string) error {
func (img *Image) appendExtraFiles(binaries []string) error {
for _, f := range binaries {
- if !strings.HasPrefix(f, "/") {
+ if !filepath.IsAbs(f) {
// simple names like "strace" are resolved as binaries under /usr/bin
f = "/usr/bin/" + f
}