-
Notifications
You must be signed in to change notification settings - Fork 2
/
portz
executable file
·190 lines (174 loc) · 5.18 KB
/
portz
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/env bash
##
## portz - minimal local port system
## (custom software build/packaging system)
##
## general usage:
## portz [options] ACTION [ARGS...]
##
## installation:
## portz install PACKAGE
## portz easy_install name=foo PACKAGE_URL
##
## installed packages
## portz list - list installed packages in $prefix
## portz files PACKAGE - list files in PACKAGE under $prefix
## portz uninstall PACKAGE - uninstall package
## portz classify FILES - find owner packages for FILES
##
## distribution
## portz dist PACKAGE - build tgz archive from uninstalled package
## portz packback PACKAGE - build tgz archive from alreadt installed package
##
## package maintenance
## portz invoke PACKAGE STEP - invoke particural step of build
## portz make_patch PACKAGE - make patch from currently processed sources
##
## other
## portz get_src PACKAGE
##
## environment
## prefix
## exec_prefix
## site
## portz_repo
##
## options
## -p PATH | --prefix PATH
## change installation prefix, default ($prefix, /usr/local)
## --exec-prefix PATH
## change installation prefix, default ($exec_prefix, $prefix)
## --debug|-d -- debug mode, be more verbose
## --quiet|-q -- quiet mode, show only warnings and errors
## -r REPO
## change repo location
## -a FOLDER
## change archive location
##
## install/dist/easy_install options:
## --strip -- strip debug info from binaries
## --strip-leave-debug -- move debug into from binaries to *.debug
##
#if type bashfoo >/dev/null 2>/dev/null ; then
portz_script_dir="$(dirname $BASH_SOURCE)"
if [ -f ${portz_script_dir}/bashfoo/bashfoo.sh ] ; then
export bashfoo_libdir="${portz_script_dir}/bashfoo"
source ${bashfoo_libdir}/bashfoo.sh
elif [ -f ${portz_script_dir}/../lib/portz/bashfoo/bashfoo.sh ] ; then
export bashfoo_libdir="${portz_script_dir}/../lib/portz/bashfoo"
source ${bashfoo_libdir}/bashfoo.sh
elif [ type bashfoo >/dev/null 2>/dev/null ] ; then
eval `bashfoo --eval-out`
else
echo "$0: bashfoo not found or incorrect, panic" 2>&1
exit 1
fi
bashfoo_require path
portz_script_dir=$(abspath $portz_script_dir)
if [ -f "${portz_script_dir}/scripts/runtime.sh" ] ; then
portz_libdir="${portz_script_dir}"
elif [ -f "${portz_script_dir}/../lib/portz/scripts/runtime.sh" ] ; then
portz_libdir="${portz_script_dir}/../lib/portz/"
else
echo "$0: rest of portz not found or incorrect, panic" 2>&1
exit 1
fi
bashfoo_require auto_usage
export portz_libdir
export bashfoo_libdir
portz_quiet=${portz_quiet-1}
while [ -n "$1" ] ; do
maybe_show_auto_help "$1"
if log_process_options "$1"; then
shift
continue
fi
case "$1" in
-s|--site)
[ -z "$2" ] && fail_on_bad_usage "$1, argument required"
site=$2
export site
shift ; shift
;;
-p|--prefix)
[ -z "$2" ] && fail_on_bad_usage "$1, argument required"
prefix=$2
export prefix
shift ; shift
;;
--exec-prefix|--exec_prefix)
[ -z "$2" ] && fail_on_bad_usage "$1, argument required"
exec_prefix=$2
export exec_prefix
shift ; shift
;;
-r|--repo)
[ -z "$2" ] && fail_on_bad_usage "$1, argument required"
portz_repo="$(abspath $2)"
export portz_repo
shift ; shift
;;
-a|--archive)
[ -z "$2" ] && fail_on_bad_usage "$1, argument required"
portz_archive="$(abspath $2)"
export portz_archive
shift ; shift
;;
-n|--dry-run)
export portz_dry_run=1
shift
;;
--strip)
export portz_deploy_strip_binaries=1
shift
;;
--strip-leave-debug)
export portz_deploy_strip_binaries=1
export portz_deploy_strip_leave_debug_info=1
shift
;;
-i)
action=install ; shift ;;
-ql)
action=file ; shift ;;
get_src)
action=get
shift
break
;;
list)
next_cmd="${portz_libdir}/portz_query list"
shift ; break ;;
-S|-qf|classify)
action=find_pkg
shift
break;
;;
files)
next_cmd="${portz_libdir}/portz_query files"
shift ; break ;;
dist|install|invoke|easy_install|query|packback|uninstall|build_site|invoke|make_patch)
action=$1
shift
break
;;
*)
fail_on_bad_usage "'$1' -- invalid action or option"
;;
esac
done
[ -z "$action" -a -z "$next_cmd" ] && fail_on_bad_usage "action required"
export portz_libdir
if [ -n "$site" ] ; then
log_info "using site=$site"
fi
log_debug "portz_libdir=$portz_libdir"
log_debug "prefix=$prefix"
log_debug "exec_prefix=$exec_prefix"
if [ -n "${next_cmd}" ] ; then
log_debug "next_cmd=$next_cmd"
exec ${next_cmd} "$@"
else
log_debug "action=$action"
exec "${portz_libdir}/portz_${action}" "$@"
fi