diff options
author | Chris Severance | 2018-12-27 10:13:06 -0500 |
---|---|---|
committer | Chris Severance | 2018-12-27 10:13:06 -0500 |
commit | 763163f55e111c7c5ce6cf093141dd1bf5125f7e (patch) | |
tree | 6111ccd292094b76eacb9bcfe746452c2c95b63a | |
parent | 580a8b4aa9812f2a5c3b4958c2d7f5a427707176 (diff) | |
download | aur-763163f55e111c7c5ce6cf093141dd1bf5125f7e.tar.gz |
autu: Update to 3.8.C-1 rename cups binaries
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 415 |
2 files changed, 340 insertions, 79 deletions
@@ -1,5 +1,5 @@ # Generated by mksrcinfo v8 -# Sun Dec 16 01:50:28 UTC 2018 +# Thu Dec 27 15:13:06 UTC 2018 pkgbase = lprng-cups pkgdesc = an enhanced, extended, and portable implementation of the Berkeley LPR lpd print spooler functionality that coexists with CUPS pkgver = 3.8.C @@ -20,8 +20,8 @@ pkgbase = lprng-cups optdepends = foomatic-filters-lprng: foomatic-rip in filters (foofilter) optdepends = hplip: drivers for HP printers optdepends = ifhp: filters for many printers - optdepends = cups: standard BSD binaries lp lpr lpq optdepends = lprng: install this instead for standard BSD binaries lp lpr lpq without cups + optdepends = cups: standard BSD binaries lp lpr lpq provides = lprng=3.8.C conflicts = lprng options = !strip @@ -9,8 +9,25 @@ # TODO: We shouldn't be the ones to rename the binaries. Upstream should implement EXEEXT. # TODO: Are there better versions of these old filters? +# Renaming cups binaries has race conditions where binaries are bogus or missing for a short time. + +set -u + _opt_SSL10=1 +_primarylpr=0 # Can be changed between installs +# 0 - cups binaries with original name lp lpr lpq, alternate names for lprng +# 1 - lprng binaries with original name lp lpr lpq, alternate names for cups +# Final test: install 0 twice, install 1 twice, install cups, install 0 twice + +# suffix for conflicting binaries: lpr -> lprng so tab completion will find it +# Can be changed between installs. +if [ "${_primarylpr}" -eq 0 ]; then + _sfx='ng' # sources contain EXEEXT but I couldn't get it to do anything. +else + _sfx='cups' +fi + # Need: Web based printcap editor, LPInfo? # https://github.com/apple/cups/issues/5269 @@ -23,11 +40,14 @@ _opt_SSL10=1 # and for automatic printing of PCL, PXL, PostScript and PDF. Neither # raw nor CUPS is going away so I fixed lprng to coexist with CUPS. +# printcap is also a lot easier to manage than CUPS. Text FTW! + # Gentoo solves this with a use flag that leaves out the lpr binaries from the cups package # https://packages.gentoo.org/useflags/lprng-compat # Debian/Ubuntu solves this with the conflicting binaries in a separate cups-bsd package. +# Unfortunately neither of these solutions allows using both cups and lprng command line tools. -# printcap is also a lot easier to manage than CUPS. Text FTW! +# Here we can rename either the cups binaries or the lprng binaries, whichever is easier to fix scripting. # As of Dec 2018 CUPS raw can be considered as already gone. # CUPS has two show stopper raw bugs that probably won't be fixed. @@ -67,12 +87,10 @@ _opt_SSL10=1 # ExecStart= # ExecStart=-/usr/lib/cups/daemon/cups-lpd -o job-sheets=none -o document-format=application/vnd.cups-raw -_sfx='ng' # sources contain EXEEXT but I couldn't get it to do anything. _spooldir='/var/spool/lpd' _printcap='/etc/lprng/printcap' _service='lpd.service' -set -u pkgname='lprng' pkgver='3.8.C' pkgrel='1' @@ -100,17 +118,41 @@ if [ ! -z "${_sfx}" ]; then provides=("lprng=${pkgver}") # a rather specious claim since we don't provide the binaries with the same name conflicts=('lprng') optdepends+=( - 'cups: standard BSD binaries lp lpr lpq' 'lprng: install this instead for standard BSD binaries lp lpr lpq without cups' ) + if [ "${_primarylpr}" -ne 0 ]; then + depends+=('cups') + else + optdepends+=( + 'cups: standard BSD binaries lp lpr lpq' + ) + fi else conflicts=('cups') + _primarylpr=0 fi backup=( 'etc/lprng/lpd/lpd.conf' 'etc/lprng/lpd/lpd.perms' "${_printcap#/}" ) +_mans=( + 'man1/cancel.1' + 'man1/lp.1' + 'man1/lpq.1' + 'man1/lpr.1' + 'man1/lprm.1' + 'man1/lpstat.1' + 'man8/lpc.8' +) +if [ "${_primarylpr}" -ne 0 ]; then + _bins=("${_mans[@]##*/}") + _bins=("${_bins[@]%%.*}") + _binscups=("${_bins[@]/#/usr\/bin/}") + _binscups=("${_binscups[@]/%/${_sfx}}") + backup+=("${_binscups[@]}") # minimize race conditions with cups binaries. Race conditions for man pages are of no concern. + unset _binscups +fi options=('!strip') install="${pkgname%%-*}.install" _srcdir="lprng-${pkgver}" @@ -150,22 +192,6 @@ sha256sums=('694a1747a96385b89e93f43343bf35cee5c8c73353a83814106911c99f09de10' 'faf52cf982eaa66a475344a5647a80a761d10402ccb9de263c70dc15ccc85c29' '47b48ab7fa15ae9226463c98d6c8fce9ee9b602c3a9f96907fcd84e50902b2cc') -# We can't modify .install but we can stop and force the user to fix it. -_install_check() { - local _ckvar - local _ckline - local _pkgname="${pkgname}" - for _ckvar in '_service' '_printcap'; do - _ckline="${_ckvar}='${!_ckvar}'" - if ! grep -q "^${_ckline}"'$' "${startdir}/${install}"; then - msg "${install} must be fixed" - echo "${_ckline}" - set +u - false - fi - done -} - prepare() { set -u cd "${_srcdir}" @@ -198,7 +224,6 @@ prepare() { build() { set -u - _install_check cd "${_srcdir}" if [ ! -s 'Makefile' ]; then @@ -228,7 +253,7 @@ build() { set +x fi set -x - make -s + make -s # -j"$(nproc)" set +x set +u } @@ -266,64 +291,300 @@ EOF # Make documentation easy to find ln -s "/usr/share/doc/${pkgname}" "${pkgdir}/etc/lprng/lpd/doc" + local _cdir="usr/lib/${pkgname}/cups" # This must be deleted when changing to _primarylpr=0 + local _scriptdir="/usr/share/${pkgname}" + local _script="${_scriptdir}/${pkgname}.sh" + + # Generate amended install + bash -n "${startdir}/${install}" || echo "${}" + true && install="${install}.pkg" + rm -f "${startdir}/${install}" + cat - <<<" +# Do not modify this copy + +_printcap='${_printcap}' +_service='${_service}' +_postinst='${_script}' # secondary needs this to clean up afer a primary -> secondary switch +_primarylpr='${_primarylpr}' # This is a post-upgrade setting sent to the pre-upgrade script +_cdir='${_cdir}' + +" "${startdir}/${install%.pkg}" > "${startdir}/${install}" + bash -n "${startdir}/${install}" || echo "${}" + + # Produce suffix cups or suffix lprng if [ ! -z "${_sfx}" ]; then - # lpd doesn't conflict with cups - #sed -e '/^ExecStart=/ s:lpd'":&${_sfx}:g" -i "${pkgdir}/usr/lib/systemd/system/${_service}" - # Rename programs and change self references in man pages - local _moveem=( - 'man1/cancel.1' - 'man1/lp.1' - 'man1/lpq.1' - 'man1/lpr.1' - 'man1/lprm.1' - 'man1/lpstat.1' - 'man8/lpc.8' - ) - pushd "${pkgdir}/usr/bin" > /dev/null - local _f _fx - for _fx in "${_moveem[@]}"; do - _f="${_fx##*/}" - _f="${_f%%.*}" - mv "${_f}" "${_f}ng" - sed -e "s:\b${_f}\b:&${_sfx}:g" \ - -e "1,2 s:\b${_f^^}\b:&${_sfx}:g" \ - -i "${pkgdir}/usr/share/man/${_fx}" + if [ "${_primarylpr}" -ne 0 ]; then + pushd "${pkgdir}/usr/bin" + # Overwrite hard links with soft links + ln -sf 'lpr' 'lp' + ln -sf 'lprm' 'cancel' + local _ldir="usr/lib/${pkgname}/lprng" + local _cdir="usr/lib/${pkgname}/cups" + # folders to store conflicting lprng and cups files + install -d "${pkgdir}/${_ldir}"/{usr/bin,/usr/share/man/{man1,man8}} + # There's no way to do this without this folder of untracked files. + install -d "${pkgdir}/${_cdir}"/{usr/bin,/usr/share/man/{man1,man8}} + local _f + for _f in "${_bins[@]}"; do + mv "${_f}" "${pkgdir}/${_ldir}/usr/bin" + touch "${_f}${_sfx}" + done + local _zipmanlpr='.gz' # These need to be the same or cups will show untracked files + local _zipmancups='.gz' + cd "${pkgdir}/usr/share/man" + for _f in "${_mans[@]}"; do + mv "${_f}" "${pkgdir}/${_ldir}/usr/share/man/${_f}" + touch "${_f/./${_sfx}.}${_zipmancups}" + done + popd > /dev/null + + # Generate install helper script. + install -Dpm644 <(cat << EOF +#!/bin/sh + +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +set +e +set -u + +_opt_q='' + +$(declare -p _bins) +$(declare -p _mans) +_zipmancups='${_zipmancups}' +_zipmanlpr='${_zipmanlpr}' +_sfx='${_sfx}' +_ldir='${_ldir}' +_cdir='${_cdir}' +_primarylpr='${_primarylpr}' + +if [ "\${EUID}" -eq 0 ]; then + #_echo='' + _tp='/' + #_true='true ' +else + #_echo='' + _tp='../../../' + #_true='' +fi + +# -t to generate cups test files, test option only +# -c to install/upgrade cups +# -l to post-install lprng +# -p to pre-upgrade lprng +# -u to post-upgrade lprng +# -r to pre-remove lprng + +# Generate fake CUPS files in system folders +# This only works in the test folder. It is never called from the .install +_fn_gen_cups() { + if [ "\${EUID}" -ne 0 ]; then + local _f _c1 _c1 _c2 + for _f in "\${_bins[@]}"; do + _c1="\${_tp}usr/bin/\${_f}" + rm -f "\${_c1}" + dd if=/dev/urandom of="\${_c1}" bs=512 count=1 2> /dev/null done - # Overwrite hard links with soft links - ln -sf "lpr${_sfx}" "lp${_sfx}" - ln -sf "lprm${_sfx}" "cancel${_sfx}" - popd > /dev/null - # Rename man pages. - pushd "${pkgdir}/usr/share/man" > /dev/null - for _f in "${_moveem[@]}"; do - mv "${_f}" "${_f/./${_sfx}.}" + for _f in "\${_mans[@]}"; do + _c1="\${_tp}usr/share/man/\${_f}\${_zipmancups}" + rm -f "\${_c1}" + dd if=/dev/urandom of="\${_c1}" bs=512 count=1 2> /dev/null done - # Change references in man pages - sed -e "#s:\blpd\( \?\)(:lpd${_sfx}\1(:g" \ - -e "s:\blpr\( \?\)(:lpr${_sfx}\1(:g" \ - -e "s:\blprm\( \?\)(:lprm${_sfx}\1(:g" \ - -e "s:\blpc\( \?\)(:lpc${_sfx}\1(:g" \ - -e "s:\blp\( \?\)(:lp${_sfx}\1(:g" \ - -e "s:\blpq\( \?\)(:lpq${_sfx}\1(:g" \ - -i */* - sed -e "s:\blprm\b:&${_sfx}:g" \ - -e "s:\blpr\([ ,]\):lpr${_sfx}\1:g" \ - -e "#s:\blpd\([ ,)]\):lpd${_sfx}\1:g" \ - -e "s:\blpq\b:&${_sfx}:g" \ - -e "s:\blpc\b:&${_sfx}:g" \ - -i 'man5/printcap.5' 'man5/lpd.perms.5' 'man8/lpd.8' - sed -e "/^\.I/ s:\blprm\b:&${_sfx}:g" \ - -e "/^\.I/ s:\blpr\([ ,]\):lpr${_sfx}\1:g" \ - -e "/^\.I/ s:\blpd\([ ,)]\):lpd${_sfx}\1:g" \ - -e "/^\.I/ s:\blpq\b:&${_sfx}:g" \ - -e "/^\.I/ s:\blpc\b:&${_sfx}:g" \ - -i 'man8/lpcng.8' - sed -e "s:\blprm\b:&${_sfx}:g" -i 'man1/cancelng.1' - popd > /dev/null - # Change reference in printcap - sed -e "s: checkpc\b: sudo&:g" \ - -e "s: lpc\b:&${_sfx}:g" \ - -i "${pkgdir}/etc/lprng/printcap.sample" + fi +} + +# Copy cups files from system folders to _cdir with original names +_fn_store_cups() { + local _f _c1 _c2 + for _f in "\${_bins[@]}"; do + _c1="\${_tp}usr/bin/\${_f}" + _c2="\${_tp}\${_cdir}/usr/bin/\${_f}" + cp -pf "\${_c1}" "\${_c2}" + done + for _f in "\${_mans[@]}"; do + _c1="\${_tp}usr/share/man/\${_f}\${_zipmancups}" + _c2="\${_tp}${_cdir}/usr/share/man/\${_f}\${_zipmancups}" + cp -pf "\${_c1}" "\${_c2}" + done +} + +# Copy cups files to system folders with modified names +_fn_cp_cups() { + local _f _c1 _c2 + for _f in "\${_bins[@]}"; do + _c1="\${_tp}usr/bin/\${_f}\${_sfx}" + _c2="\${_tp}\${_cdir}/usr/bin/\${_f}" + cp -pf --remove-destination "\${_c2}" "\${_c1}" + done + for _f in "\${_mans[@]}"; do + _c1="\${_tp}usr/share/man/\${_f/./\${_sfx}.}\${_zipmancups}" + _c2="\${_tp}${_cdir}/usr/share/man/\${_f}\${_zipmancups}" + cp -pf --remove-destination "\${_c2}" "\${_c1}" + done +} + +# Erase modified name cups files in system folders +# This prevents .pacsave files +_fn_rm_cups() { + local _f _c1 _c2 + for _f in "\${_bins[@]}"; do + _c1="\${_tp}usr/bin/\${_f}\${_sfx}" + rm "\${_c1}" + done + for _f in "\${_mans[@]}"; do + _c1="\${_tp}usr/share/man/\${_f/./\${_sfx}.}\${_zipmancups}" + rm "\${_c1}" + done +} + +# Erase lprng files with original cups names in system folders. +# cp -f isn't erasing our soft links leading to cups lp -> lpr which isn't correct. +# cp --remove-destination fixed this +_fn_rm_lprng_cups() { + local _f _c1 _c2 + for _f in "\${_bins[@]}"; do + _c1="\${_tp}usr/bin/\${_f}" + rm "\${_c1}" + done + for _f in "\${_mans[@]}"; do + _c1="\${_tp}usr/share/man/\${_f}\${_zipmancups}" + rm "\${_c1}" + done +} + +# Erase original name cups files in _cdir +_fn_rm_cups_store() { + rm -rf "\${_tp}\${_cdir}/usr" +} + +# Copy cups files to system folders with original names +_fn_cp_cups_u() { + cp -dprf --remove-destination "\${_tp}${_cdir}/." "\${_tp}/" +} + +# Copy original name lpr files to system folders +_fn_cp_lpr() { + cp -dprf --remove-destination "\${_tp}${_ldir}/." "\${_tp}/" +} + +while getopts 'qtclp:u:r' opt; do + case "\${opt}" in + q) _opt_q='true ';; + t) _fn_gen_cups;; + c) + \${_opt_q} echo 'lprng: update cups' + _fn_store_cups + _fn_cp_lpr + _fn_cp_cups + ;; + l) + \${_opt_q} echo 'lprng: post-install lprng' + _fn_store_cups + _fn_cp_lpr + _fn_cp_cups + ;; + p) + \${_opt_q} echo 'lprng: pre-upgrade lprng' + #_fn_rm_lprng_cups + _fn_rm_cups + _fn_cp_cups_u + if [ "\${OPTARG}" -eq 0 ] && [ "\${_primarylpr}" -ne 0 ]; then + \${_opt_q} echo 'lprng: pre-upgrade remove cups store changing from primary to secondary' + _fn_rm_cups_store + fi + ;; + u) + \${_opt_q} echo 'lprng: post-upgrade lprng' + #This is *post* upgrade so we can't use the same method as pre-upgrade unless we pass forward the pre-upgrade _primarylpr + if [ ! -x "\${_cdir}/usr/bin/lpr" ]; then + \${_opt_q} echo 'lprng: post-upgrade add cups store changing from secondary to primary' + _fn_store_cups + fi + _fn_cp_lpr + _fn_cp_cups + ;; + r) + \${_opt_q} echo 'lprng: pre-remove lprng' + _fn_rm_cups + _fn_cp_cups_u + _fn_rm_cups_store + ;; + *) echo "Usage: \$0 [-c] [-l]"; exit 1 ;; + esac +done +EOF + ) "${pkgdir}${_script}" + test -s "${pkgdir}${_script}" || echo "${}" + bash -n "${pkgdir}${_script}" || echo "${}" + + # cups hook + install -Dm644 <(cat << EOF +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ +# Replace cups lpr tools with lprng tools +# cups tools are renamed +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = cups +[Action] +Description = Replace cups binaries with lprng +Depends = coreutils +When = PostTransaction +Exec = /usr/bin/bash "${_script}" -q -c +EOF + ) "${pkgdir}/usr/share/libalpm/hooks/${pkgname}-rename.hook" + else + # lpd doesn't conflict with cups + #sed -e '/^ExecStart=/ s:lpd'":&${_sfx}:g" -i "${pkgdir}/usr/lib/systemd/system/${_service}" + # Rename programs and change self references in man pages + pushd "${pkgdir}/usr/bin" > /dev/null + local _f _fx + for _fx in "${_mans[@]}"; do + _f="${_fx##*/}" + _f="${_f%%.*}" + mv "${_f}" "${_f}${_sfx}" + sed -e "s:\b${_f}\b:&${_sfx}:g" \ + -e "1,2 s:\b${_f^^}\b:&${_sfx}:g" \ + -i "${pkgdir}/usr/share/man/${_fx}" + done + # Overwrite hard links with soft links + ln -sf "lpr${_sfx}" "lp${_sfx}" + ln -sf "lprm${_sfx}" "cancel${_sfx}" + # Rename man pages. + cd "${pkgdir}/usr/share/man" + for _f in "${_mans[@]}"; do + mv "${_f}" "${_f/./${_sfx}.}" + done + # Change references in man pages + sed -e "#s:\blpd\( \?\)(:lpd${_sfx}\1(:g" \ + -e "s:\blpr\( \?\)(:lpr${_sfx}\1(:g" \ + -e "s:\blprm\( \?\)(:lprm${_sfx}\1(:g" \ + -e "s:\blpc\( \?\)(:lpc${_sfx}\1(:g" \ + -e "s:\blp\( \?\)(:lp${_sfx}\1(:g" \ + -e "s:\blpq\( \?\)(:lpq${_sfx}\1(:g" \ + -i */* + sed -e "s:\blprm\b:&${_sfx}:g" \ + -e "s:\blpr\([ ,]\):lpr${_sfx}\1:g" \ + -e "#s:\blpd\([ ,)]\):lpd${_sfx}\1:g" \ + -e "s:\blpq\b:&${_sfx}:g" \ + -e "s:\blpc\b:&${_sfx}:g" \ + -i 'man5/printcap.5' 'man5/lpd.perms.5' 'man8/lpd.8' + sed -e "/^\.I/ s:\blprm\b:&${_sfx}:g" \ + -e "/^\.I/ s:\blpr\([ ,]\):lpr${_sfx}\1:g" \ + -e "/^\.I/ s:\blpd\([ ,)]\):lpd${_sfx}\1:g" \ + -e "/^\.I/ s:\blpq\b:&${_sfx}:g" \ + -e "/^\.I/ s:\blpc\b:&${_sfx}:g" \ + -i "man8/lpc${_sfx}.8" + sed -e "s:\blprm\b:&${_sfx}:g" -i "man1/cancel${_sfx}.1" + popd > /dev/null + # Change reference in printcap + sed -e "s: checkpc\b: sudo&:g" \ + -e "s: lpc\b:&${_sfx}:g" \ + -i "${pkgdir}/etc/lprng/printcap.sample" + fi fi # Check for unwanted folders |