Skip to content

Commit

Permalink
paired with @elbandito on multibuildpack support
Browse files Browse the repository at this point in the history
  • Loading branch information
hone committed May 8, 2019
1 parent 71fe5e8 commit 3715e77
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ mkdir -p "${profile_dir}/profile.d"
cp .profile.d/* "${profile_dir}/profile.d/"
echo "launch = true" > ${layers_dir}/profile.toml

if [ -f "{$target_dir}/exports" ]; then
echo "build = true" >> ${layers_dir}/profile.toml
mkdir -p "${profile_dir}/profile.d/env.build/"
"${bp_dir}/bin/exports" "${target_dir}/exports" "${platform_dir}"
fi

# run bin/release, read Procfile, and generate launch.toml
"${bp_dir}/bin/release" "${target_dir}" "${layers_dir}" "${platform_dir}"
39 changes: 39 additions & 0 deletions cmd/exports/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/buildpack/libbuildpack/logger"
)

func main() {
if len(os.Args) != 2 {
fmt.Println("Usage:", os.Args[0], "EXPORTS_PATH", "PLATFORM_DIR")
return
}

log, err := logger.DefaultLogger(os.Args[3])
if err != nil {
log.Info(err.Error())
os.Exit(1)
}

exportsPath := os.Args[1]

data, err := ioutil.ReadFile(exportsPath)
if err != nil {
log.Info(err.Error())
os.Exit(2)
}

contents := string(data)
lines := strings.SplitN(contents, "\n", 2)

for _, line := range lines {
components := strings.Split(line, "=")
ioutil.WriteFile(components[0], []byte(components[1]), 0644)
}
}

0 comments on commit 3715e77

Please sign in to comment.