Skip to content

Commit 07fedfa

Browse files
Add habitat plan
1 parent 2cde593 commit 07fedfa

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-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: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
pkg_name=git-subsplit
2+
pkg_origin=dflydev
3+
pkg_maintainer="Beau Simensen <[email protected]>"
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+
# setup emergence build
50+
SOURCES_CACHE_PATH="${HAB_CACHE_SRC_PATH}/sources"
51+
}
52+
53+
do_unpack() {
54+
mkdir "${CACHE_PATH}"
55+
build_line "Extracting ${GIT_DIR}#${pkg_commit}"
56+
git archive "${pkg_commit}" | tar -x --directory="${CACHE_PATH}"
57+
}
58+
59+
do_build() {
60+
pushd "${CACHE_PATH}" > /dev/null
61+
62+
build_line "Fixing interpreter"
63+
sed -e "s#\#\!/usr/bin/env bash#\#\!$(pkg_path_for bash)/bin/bash#" --in-place "./git-subsplit.sh"
64+
65+
popd > /dev/null
66+
}
67+
68+
do_install() {
69+
cp -v "${CACHE_PATH}/git-subsplit.sh" "${pkg_prefix}/bin/git-subsplit"
70+
}
71+
72+
do_strip() {
73+
return 0
74+
}

0 commit comments

Comments
 (0)