Skip to content

Commit

Permalink
Add more file wrappers...
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed May 20, 2021
1 parent 10f421c commit 16da038
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v2.3.1
- Set the `GIT_SSL_CAINFO` variable to use the Mozilla PEM certificate with git.

v2.3.0
- Add `rpm` -- this may be removed if not useful.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ rootfs-with-spack: rootfs
$$(readlink build/6_spack/view)/include \
$$(readlink build/6_spack/view)/share/gettext/archive.dir.tar.gz \
$$(readlink build/6_spack/view)/lib/python3.8/test
$(UNSHARE) fix_file /build/6_spack/$$(readlink build/6_spack/view)/bin/file
$(UNSHARE) fix_file /build/6_spack/$$(readlink build/6_spack/view)/bin
$(UNSHARE) bash -c 'cd /build/6_spack && ./spack python -m compileall spack_src/ install/ ._view/ 1> /dev/null || true'

# Download the latest version of spack as a tarball from GitHub
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ to ensure that log files are written to the `config:misc_cache` folder.

**openssl**: By default spack.x uses `ca-certificates-mozilla` for downloading
package sources over https. If you somehow need to use system certificates,
set `SSL_CERT_DIR` and `GIT_SSL_CAPATH` or `SSL_CERT_FILE` and `GIT_SSL_CERT`.
set `SSL_CERT_DIR` and `GIT_SSL_CAINFO` or `SSL_CERT_FILE` and `GIT_SSL_CERT`.

## Can I run spack.x inside a container?

Expand Down
64 changes: 47 additions & 17 deletions build/4_environment/fix_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"io/ioutil"
"path"
"path/filepath"
)

Expand All @@ -13,27 +14,14 @@ func check(e error) {
}
}

func main() {
// `file` is not relocatable, but it's also not always possible to force
// libtool to use our version; so instead we wrap `file` in a shell script...

if len(os.Args) < 2 {
fmt.Printf("Usage: %s view/bin/file\n", os.Args[0])
os.Exit(1)
return
}

// Make input absolute
file, err := filepath.Abs(os.Args[1])
check(err)
file = filepath.Clean(file)

func file_executable_wrapper(view_dir string, exe string) {
file := path.Join(view_dir, exe)
info, err := os.Lstat(file)
check(err)

if info.Mode()&os.ModeSymlink != os.ModeSymlink {
fmt.Printf("%s is not a symlink; skipping\n", file)
os.Exit(0)
fmt.Printf(" %s is not a symlink; skipping\n", exe)
return
}

points_to, err := os.Readlink(file)
Expand All @@ -52,3 +40,45 @@ ${HERE}/` + points_to + ` "$@"
err = ioutil.WriteFile(file, []byte(contents), 0777)
check(err)
}

func main() {
// `file` is not relocatable, but it's also not always possible to force
// libtool to use our version; so instead we wrap `file` in a shell script...

if len(os.Args) < 2 {
fmt.Printf("Usage: %s view/bin\n", os.Args[0])
os.Exit(1)
return
}

// Make input absolute
view, err := filepath.Abs(os.Args[1])
check(err)
view = filepath.Clean(view)

// Make sure we have a directory
info, err := os.Lstat(view)
check(err)

if !info.IsDir() { panic(fmt.Sprintf("%s is not a directory", view)) }

exes := []string{
"file",
"gendiff",
"rpm",
"rpm2archive",
"rpm2cpio",
"rpmbuild",
"rpmdb",
"rpmgraph",
"rpmkeys",
"rpmquery",
"rpmsign",
"rpmspec",
"rpmverify",
}
for _, exe := range exes {
fmt.Printf("Making sure %s has a file wrapper\n", exe)
file_executable_wrapper(view, exe)
}
}
11 changes: 5 additions & 6 deletions build/6_spack/spack
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if [ -z ${SSL_CERT_DIR+x} ] && [ -z ${SSL_CERT_FILE+x} ]; then
export SSL_CERT_FILE="$HERE/view/share/cacert.pem"
fi

if [ -z ${GIT_SSL_CAPATH+x} ] && [ -z ${GIT_SSL_CERT+x} ]; then
export GIT_SSL_CERT="$HERE/view/share/cacert.pem"
if [ -z ${GIT_SSL_CAPATH+x} ] && [ -z ${GIT_SSL_CAINFO+x} ]; then
export GIT_SSL_CAINFO="$HERE/view/share/cacert.pem"
fi

# make our binaries and libs important
Expand All @@ -23,10 +23,9 @@ export GIT_EXEC_PATH="$HERE/view/libexec/git-core"
export GIT_TEMPLATE_DIR="$HERE/view/share/git-core/templates/"
export TERMINFO="$HERE/view/share/terminfo"

# rpm has MANY macros to be configured, let's just make everything fail and let
# the user configure every macro they need -- if that turns out incredibly
# unhelpful then I'll likely remove rpm altogether from spack.x
export RPM_CONFIGDIR="$HERE"
# rpm has MANY macros to be configured, not sure what the odds are that
# they will actually work with spack.x
export RPM_CONFIGDIR="$HERE/view/lib/rpm"

# By default run spack $@, but if NO_ENTRYPOINT=... run the command directly
if [ -z ${NO_ENTRYPOINT+x} ]; then
Expand Down

0 comments on commit 16da038

Please sign in to comment.