2 # Copyright (C) 2007 - 2021 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.
11 Always build outside of the source tree if possible. Meson even
12 enforces this, CMake to a lesser degree does as well. This is a good
17 *** KEEP THE BUILD TREE ***
19 A big difference with Meson compared to other build systems is that you
20 should only ever have to run it once per package. You do not have to
21 re-run it every time there is a change in the source tree. To that
22 end, here is a reasonable template to use in the 'configure_commands()'
23 section of the build script...
25 # If you change the options after the build tree has already been
26 # set up and configured, run the build as: 'FORCE=1 ../build'
27 if [[ ! -d meson-info || \${FORCE} -eq 1 ]]; then
28 if [[ \${FORCE} -eq 1 ]]; then
29 _cmd=configure TREE=\${PWD}
30 echo '***' No logs on a FORCE run
31 echo Check what happened with: \'meson introspect --buildoptions -i\'
39 -Dbuildtype=release \\
42 any other options here \\
46 The Meson equivalent of configure --help
48 meson introspect --buildoptions -i
50 All "path" options (libdir, datadir, etc) are relative to prefix
51 unless the value begins with a '/' and then it is an absolute path.
53 Another nice thing about Meson is that when you set prefix to '/usr',
54 sysconfdir is automatically set to '/etc' and localstatedir to '/var'.
56 One headache that I have with Meson (and also CMake and Ninja) is
57 that file timestamps are very often not updated on install. I use
58 timestamps to help with upgrades (see: Upgrading below) and cleaning
59 out the old stuff that no longer exists in the current version of a
60 package. So here is a template for the 'install_commands()' section
61 of the build script...
64 # Meson builds tend not to update timestamps
65 meson introspect --installed -i |
66 awk '{print \$2}'|tr -d '",'|xargs touch -h
70 *** KEEP THE BUILD TREE ***
72 Always use Ninja instead of old crusty unix makefiles. Here is a
73 reasonable template for 'configure_commands()'...
76 -DCMAKE_BUILD_TYPE=Release \\
77 -DCMAKE_INSTALL_PREFIX=/usr \\
78 -DCMAKE_INSTALL_LIBDIR=lib \\
79 -DCMAKE_INSTALL_LIBEXECDIR=lib \\
80 -DCMAKE_INSTALL_LOCALSTATEDIR=/var \\
81 -DCMAKE_INSTALL_RUNSTATEDIR=/run \\
82 -DCMAKE_INSTALL_SYSCONFDIR=/etc \\
83 any other options here \\
86 Like Meson, CMake path options are relative to prefix unless the value
87 begins with a '/' and then it is absolute.
89 A nice thing about CMake is that it creates targets to edit and
90 rebuild the cache (think: reconfigure). 'ninja edit_cache' and
91 'ninja rebuld_cache', respectively.
93 Same headache as with Meson... timestamps not being updated on installs.
94 Here is the 'install_commands()' template for CMake builds...
97 # CMake builds tend not to update timestamps
98 if [ -f install_manifest.txt ]; then
99 echo>>install_manifest.txt # we need a final newline
101 touch -h \"\${file}\"
102 done<install_manifest.txt
107 install_commands() template...
110 # Libtool .la files are NOT needed on a modern Linux system
111 find /usr/lib -name \\*.la -user \$(whoami) -delete
116 1) touch ~/timestampfile
117 2) build and install the package
118 3) forall_direntries_from \$(whoami) -not -newer ~/timestampfile
120 If step 3 turns up libraries that are dependencies of other packages
121 move them to /usr/lib/deprecated until everything that needs them has
122 been updated/rebuilt. Remember to run ldconfig.
130 if [ -z "$arg" ]; then
134 (conf) less ${HOME}/configure.err ;;
135 (install) less ${HOME}/install.err ;;
136 (check) less ${HOME}/check.err ;;
137 (make) less ${HOME}/make.err ;;
138 (upd) less ${HOME}/upd.err ;;
139 (ver) less ${HOME}/verupd.err ;;
140 (all) less ${HOME}/*.err ;;
147 if [ -z "$arg" ]; then
151 (conf) less ${HOME}/configure.log ;;
152 (install) less ${HOME}/install.log ;;
153 (check) less ${HOME}/check.log ;;
154 (make) less ${HOME}/make.log ;;
155 (upd) less ${HOME}/upd.log ;;
156 (ver) less ${HOME}/verupd.log ;;
157 (all) less ${HOME}/*.log ;;
164 if [ -z "$arg" ]; then
168 (conf) less ${HOME}/configure.{err,log} ;;
169 (install) less ${HOME}/install.{err,log} ;;
170 (check) less ${HOME}/check.{err,log} ;;
171 (make) less ${HOME}/make.{err,log} ;;
172 (upd) less ${HOME}/upd.{err,log} ;;
173 (ver) less ${HOME}/verupd.{err,log} ;;
174 (all) less ${HOME}/*.{err,log} ;;
181 if [ -z "$arg" ]; then
184 grep --colour=always '^\*\*\*' ${HOME}/install.${arg}|less
190 if [ -z "$arg" ]; then
193 grep --colour=always '^\*\*\*' ${HOME}/check.${arg}|less
199 if [ -z "$arg" ]; then
202 grep --colour=always '^\*\*\*' ${HOME}/make.${arg}|less
207 for log in configure make check install upd verupd; do
208 [[ -f ${HOME}/${log}.err ]] && rm -v ${HOME}/${log}.err
209 [[ -f ${HOME}/${log}.log ]] && rm -v ${HOME}/${log}.log
216 sed -i "s|\(Version: \).*$|\1${arg}|" ${HOME}/.project
217 echo -n "Version updated... "
218 grep --colour Version:.*$ ${HOME}/.project
223 local top=$(grep -n "^Install Notes:$" ${HOME}/.project|cut -d: -f1)
224 local bot=$(grep -n "^General Notes:$" ${HOME}/.project|cut -d: -f1)
225 sed -n ${top},${bot}p ${HOME}/.project|less
230 local top=$(grep -n "^General Notes:$" ${HOME}/.project|cut -d: -f1)
231 local bot=$(grep -n "^CONTENTS:$" ${HOME}/.project|cut -d: -f1)
232 sed -n ${top},${bot}p ${HOME}/.project|less
235 ## Check if there is a newer build script, maybe update.
236 # NOTE: Updating needs SXEmacs. It'll work in XEmacs and Emacs too,
237 # but you'll need to change build-update() accordingly.
240 if [ -x $(type -p sxemacs) ]; then
241 sxemacs -l /etc/pkgusr/bld-update.el
243 echo *** Sorry, you do not have SXEmacs installed.
244 echo *** Copying the new build script to ~/build-$(date +%Y%m%d)
245 cp -v /etc/pkgusr/skel-package/build \
246 ${HOME}/build-$(date +%Y%m%d)
252 local sysb=/etc/pkgusr/skel-package/build
253 local pkgb=${HOME}/build
254 local sysbv=$(${sysb} -V|awk '/build:/ {print $2;}')
255 local pkgbv=$(${pkgb} -V|awk '/build:/ {print $2;}')
257 if [[ ${sysbv} > ${pkgbv} ]]; then
258 echo '*****************************************'
260 echo '* B u i l d S c r i p t U p d a t e *'
261 echo '* A v a i l a b l e *'
263 echo '*****************************************'
264 echo ' Your version:' ${pkgbv}
265 echo ' Available Version:' ${sysbv}
267 echo 'For a SXEmacs based interactive update, run: "build-update"'
268 echo 'To turn this notice off, set $CHECKUPDATES to: "0"'
270 echo -n 'Press [RETURN] to continue...'
275 ## Convenience to allow existing pkgusrs to update their git
279 install -vdm755 ${HOME}/.config/git &&
280 ln -svf /etc/pkgusr/gitconfig ${HOME}/.config/git/config &&
281 # Nuke the old ~/.gitconfig
282 rm -v ${HOME}/.gitconfig 2>/dev/null || true
287 alias srepo='grep --colour Repo_Location:.*$ ${HOME}/.project'
288 alias rawrepo='srepo|cut -d" " -f2|tr -d "<>"'
289 alias trepo='grep --colour Repo_Type:.*$ ${HOME}/.project'
290 alias web='grep --colour Web_Site:.*$ ${HOME}/.project'
291 alias rawweb='web|tr -s " "|cut -d" " -f3|tr -d "<>"'
293 alias alogs='ls -l ${HOME}/*.{err,log}'
294 alias lerr='ls -l ${HOME}/*.err'
295 alias llog='ls -l ${HOME}/*.log'
297 ## As of 2021-01-18 nano (v5.5) seems FUBAR'd
298 alias ebld='vi ${HOME}/build'
299 alias epro='vi ${HOME}/.project'
300 alias ebp='vi -a ${HOME}/{build,.project}'
301 # alias ebld='nano -w ${HOME}/build'
302 # alias epro='nano -w ${HOME}/.project'
303 # alias ebp='nano -w ${HOME}/{build,.project}'
304 alias deps='grep --colour "Deps: " ${HOME}/.project'
305 alias listp='pinky -l $(whoami)|less'
306 alias patches='find ${SLACKPKG}/**/$(whoami)|grep -E "(diff|patch)"'
316 alogs List of build logs (showing size)
317 lerr List just the error logs
318 llog List just the .log logs
319 verr [LOG] Display LOG, which can be:
320 \`conf' -- configure.err
321 \`check' -- check.err
322 \`install' -- install.err
326 \`all' -- all error logs (default)
327 vlog [LOG] Same as for \`verr', but for the .log files.
328 verrlog [LOG] Same as for \`verr', but displays both the .err,
330 dlog Removes all build logs
331 instg {err|log} Greps install.err (default) or install.log for
332 pkgusr notifications ("*** some message")
333 chkg {err|log} Greps check.err (default) or check.log for
334 pkgusr notifications ("*** some message")
335 makeg {err|log} Greps make.err (default) or make.log for
336 pkgusr notifications ("*** some message")
338 Package Notes/Content:
340 ipkg Displays the \`Install Notes'.
341 gpkg Displays the \`General Notes'.
342 listp Displays the entire package info (piped through less(1))
343 srepo Display the package's source repo location.
344 rawrepo Output just the repo URL (to use with lynx, curl, etc)
345 trepo Display the type of repo (git, svn, mercurial, tla etc)
346 web Display the package's homepage URL.
347 rawweb Output just the web URL (to use with lynx etc)
348 deps Display the package's dependencies
352 xtar [TARBALL] Extract TARBALL
353 vtar [TARBALL] List the contents of TARBALL
357 ebld Edit the build script.
358 epro Edit the .project file.
359 ebp Edit the build script and the .project file.
360 updver [NEWVER] Updates the version in the .project. It MUST be
361 quoted to protect it from shell expansion.
363 Miscellaneous Bobs & Bits:
365 prep_git Sets up ~/.config/git/config
366 In the normal course of events you shouldn't need to
367 use this as it happens during login if it is needed.
368 patches Check for any Slackware patches. (see SLACKPKG var in
370 B-tips A few build tips. Includes templates for Meson and
371 CMake to use in the build script.