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' ' '
190 ## Check if there is a newer build script, maybe update.
191 # NOTE: Updating needs SXEmacs. It'll work in XEmacs and Emacs too,
192 # but you'll need to change build-update() accordingly.
195 if [ -x $(type -p sxemacs) ]; then
196 sxemacs -l /etc/pkgusr/bld-update.el
202 local sysb=/etc/pkgusr/skel-package/build
203 local pkgb=${HOME}/build
204 local sysbv=$(${sysb} -V|awk '/build:/ {print $2;}')
205 local pkgbv=$(${pkgb} -V|awk '/build:/ {print $2;}')
207 if [ ${sysb} -nt ${pkgb} ]; then
208 echo '*****************************************'
210 echo '* B u i l d S c r i p t U p d a t e *'
211 echo '* A v a i l a b l e *'
213 echo '*****************************************'
214 echo ' Your version:' ${pkgbv}
215 echo ' Available Version:' ${sysbv}
217 echo 'For a SXEmacs based interactive update, run: "build-update"'
218 echo 'To turn this notice off, set $CHECKUPDATES to: "0"'
220 echo -n 'Press [RETURN] to continue...'
227 alias srepo='grep --colour Repo_Location:.*$ ${HOME}/.project'
228 alias rawrepo='srepo|cut -d" " -f2|tr -d "<>"'
229 alias trepo='grep --colour Repo_Type:.*$ ${HOME}/.project'
230 alias web='grep --colour Web_Site:.*$ ${HOME}/.project'
231 alias rawweb='web|tr -s " "|cut -d" " -f3|tr -d "<>"'
233 alias alogs='ls -l ${HOME}/*.{err,log}'
234 alias lerr='ls -l ${HOME}/*.err'
235 alias llog='ls -l ${HOME}/*.log'
237 alias ebld='nano -w ${HOME}/build'
238 alias epro='nano -w ${HOME}/.project'
239 alias ebp='nano -w ${HOME}/{build,.project}'
240 alias deps='grep --colour "Deps: " ${HOME}/.project'
243 alias listp='pinky -l $(whoami)|less'
252 alogs List of build logs (showing size)
253 lerr List just the error logs
254 llog List just the .log logs
255 verr [LOG] Display LOG, which can be:
256 \`conf' -- configure.err
257 \`check' -- check.err
258 \`install' -- install.err
262 \`all' -- all error logs (default)
263 vlog [LOG] Same as for \`verr', but for the .log files.
264 verrlog [LOG] Same as for \`verr', but displays both the .err,
266 dlog Removes all build logs
267 instg {err|log} Greps install.err (default) or install.log for
268 pkgusr notifications ("*** some message")
270 Package Notes/Content:
272 showinst Displays the \`Install Notes'. (alias: ipkg)
273 showgen Displays the \`General Notes'. (alias: gpkg)
274 listp Displays the entire package info (piped through less(1))
275 srepo Display the package's source repo location.
276 rawrepo Output just the repo URL (to use with lynx, curl, etc)
277 trepo Display the type of repo (tla, git, svn, mercurial etc)
278 web Display the package's homepage URL.
279 rawweb Output just the web URL (to use with lynx etc)
280 deps Display the package's dependencies
284 xtar [TARBALL] Extract TARBALL, automatically choosing the appropriate
286 vtar [TARBALL] List the contents of TARBALL, automatically choosing
287 appropriate options and piping through less(1).
291 ebld Edit the build script.
292 epro Edit the .project file.
293 ebp Edit the build script and the .project file.
294 updver [NEWVER] Updates the version in the .project. It MUST be
295 quoted to protect it from shell expansion.