2 # Copyright (C) 2007 - 2014 Steve Youngs <steve@sxemacs.org>
4 # What lies here is a collection of handy bash shell functions and
5 # aliases that make life a little easier for pkgusr.
10 local al=$(wc -l<${arg})
11 local sl=$(($LINES-2))
13 if [ $al -le $sl ]; then
23 if [ -z "$arg" ]; then
27 (conf) less-or-cat ${HOME}/configure.err ;;
28 (install) less-or-cat ${HOME}/install.err ;;
29 (check) less-or-cat ${HOME}/check.err ;;
30 (make) less-or-cat ${HOME}/make.err ;;
31 (upd) less-or-cat ${HOME}/upd.err ;;
32 (ver) less-or-cat ${HOME}/verupd.err ;;
33 (all) less ${HOME}/*.err ;;
40 if [ -z "$arg" ]; then
44 (conf) less-or-cat ${HOME}/configure.log ;;
45 (install) less-or-cat ${HOME}/install.log ;;
46 (check) less-or-cat ${HOME}/check.log ;;
47 (make) less-or-cat ${HOME}/make.log ;;
48 (upd) less-or-cat ${HOME}/upd.log ;;
49 (ver) less-or-cat ${HOME}/verupd.log ;;
50 (all) less ${HOME}/*.log ;;
57 if [ -z "$arg" ]; then
61 (conf) less ${HOME}/configure.{err,log} ;;
62 (install) less ${HOME}/install.{err,log} ;;
63 (check) less ${HOME}/check.{err,log} ;;
64 (make) less ${HOME}/make.{err,log} ;;
65 (upd) less ${HOME}/upd.{err,log} ;;
66 (ver) less ${HOME}/verupd.{err,log} ;;
67 (all) less ${HOME}/*.{err,log} ;;
77 grep --color '^\*\*\*' ${HOME}/install.${arg}
82 for log in configure make check install upd verupd; do
83 [[ -f ${HOME}/${log}.err ]] && rm -v ${HOME}/${log}.err
84 [[ -f ${HOME}/${log}.log ]] && rm -v ${HOME}/${log}.log
91 sed -i "s|\(Version: \).*$|\1${arg}|" ${HOME}/.project
92 echo -n "Version updated... "
93 grep --colour Version:.*$ ${HOME}/.project
98 local top=$(grep -n "^Install Notes:$" ${HOME}/.project|cut -d: -f1)
99 local bot=$(grep -n "^General Notes:$" ${HOME}/.project|cut -d: -f1)
100 sed -n ${top},${bot}p ${HOME}/.project
105 local top=$(grep -n "^General Notes:$" ${HOME}/.project|cut -d: -f1)
106 local bot=$(grep -n "^CONTENTS:$" ${HOME}/.project|cut -d: -f1)
107 sed -n ${top},${bot}p ${HOME}/.project
116 if [ -z "${fname}" ]; then
117 echo No filename specified >&2
121 type=$(file ${fname}|cut -d' ' -f2)
130 if lzmainfo ${fname} &>/dev/null; then
133 printf "Unknown file type: %s\n" $type >&2
148 if [ -z "${fname}" ]; then
149 echo No filename specified >&2
153 type=$(file ${fname}|cut -d' ' -f2)
157 (gzip) opts=ztvvvf ;;
158 (bzip2) opts=jtvvvf ;;
159 (xz|XZ) opts=Jtvvvf ;;
161 # lzma. Here because lzmainfo is too stupid
162 if lzmainfo ${fname} &>/dev/null; then
165 printf "Unknown file type: %s\n" $type >&2
171 tar ${opts} ${fname}|less
174 # Used primarily in the build script to update deps.
179 [ -z "$arg" ] && arg=$(whoami)
181 for file in $(forall_direntries_from $arg -type f -executable -readable); do
182 (readelf -d $file ; ldd $file ) |
183 awk '/NEEDED/ { lib=substr($5,2,length($5)-2); LIBS[lib]=$5 } \
184 /.*=>/ {if ( $1 in LIBS ) LIBS[$1]=$3 } END \
185 { for (lib in LIBS) print LIBS[lib] }' |
186 xargs stat --printf "%U:%G\n"
187 done|sort -u|tr -s '\n' ' '
192 alias srepo='grep --colour Repo_Location:.*$ ${HOME}/.project'
193 alias rawrepo='srepo|cut -d" " -f2|tr -d "<>"'
194 alias trepo='grep --colour Repo_Type:.*$ ${HOME}/.project'
195 alias web='grep --colour Web_Site:.*$ ${HOME}/.project'
196 alias rawweb='web|tr -s " "|cut -d" " -f3|tr -d "<>"'
198 alias alogs='ls -l ${HOME}/*.{err,log}'
199 alias lerr='ls -l ${HOME}/*.err'
200 alias llog='ls -l ${HOME}/*.log'
202 alias ebld='nano -w ${HOME}/build'
203 alias epro='nano -w ${HOME}/.project'
204 alias ebp='nano -w ${HOME}/{build,.project}'
205 alias deps='grep --colour "Deps: " ${HOME}/.project'
208 alias listp='pinky -l $(whoami)|less'
217 alogs List of build logs (showing size)
218 lerr List just the error logs
219 llog List just the .log logs
220 verr [LOG] Display LOG, which can be:
221 \`conf' -- configure.err
222 \`check' -- check.err
223 \`install' -- install.err
227 \`all' -- all error logs (default)
228 vlog [LOG] Same as for \`verr', but for the .log files.
229 verrlog [LOG] Same as for \`verr', but displays both the .err,
231 dlog Removes all build logs
232 instg {err|log} Greps install.err (default) or install.log for
233 pkgusr notifications ("*** some message")
235 Package Notes/Content:
237 showinst Displays the \`Install Notes'. (alias: ipkg)
238 showgen Displays the \`General Notes'. (alias: gpkg)
239 listp Displays the entire package info (piped through less(1))
240 srepo Display the package's source repo location.
241 rawrepo Output just the repo URL (to use with lynx, curl, etc)
242 trepo Display the type of repo (tla, git, svn, mercurial etc)
243 web Display the package's homepage URL.
244 rawweb Output just the web URL (to use with lynx etc)
245 deps Display the package's dependencies
249 xtar [TARBALL] Extract TARBALL, automatically choosing the appropriate
251 vtar [TARBALL] List the contents of TARBALL, automatically choosing
252 appropriate options and piping through less(1).
256 ebld Edit the build script.
257 epro Edit the .project file.
258 ebp Edit the build script and the .project file.
259 updver [NEWVER] Updates the version in the .project. It MUST be
260 quoted to protect it from shell expansion.