-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathplan.sh
More file actions
71 lines (54 loc) · 1.49 KB
/
plan.sh
File metadata and controls
71 lines (54 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pkg_name=git-subsplit
pkg_origin=dflydev
pkg_maintainer="Beau Simensen <hello@dflydev.com>"
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
}