HeSYINUvSBZfxqA-capistrano 2.5.23 → 2.5.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,174 @@
1
+ #! /bin/sh
2
+ # $Id$
3
+ # vim:et:ft=sh:sts=2:sw=2
4
+ #
5
+ # Copyright 2008 Kate Ward. All Rights Reserved.
6
+ # Released under the LGPL (GNU Lesser General Public License)
7
+ #
8
+ # Author: kate.ward@forestent.com (Kate Ward)
9
+ #
10
+ # This library provides reusable functions that determine actual names and
11
+ # versions of installed shells and the OS. The library can also be run as a
12
+ # script if set execuatable.
13
+
14
+ VERSIONS_SHELLS='/bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/sh /bin/zsh'
15
+
16
+ #------------------------------------------------------------------------------
17
+ # functions
18
+ #
19
+
20
+ versions_osName()
21
+ {
22
+ os_name_='unrecognized'
23
+ os_system_=`uname -s`
24
+ case ${os_system_} in
25
+ Cygwin) os_name_='Cygwin' ;;
26
+ Darwin) os_name_='Mac OS X' ;;
27
+ Linux) os_name_='Linux' ;;
28
+ SunOS) os_name_='Solaris' ;;
29
+ esac
30
+ echo ${os_name_}
31
+ unset os_name_ os_system_
32
+ }
33
+
34
+ versions_osRelease()
35
+ {
36
+ os_str_='unrecognized'
37
+ os_system_=`uname -s`
38
+ os_release_=`uname -r`
39
+ case ${os_system_} in
40
+ Cygwin) os_str_='unknown' ;;
41
+ Darwin)
42
+ major_='10'
43
+ sub_=`echo ${os_release_} |\
44
+ sed 's/^[0-9]*\.\([0-9]*\)\.[0-9]*$/\1/'`
45
+ case ${os_release_} in
46
+ 8.*) minor_='4' ;;
47
+ 9.*) minor_='5' ;;
48
+ *) minor_='X'; sub_='X' ;;
49
+ esac
50
+ os_str_="${major_}.${minor_}.${sub_}"
51
+ ;;
52
+ Linux)
53
+ if [ -r '/etc/lsb-release' ]; then
54
+ os_str_=`. /etc/lsb-release && \
55
+ echo "${DISTRIB_ID:-}-${DISTRIB_RELEASE:-}"`
56
+ fi
57
+ if [ "${os_release_}" = '-' ]; then
58
+ os_str_=''
59
+ if [ -r '/etc/redhat-release' ]; then
60
+ os_str_=`cat /etc/redhat-release`
61
+ fi
62
+ fi
63
+ ;;
64
+ SunOS)
65
+ os_version_=`versions_osVersion`
66
+
67
+ os_str_=`echo ${os_release_} |sed 's/[0-9]*\.\([0-9]*\)/\1/'`
68
+ os_str_="${os_release_}-${os_version_}"
69
+ ;;
70
+ esac
71
+ echo ${os_str_}
72
+ unset os_name_ os_release_ os_str_ os_version_ major_ minor_ sub_
73
+ }
74
+
75
+ versions_osVersion()
76
+ {
77
+ uname -v
78
+ }
79
+
80
+ versions_shellVersion()
81
+ {
82
+ shell_=$1
83
+
84
+ if [ ! -x "${shell_}" ]; then
85
+ echo 'not installed'
86
+ return
87
+ fi
88
+
89
+ version_=''
90
+ case ${shell_} in
91
+ */sh)
92
+ # TODO(kward): fix this
93
+ ## this could be one of any number of shells. try until one fits.
94
+ #version_=`versions_shell_bash ${shell_}`
95
+ ## dash cannot be self determined yet
96
+ #[ -z "${version_}" ] && version_=`versions_shell_ksh ${shell_}`
97
+ ## pdksh is covered in versions_shell_ksh()
98
+ #[ -z "${version_}" ] && version_=`versions_shell_zsh ${shell_}`
99
+ ;;
100
+ */bash) version_=`versions_shell_bash ${shell_}` ;;
101
+ */dash)
102
+ # simply assuming Ubuntu Linux until somebody comes up with a better
103
+ # test. the following test will return an empty string if dash is not
104
+ # installed.
105
+ version_=`versions_shell_dash`
106
+ ;;
107
+ */ksh) version_=`versions_shell_ksh ${shell_}` ;;
108
+ */pdksh) version_=`versions_shell_pdksh ${shell_}` ;;
109
+ */zsh) version_=`versions_shell_zsh ${shell_}` ;;
110
+ *) version_='invalid'
111
+ esac
112
+
113
+ echo ${version_:-unknown}
114
+ unset shell_ version_
115
+ }
116
+
117
+ versions_shell_bash()
118
+ {
119
+ $1 --version 2>&1 |grep 'GNU bash' |sed 's/.*version \([^ ]*\).*/\1/'
120
+ }
121
+
122
+ versions_shell_dash()
123
+ {
124
+ dpkg -l |grep ' dash ' |awk '{print $3}'
125
+ }
126
+
127
+ versions_shell_ksh()
128
+ {
129
+ versions_shell_=$1
130
+
131
+ versions_version_=`strings ${versions_shell_} 2>&1 \
132
+ |grep Version \
133
+ |sed 's/^.*Version \(.*\)$/\1/;s/ s+ \$$//;s/ /-/g'`
134
+ [ -z "${versions_version_}" ] \
135
+ && versions_version_=`versions_shell_pdksh ${versions_shell_}`
136
+ echo ${versions_version_}
137
+
138
+ unset versions_shell_ versions_version_
139
+ }
140
+
141
+ versions_shell_pdksh()
142
+ {
143
+ strings $1 2>&1 \
144
+ |grep 'PD KSH' \
145
+ |sed -e 's/.*PD KSH \(.*\)/\1/;s/ /-/g'
146
+ }
147
+
148
+ versions_shell_zsh()
149
+ {
150
+ echo 'echo ${ZSH_VERSION}' |$1
151
+ }
152
+
153
+ #------------------------------------------------------------------------------
154
+ # main
155
+ #
156
+
157
+ versions_main()
158
+ {
159
+ # treat unset variables as an error
160
+ set -u
161
+
162
+ os_name=`versions_osName`
163
+ os_version=`versions_osVersion`
164
+ echo "os: ${os_name} version: ${os_version}"
165
+
166
+ for shell in ${VERSIONS_SHELLS}; do
167
+ shell_version=`versions_shellVersion ${shell}`
168
+ echo "shell: ${shell} version: ${shell_version}"
169
+ done
170
+ }
171
+
172
+ if [ "`basename $0`" = 'versions' ]; then
173
+ versions_main "$@"
174
+ fi
data/bin/build CHANGED
@@ -1,3 +1,32 @@
1
- #!/bin/bash -e
1
+ #!/bin/bash
2
2
 
