Skip to content

Commit 94e21a3

Browse files
Add habitat plan
1 parent 2cde593 commit 94e21a3

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
results/

habitat/plan.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
pkg_name=git-subsplit
2+
pkg_origin=dflydev
3+
pkg_maintainer="Beau Simensen <hello@dflydev.com>"
4+
pkg_license=("MIT")
5+
pkg_upstream_url=https://github.com/dflydev/git-subsplit
6+
7+
pkg_build_deps=(
8+
core/git
9+
)
10+
11+
pkg_deps=(
12+
core/bash
13+
)
14+
15+
pkg_bin_dirs=(bin)
16+
17+
18+
# implement git-based dynamic version strings
19+
pkg_version() {
20+
if [ -n "${pkg_last_tag}" ]; then
21+
echo "${pkg_last_version}-git+${pkg_last_tag_distance}.${pkg_commit}"
22+
else
23+
echo "${pkg_last_version}-git+${pkg_commit}"
24+
fi
25+
}
26+
27+
28+
# implement in-git build workflow
29+
do_before() {
30+
do_default_before
31+
32+
# configure git repository
33+
export GIT_DIR="${PLAN_CONTEXT}/../.git"
34+
35+
# load version information from git
36+
pkg_commit="$(git rev-parse --short HEAD)"
37+
pkg_last_tag="$(git describe --tags --abbrev=0 ${pkg_commit} || true 2>/dev/null)"
38+
39+
if [ -n "${pkg_last_tag}" ]; then
40+
pkg_last_version=${pkg_last_tag#v}
41+
pkg_last_tag_distance="$(git rev-list ${pkg_last_tag}..${pkg_commit} --count)"
42+
else
43+
pkg_last_version="0.0.0"
44+
fi
45+
46+
# initialize pkg_version
47+
update_pkg_version
48+
}
49+
50+
do_unpack() {
51+
mkdir "${CACHE_PATH}"
52+
build_line "Extracting ${GIT_DIR}#${pkg_commit}"
53+
git archive "${pkg_commit}" | tar -x --directory="${CACHE_PATH}"
54+
}
55+
56+
do_build() {
57+
pushd "${CACHE_PATH}" > /dev/null
58+
59+
build_line "Fixing interpreter"
60+
sed -e "s#\#\!/usr/bin/env bash#\#\!$(pkg_path_for bash)/bin/bash#" --in-place "./git-subsplit.sh"
61+
62+
popd > /dev/null
63+
}
64+
65+
do_install() {
66+
cp -v "${CACHE_PATH}/git-subsplit.sh" "${pkg_prefix}/bin/git-subsplit"
67+
}
68+
69+
do_strip() {
70+
return 0
71+
}

0 commit comments

Comments
 (0)