Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add habitat plan #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/
71 changes: 71 additions & 0 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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
}

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
}