3
- gem build $(basename $(pwd)).gemspec
3
+ #/ NAME
4
+ #/ build -- upload the latest (timestamp) rubygem to rubygems.org
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ build -n gem_name
8
+
9
+ # figure out the project root under which bin, lib live
10
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
11
+
12
+ # load a meat library
13
+ source "$shome/bin/_prime" "$@"
14
+
15
+ # entry point
16
+ function main {
17
+ pth_gemspec="$shome/$FLAGS_name.gemspec"
18
+ if [[ ! -e "$pth_gemspec" ]]; then
19
+ logger_fatal "could not find gemspec $pth_gemspec"
20
+ exit 1
21
+ fi
22
+
23
+ gem build "$pth_gemspec"
24
+ }
25
+
26
+ # parse the command-line
27
+ DEFINE_string 'name' "$(basename "$shome")" 'name of gem' 'n'
28
+ parse_command_line "$@" || exit $?
29
+ eval set -- "${FLAGS_ARGV}"
30
+
31
+ # pass arguments to entry point
32
+ main "$@"
@@ -0,0 +1,156 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ bump -- increments a semver in a file or in git tags
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ bump [major|minor|patch]
8
+ #/ bump 1.2.3
9
+ #/ bump
10
+ #/ without arguments is equivalent to 'bump patch'
11
+
12
+ # figure out the project root under which bin, lib live
13
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
14
+
15
+ # load a meat library
16
+ source "$shome/bin/_prime" "$@"
17
+
18
+ function bump_version {
19
+ if [[ "$FLAGS_dirty" = "$FLAGS_FALSE" ]]; then
20
+ ensure_clean_git_status
21
+ fi
22
+
23
+ local_file=
24
+ if [[ -f VERSION || -L VERSION ]]; then
25
+ local_file=1
26
+ if [[ ! -e VERSION ]]; then
27
+ logger_fatal "cannot write to VERSION file"
28
+ exit 1
29
+ fi
30
+ fi
31
+
32
+ tmp_version=$(mktemp -t XXXXXXXXX)
33
+ if [[ -n $local_file ]]; then
34
+ cat VERSION | perl -ne 'm{^\s*v?(\d+)\.(\d+)\.(\d+)\s*$} && printf("%03d.%03d.%03d %d.%d.%d\n",$1,$2,$3,$1,$2,$3)' | sort -r | head -1 | awk '{print $2}' > $tmp_version
35
+ else
36
+ git tag | perl -ne 'm{^v(\d+)\.(\d+)\.(\d+)$} && printf("%03d.%03d.%03d %d.%d.%d\n",$1,$2,$3,$1,$2,$3)' | sort -r | head -1 | awk '{print $2}' > $tmp_version
37
+ fi
38
+
39
+ if [[ ! -s "$tmp_version" ]]; then
40
+ logger_fatal "need at least one git tag (in the form v0.0.0) or a version in file VERSION (in the form 0.0.0)"
41
+ exit 1
42
+ fi
43
+
44
+ case "$1" in
45
+ patch|minor|major)
46
+ bump=$1; shift
47
+ set -- $(cat $tmp_version | sed 's#\.# #g')
48
+ case "$bump" in
49
+ patch)
50
+ echo "$1.$2.$(($3 + 1))"
51
+ ;;
52
+ minor)
53
+ echo "$1.$(($2 + 1)).0"
54
+ ;;
55
+ major)
56
+ echo "$(($1 + 1)).0.0"
57
+ ;;
58
+ esac > $tmp_version
59
+ ;;
60
+ *)
61
+ ver_new=$1; shift
62
+ ver_new=${ver_new#v}
63
+ echo $ver_new > $tmp_version
64
+ ;;
65
+ esac
66
+
67
+ ver_new=$(cat $tmp_version)
68
+ set -- $(echo "$ver_new" | sed 's#\.# #g') 0
69
+ M=$1; shift
70
+ m=$1; shift
71
+ p=$1; shift
72
+
73
+ (echo "$(($M+0)).$(($m+0)).$(($p+0))" > $tmp_version) 2>&-
74
+ ver_new_same=$(cat $tmp_version)
75
+
76
+ if [[ $ver_new != $ver_new_same ]]; then
77
+ logger_fatal "invalid version: $ver_new"
78
+ exit 1
79
+ fi
80
+
81
+ ver_bumped="v$(cat $tmp_version)"
82
+ rm -f $tmp_version
83
+ ensure_git_tag_available $ver_bumped
84
+
85
+ if [[ -n $local_file ]]; then
86
+ echo ${ver_bumped#v} > VERSION
87
+ git add VERSION
88
+ if [[ -f Gemfile ]]; then
89
+ bundle check 2>&1 >/dev/null || { bundle --quiet install --local --path vendor/bundle || bundle check > /dev/null; }
90
+ git add Gemfile.lock
91
+ fi
92
+
93
+ git commit -m "bump: $ver_bumped"
94
+ git push
95
+ fi
96
+
97
+ git_tag "$ver_bumped"
98
+ echo $ver_bumped
99
+ }
100
+
101
+ function ensure_git_tag_available {
102
+ version=$1; shift
103
+ git fetch --tags
104
+ remote_sha=$(git ls-remote origin $version | awk '{print $1}')
105
+ if [[ -n $remote_sha ]]; then
106
+ logger_fatal "already a remote tag $version, bump again"
107
+ exit 1
108
+ fi
109
+
110
+ local_sha=$(git show-ref $version | awk '{print $1}')
111
+ if [[ -n $local_sha ]]; then
112
+ logger_fatal "already a local tag $version"
113
+ exit 1
114
+ fi
115
+ }
116
+
117
+ function git_tag {
118
+ local version=$1; shift
119
+
120
+ ensure_git_tag_available "$version"
121
+
122
+ git tag $version
123
+ git push origin tag $version
124
+ remote_sha=$(git ls-remote origin $version | awk '{print $1}')
125
+ local_sha=$(git show-ref $version | awk '{print $1}')
126
+ if [[ $remote_sha != $local_sha ]]; then
127
+ logger_fatal "remote tag $version does not match local SHA"
128
+ exit 1
129
+ fi
130
+ }
131
+
132
+ function ensure_clean_git_status {
133
+ local lines=$(git status -s -uno | wc -l | awk '{print $1}')
134
+ if [[ $lines != "0" ]]; then
135
+ logger_fatal "git status is not clean, cannot tag"
136
+ git status -s -uno
137
+ exit 1
138
+ fi
139
+ }
140
+
141
+ # entry point
142
+ function main {
143
+ bump_version "$@"
144
+ }
145
+
146
+ # parse the command-line
147
+ DEFINE_boolean 'dirty' "$FLAGS_FALSE" 'force bumping in unclean work area' 'f'
148
+ parse_command_line "$@" || exit $?
149
+ eval set -- "${FLAGS_ARGV}"
150
+
151
+ if [[ "$#" = 0 ]]; then
152
+ set -- patch
153
+ fi
154
+
155
+ # pass arguments to entry point
156
+ main "$@"
@@ -0,0 +1,42 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ free_sample -- template for a meaty script
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ free_sample script_name
8
+
9
+ # figure out the project root under which bin, lib live
10
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
11
+
12
+ # load a meat library
13
+ source "$shome/bin/_prime" "$@"
14
+
15
+ # entry point
16
+ function main {
17
+ local nm_script="$1"; shift
18
+
19
+ tmp_script="$(mktemp -t XXXXXXXXX)"
20
+ cat "$shome/bin/$(basename "$0")" | sed "s#free_sample#$nm_script#" > "$tmp_script"
21
+ mv "$tmp_script" "$shome/bin/$nm_script.new"
22
+ chmod 755 "$shome/bin/$nm_script.new"
23
+ mv "$shome/bin/$nm_script.new" "$shome/bin/$nm_script"
24
+ }
25
+
26
+ # define command line options:
27
+ # var name, default, description, short option
28
+ DEFINE_string 'name' '' 'generate script name' '-n'
29
+
30
+ # parse the command-line
31
+ parse_command_line "$@" || exit $?
32
+ eval set -- "${FLAGS_ARGV}"
33
+
34
+ if [[ "$#" = 0 ]]; then
35
+ logger_fatal "missing script name"
36
+ display_help
37
+ exit 1
38
+ fi
39
+
40
+ # pass arguments to entry point
41
+ main "$@"
42
+
@@ -0,0 +1,43 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ meat -- sources a meaty library and dump arguments
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ meat the stuff you get at safeway
8
+ #/ meat --prime japanese kobe steak
9
+ #/
10
+ #/ DESCRIPTION
11
+ #/
12
+ #/ The arguments are arbitrary.
13
+
14
+ shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)"
15
+ source "$shome/bin/_prime" "$@"
16
+
17
+ function dump_args {
18
+ echo "0' $shome"
19
+
20
+ local i=1
21
+ while [[ "$#" > 0 ]]; do
22
+ echo "$i: $1"; shift
23
+ i="$((i+1))"
24
+ done
25
+ }
26
+
27
+ function main {
28
+ local quality="meat"
29
+
30
+ if [[ "$FLAGS_prime" = "$FLAGS_TRUE" ]]; then
31
+ quality="prime"
32
+ fi
33
+
34
+ require "$quality" "$@"
35
+
36
+ dump_args "$@"
37
+ }
38
+
39
+ DEFINE_boolean 'prime' 'false' 'enable more restrictions'
40
+
41
+ parse_command_line "$@" || exit $?
42
+ eval set -- "${FLAGS_ARGV}"
43
+ main "$@"