Peter Schaffter <pe...@schaffter.ca> wrote: > On Mon, Apr 27, 2020, T. Kurt Bond wrote: >> I added a -P option that lets you specify the prefix to use. I often >> install software into places like /sw/versions/groff/git (so I can >> have multiple versions of software installed), which means >> that the I'd specify "-P /sw/versions/groff/git/share/groff". > > Needs better documentation. > > -P dir > Path to the top-level groff directory if groff has been > installed in a non-default location.
Yes, that is much better. I've attached a patch against the original install-font.sh versus a version with that change made. >> I added a -n option that stops the source font file from >> being installed anywhere. This is useful if you don't have >> /usr/local/share/fonts/truetype or /usr/local/share/fonts/opentype >> or /usr/local/share/fonts/type1, which, if you didn't specify -C >> and depending on the type of font file, is where the source file >> is copied to. > > Okay. Does the same thing as answering "n" to the prompt that asks > whether to copy, but might be useful for batch processing. Yes, I found it useful for that. >> Also, wouldn't this script be useful to include in the groff >> distribution? > > I'm inclined to think so, however it contains non-portable bashisms > and so might not be appropriate. The script was a quick and dirty > solution to font installation. Something similar but more robust > and not reliant on a particular shell interpreter would be better. That makes sense. -- T. Kurt Bond, tkurtb...@gmail.com
diff -Naur old/install-font.sh b/install-font.sh --- old/install-font.sh 2020-04-01 16:11:12.000000000 -0400 +++ b/install-font.sh 2020-04-28 19:08:42.120565093 -0400 @@ -33,7 +33,7 @@ printf <<EOF \ "USAGE: - install-font.sh [-hHlscp] [-C \033[4mdir\033[0m] [-F \033[4mfamily\033[0m] \ + install-font.sh [-hHlscpn] [-P \033[4mdir\033[0m] [-C \033[4mdir\033[0m] [-F \033[4mfamily\033[0m] \ [-f \033[4mgroff fontname\033[0m] file1 file2 ... DESCRIPTION: @@ -79,9 +79,13 @@ -H Long help. - -l Assume prefix /usr/local/ for all directories. (default) + -l Assume prefix /usr/local/share/groff for all directories. (default) - -s Assume prefix /usr/ for all directories. + -s Assume prefix /usr/share/groff for all directories. + + -P \033[4mdir\033[0m + Path to the top-level groff directory if groff has been + installed in a non-default location. -c Copy file(s) named on the command line to a system-accessible location. If neither -s nor -C is given, copy to the family @@ -93,6 +97,9 @@ If neither -c nor -C is given, a prompt asks whether to copy the file(s) named on the command line. + -n Don't copy file(s) named on the command line to a system-accessible + location. + -d Make font available to gropdf. -D Do not make font available to gropdf. @@ -158,18 +165,6 @@ ;; esac -# need write access to /usr/ and /usr/local/ - -if [ "$UID" -ne "$ROOT_UID" ] ; then - scriptname=`basename $0` - printf \ -"Superuser priviledges required.\nRerun as \ -'\033[33msudo ${scriptname} \033[4margs\033[0m' \ -or \ -'\033[33msu root -c \"${scriptname} \033[4margs\033[0m\033[33m\"\033[0m'\n" - exit 126 -fi - # if fontforge not installed, no point going any further type fontforge > /dev/null 2>&1 || { @@ -471,7 +466,7 @@ : } -while getopts ":C:cdDF:f:hHlps" opt +while getopts ":C:cndDF:f:hHlpP:s" opt do case "$opt" in c) @@ -484,6 +479,9 @@ copy_dir=${OPTARG} [ -d ${copy_dir} ] || error no_dir ;; + n) + dont_copy=yes + ;; d) install_in_devpdf=yes ;; @@ -520,6 +518,11 @@ l) loc_or_sysdir=/usr/local/share/groff ;; + P) + option=P + check_optarg + loc_or_sysdir=${OPTARG} + ;; p) alias mv='mv -i' alias ln='ln -i' @@ -550,6 +553,19 @@ exit 1 } +if [ ! -w "$loc_or_sysdir" ] ; then + # need write access to $loc_or_sysdir + + scriptname=`basename $0` + printf \ +"You don't have write access to ${loc_or_sysdir} +Superuser priviledges required.\nRerun as \ +'\033[33msudo ${scriptname} \033[4margs\033[0m' \ +or \ +'\033[33msu root -c \"${scriptname} \033[4margs\033[0m\033[33m\"\033[0m'\n" + exit 126 +fi + devps=${loc_or_sysdir}/${version}/font/devps devpdf=${loc_or_sysdir}/${version}/font/devpdf site_font_devps=${loc_or_sysdir}/site-font/devps @@ -629,24 +645,25 @@ # copy input file to a system or named directory - if [ ! "$copy_orig" ] ; then - printf \ -"Copy \033[36m${file}\033[0m to ${copy_dir}/${family}/?\n (y/n; default = n) " - read copy_file + if [ ! "$dont_copy" ] ; then + if [ ! "$copy_orig" ] ; then + printf \ + "Copy \033[36m${file}\033[0m to ${copy_dir}/${family}/?\n (y/n; default = n) " + read copy_file - case "$copy_file" in - Y | y | YES | Yes | yes) - copy_file - ;; - * ) - printf \ -"Install \033[36m${file}\033[0m manually to make it available system-wide.\n" - ;; - esac - else - copy_file + case "$copy_file" in + Y | y | YES | Yes | yes) + copy_file + ;; + * ) + printf \ + "Install \033[36m${file}\033[0m manually to make it available system-wide.\n" + ;; + esac + else + copy_file + fi fi - unset append_style unset ext unset font