Skip to content

Commit

Permalink
Add habitat plan
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Jun 20, 2018
1 parent 2cde593 commit 07fedfa
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/
74 changes: 74 additions & 0 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
pkg_name=git-subsplit
pkg_origin=dflydev
pkg_maintainer="Beau Simensen <[email protected]>"
pkg_license=("MIT")
pkg_upstream_url=https://github.com/dflydev/git-subsplit

pkg_build_deps=(
core/git
)

pkg_deps=(
core/bash
)

pkg_bin_dirs=(bin)


# implement git-based dynamic version strings
pkg_version() {
if [ -n "${pkg_last_tag}" ]; then
echo "${pkg_last_version}-git+${pkg_last_tag_distance}.${pkg_commit}"
else
echo "${pkg_last_version}-git+${pkg_commit}"
fi
}


# implement in-git build workflow
do_before() {
do_default_before

# configure git repository
export GIT_DIR="${PLAN_CONTEXT}/../.git"

# load version information from git
pkg_commit="$(git rev-parse --short HEAD)"
pkg_last_tag="$(git describe --tags --abbrev=0 ${pkg_commit} || true 2>/dev/null)"

if [ -n "${pkg_last_tag}" ]; then
pkg_last_version=${pkg_last_tag#v}
pkg_last_tag_distance="$(git rev-list ${pkg_last_tag}..${pkg_commit} --count)"
else
pkg_last_version="0.0.0"
fi

# initialize pkg_version
update_pkg_version

# setup emergence build
SOURCES_CACHE_PATH="${HAB_CACHE_SRC_PATH}/sources"
}

do_unpack() {
mkdir "${CACHE_PATH}"
build_line "Extracting ${GIT_DIR}#${pkg_commit}"
git archive "${pkg_commit}" | tar -x --directory="${CACHE_PATH}"
}

do_build() {
pushd "${CACHE_PATH}" > /dev/null

build_line "Fixing interpreter"
sed -e "s#\#\!/usr/bin/env bash#\#\!$(pkg_path_for bash)/bin/bash#" --in-place "./git-subsplit.sh"

popd > /dev/null
}

do_install() {
cp -v "${CACHE_PATH}/git-subsplit.sh" "${pkg_prefix}/bin/git-subsplit"
}

do_strip() {
return 0
}

0 comments on commit 07fedfa

Please sign in to comment.