mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-25 06:56:12 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1895fabfb0
|
||
|
|
0dfb66c6c0
|
@@ -261,6 +261,17 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks, k
|
||||
fmt.Printf("Stripped %s (%s)\n", path, mimetype)
|
||||
}
|
||||
} else if strings.HasPrefix(mimetype, "application/x-pie-executable") || strings.HasPrefix(mimetype, "application/x-sharedlib") {
|
||||
cmd = exec.Command("file", "-b", path)
|
||||
cmd.Stderr = os.Stderr
|
||||
output, err = cmd.Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Skip files that use ELF as a container format
|
||||
if strings.Contains(string(output), "no machine") {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := exec.Command("strip", "--strip-unneeded", path)
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
|
||||
+36
-1
@@ -376,9 +376,44 @@ func executePackageScript(pkg, rootDir string, verbose bool, packageScript strin
|
||||
cmd := exec.Command("/bin/bash", "-c", content)
|
||||
// Setup subprocess environment
|
||||
cmd.Dir = "/"
|
||||
// Run hook in chroot if using the -R flag
|
||||
// Run package script in chroot if using the -R flag
|
||||
if rootDir != "/" {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Chroot: rootDir}
|
||||
|
||||
// Bind mount /etc/resolv.conf
|
||||
mounted, err := func() (bool, error) {
|
||||
if _, err := os.Stat("/etc/resolv.conf"); err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Join(rootDir, "etc/resolv.conf")); os.IsNotExist(err) {
|
||||
err = os.WriteFile(path.Join(rootDir, "/etc/resolv.conf"), nil, 0644)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
} else if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
mntCmd := exec.Command("mount", "-o", "ro,bind", "/etc/resolv.conf", path.Join(rootDir, "/etc/resolv.conf"))
|
||||
if verbose {
|
||||
mntCmd.Stdout = os.Stdout
|
||||
mntCmd.Stderr = os.Stderr
|
||||
}
|
||||
err = mntCmd.Run()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if mounted {
|
||||
defer exec.Command("umount", "-f", path.Join(rootDir, "/etc/resolv.conf")).Run()
|
||||
}
|
||||
}
|
||||
// Show output if verbose
|
||||
if verbose {
|
||||
|
||||
Reference in New Issue
Block a user