diff options
author | Chris Severance | 2015-08-07 12:28:35 -0400 |
---|---|---|
committer | Chris Severance | 2015-08-07 12:28:35 -0400 |
commit | f2abf45a1ee0380ae5a28517bc2539b2f0d64bfb (patch) | |
tree | 01cfbc94e0fe875f5083d526ccbe9a5b222e5673 /PKGBUILD | |
parent | 46aff6896e80489c9e6e414f9a572d4509ff8a12 (diff) | |
download | aur-f2abf45a1ee0380ae5a28517bc2539b2f0d64bfb.tar.gz |
PKGBUILD improvements
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 391 |
1 files changed, 172 insertions, 219 deletions
@@ -12,34 +12,44 @@ # Build instructions: (Skip these first two sections) # This only applies if you installed a long time ago when this driver would still -# compile and haven't upgraded in a while. Now this can't be built on Arch without a +# compile and haven't upgraded in a while. Now this can't be built on Arch without a # patch so new users skip to the next section. # This PKGBUILD does not clean up the slop from the Digi supplied make. # If you have already installed according to the the instructions -# log on as root and go through the process in reverse from the original +# log on as root and go through the process in reverse from the original # unmodified Digi tgz. You won't lose your configuration. # make preuninstall; make uninstall # To clean up you may want to remove the folders /share/ and /etc/init.d/ # Arch Linux does not use these folders though they may have spurious files from # other misdirected installs. +# If you have a configuration: mv "/etc/dgrp.backing.store" "/etc/dgrp.backing.store.pacsave" +# The new Install will pick it up automatically. # The next section: ... Now onto the real install ... +# Edit PKGBUILD.local after the first run +[ ! -s 'PKGBUILD.local' ] && cat > 'PKGBUILD.local' << EOF # Set the mode for all created devices. -_opt_defaultmode="0666" # default: 0600 +_opt_defaultmode="0600" # default: 0600 # If you need more granular control. # See http://www.digi.com/support/kbase/kbaseresultdetl?id=3048 # Once set copy /etc/udev/rules.d/10-dgrp.rules to the PKGBUILD folder # and it will be made into the package. -# sudo must be configured and available to the user account -# In (non root) user account: download PKGBUILD into a new folder -# using any method: cower or any AUR helper, wget, web browser, copy through network, or paste into PuTTY -# makepkg -sCcfi +_opt_LocktoKernel=1 # Default 1 +# 1=Automatic uninstall on every kernel upgrade. Use supplied AutoRebuild to reinstall on next login. +# 0=Allow kernel upgrades without removing dgrp. Use supplied AutoRebuild to update on next login. -# Since the kernel module isn't loaded until you have an active -# device, these services are automatically enabled and started +# Digi's product name is inconsistent. Here you can choose. RealPort seems the most popular. +_opt_RealPort='RealPort' # Can also be Realport +EOF +source 'PKGBUILD.local' + +# Recommended build command: makepkg -sCcfi + +# Since the kernel module isn't loaded until you have a device +# configured, these services are automatically enabled and started # for immediate hardware support. They will be reenabled each time the # package is installed or upgraded. # systemctl enable dgrp_daemon.service @@ -63,207 +73,155 @@ _opt_defaultmode="0666" # default: 0600 # The man page for dgrp_cfg_node lacks some detail. See this page for more info # ftp://digiftp.digi.com/support_archive/support/manuals/psts/rp-linux-conf-managing-portservers-with-dgrp-config-node.html -# To get your equipment up faster on servers that don't have Xwindows installed +# To get your equipment up faster on servers that don't have X installed # I've supplied a console shell script "drpadmin". -# It is adapted from Digi's RealPort "drpadmin" for Sun, HP UX, and SCO and has the same +# It is adapted from Digi's RealPort "drpadmin" for Sun, HP UX, and SCO and has the same # look and feel. # For information about using dgrp_ditty.service to maintain your ditty settings # across reboots see http://www.digi.com/support/kbase/kbaseresultdetl?id=904 -# make install and other commands described in the release notes -# only build properly in the Arch environment when you first run -# "makepkg -sC" to unpack the source allowing this PKGBUILD to patch the build files. - -# makepkg switches: -# -s = build package -# -C = erase source and rebuild from scratch. This is important because once -# built it is locked to your booted kernel version. When the kernel -# changes the package is worthless and you must boot the new kernel and -# rebuild from scratch. Rebuild automation is provided. -# -f = force overwrite of already built package. When the kernel changes the -# the package is worthless. -# -c = erase work folders when done -# -i = install or upgrade package after build. - -# Leave "-c -i" off if you'd like to perform the make and install yourself -# using "make install" as described in the release notes. - -# If you opt out of the Arch Linux package you must -# sudo make install -# sudo make postinstall -# You will need to construct your own startup environment. -# The BSD init scripts run just fine. They just don't launch automatically -# in systemd. For startup I use @reboot in cron (cronie) to launch a shell -# script in ~root with these commands: -# #!/bin/sh -# sleep 5 # wait for network and other services to start -# /etc/init.d/dgrp_daemon start # This submits configured interfaces to the kernel module -# /etc/init.d/dgrp_ditty start # this sets configured baud rates and other ditty-rp settings for the ports -# You won't get a graceful shutdown on reboot. - -# In general for any manual upgrade you will need to: -# sudo make preuninstall # this shuts down all of your interfaces which unloads the kernel module. - # Then the UDEV module is removed. The config file is not erased. -# sudo make uninstall # This removes the old executables, man pages, and other Digi files -# sudo mandb # this removes the Digi man page summaries from "man -k". -# (don't do this) "./configure" # this rebuilds the makefiles with the new kernel version -# (don't do this) "sudo make all" # this builds all the new executables -# (do this instead) "makepkg -sC" # This modifies some files for the Arch Linux package, runs the above two commands, makes a package, then modifies the makefiles for "make install" -# sudo make install # this installs all the executables -# sudo mandb # this adds the Digi man page summaries and any other missing summaries to "man -k" -# sudo make postinstall # this installs the UDEV module and starts any configured interfaces and the kernel module. -# Adjust your daemon startup as necessary. The @reboot option in cron (cronie) is one choice, see above. - -# Note that the kernel module is not loaded until you configure at least one interface. -# When your last interface is uninit the kernel module will be unloaded. - -# The manual install will not give you a systemd init script and installs unnecessary -# files and is a bunch of work to rebuild every time the kernel changes. - -# How about we don't do that and use the Arch Linux package instead. - -# The Arch Linux package gives you -# * systemd init scripts -# * Only installs the right files -# * Automatic removal on kernel upgrade -# * Automatic rebuild and start on next login - -# Uninstall cleanup: -# rm /etc/dgrp.backing.store /usr/bin/dgrp/config/ditty.commands +# UnInstall cleanup: +# rm /etc/dgrp.backing.store* /usr/bin/dgrp/config/ditty.commands # rmdir /usr/bin/dgrp/config # rmdir /usr/bin/dgrp -# If Digi releases a new version then all you need to change is -# pkgver, source, and possibly _pkgnamever -# Then run "updpkgsums" to get new md5sums - ############################### Arch PKGBUILD ################################# set -u pkgname='dgrp' -_pkgnamever="${pkgname}-1.9" # this is the folder name inside the supplied tgz. It should be ${pkgname}-$pkgver but Digi didn't do that. pkgver='1.9.35' pkgrel=1 -_RealPort='RealPort' # Digi's product name is inconsistent. Here you can choose. RealPort seems right so I didn't complete the change to Realport. -pkgdesc=("tty driver for Digi ${_RealPort} Connect EtherLite Flex One CM PortServer IBM RAN") -_pkgdescshort="Digi ${_RealPort} driver for Ethernet serial servers" +pkgdesc=("tty driver for Digi ${_opt_RealPort} Connect EtherLite Flex One CM PortServer IBM RAN") +#_pkgdescshort="Digi ${_opt_RealPort} driver for Ethernet serial servers" # For when we used to generate the autorebuild from here arch=('i686' 'x86_64') url='http://www.digi.com/' -license=('GPL' 'APACHE' 'custom:DigiInternational') -makedepends=('linux-headers' 'openssl' 'sudo') # openssl in in Arch Linux "base" - -_lock_to_kernel=1 - -# Locking to a kernel is only necessary if we must manually uninstall before -# upgrading the kernel. Kernel locking makes upgrades impossible. Without a -# lock the service will stop before the reboot, and not start on the next boot. -# We'll sense the missing kernel module and the upgrade will remove the -# old kernel module and install the new one. The upgrade will start the kernel -# module. -_kernelversionsmall="`uname -r | cut -d - -f 1`" -if [ "${_lock_to_kernel}" -ne 0 ]; then - depends=("linux=${_kernelversionsmall}" 'openssl') -else - depends=('linux' 'openssl') - backup=('etc/dgrp.backing.store') # don't do this if you kernel lock or your config will be lost on upgrade -fi -conflicts=("linux>${_kernelversionsmall}" "linux<${_kernelversionsmall}") +license=('GPL' 'custom') # OpenSSL=Apache. Arch is always new enough to not need their version. +makedepends=('linux-headers') +depends=('openssl' 'grep' 'awk' 'systemd') +backup=('etc/dgrp.backing.store') optdepends=('tcl: digi config manager in X' 'tk: digi config manager in X') -source=("${pkgname}-${pkgver}-81000137_W.tgz::http://ftp1.digi.com/support/driver/81000137_W.tgz" 'drpadmin' 'drpadmin.1' 'autorebuild-dgrp.sh') +source=("${pkgname}-${pkgver}-81000137_W.tgz::http://ftp1.digi.com/support/driver/81000137_W.tgz" 'drpadmin' 'drpadmin.1' "autorebuild-${pkgname}.sh") sha256sums=('218c3a873f8623d2e663735efdee384f7dac784327cea9e7211eddce700fe1c8' '1ab0ccdc361760ae078f9b69f603e99b40849cdf97ad69bb028ad6af27012634' '66f8b106a052b4807513ace92978e5e6347cef08eee39e4b4ae31c60284cc0a3' - 'dde3d60179c465696370aa493a5b9f0ba2e5189e56cfc51439cfcca38f66bad5') + 'b42eb7588448d9655fa28c39e0f2c24ebe0c2897dd427521173000c178317bc2') options=('!docs' '!emptydirs') install="${pkgname}-install.sh" -_autorebuild="autorebuild-${pkgname}.sh" -_autorebuildsenseexe="/usr/lib/modules/\`uname -r\`/misc/dgrp.ko" prepare() { - set - - cd "${_pkgnamever}" - ./configure # --prefix=/usr # this didn't work - - # Produce an Arch compatible Makefile - if [ ! -f 'Makefile.inc.Arch' ]; then - echo "# patched by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR" > 'Makefile.inc.Arch' - echo '# http://aur.archlinux.org/' >> 'Makefile.inc.Arch' - echo 'prefix=/usr' >> 'Makefile.inc.Arch' - echo '' >> 'Makefile.inc.Arch' - cat 'Makefile.inc' >> 'Makefile.inc.Arch' - sed -i -e 's:/usr/sbin:/usr/bin:g' 'Makefile.inc.Arch' - fi - cp -p 'Makefile.inc.Arch' 'Makefile.inc' + set -u + cd dgrp-*/ + rm -f daemon/openssl-*.tar.gz # I don't want their version to build if OpenSSL version detection fails in the future + # Standardize name of RealPort + sed -i -e "s/RealPort/${_opt_RealPort}/gI" $(grep -lrF $'RealPort\nRealport' .) + # grep -ri realport . | grep -vF $'RealPort\nRealport' + sed -i -e '# Cosmetic fix for gcc v5' \ + -e 's:\(3.9\*|4.\*\))$:\1|5.*):g' \ + -e "# I can't find any other way to fix the modules dir" \ + -e 's:/lib/modules/:/usr&:g' \ + 'configure' + # Eradicate sbin before we even get started + sed -i -e 's:/usr/sbin:/usr/bin:g' -e 's:/sbin/:/usr/bin/:g' 'configure' Makefile* */Makefile scripts/{preun,post}install + # Fix the installers. We do in PKBGUILD what we can and the just a little in install. + # cp -p 'scripts/postinstall' 'scripts/postinstall.Arch' # DEBUG for comparison + sed -i -e '# Some security for root' \ + -e 's:^#!\s*/bin/sh$:&\nif [ "${EUID}" -ne 0 ]; then\n echo "Must be root!"\n exit 1\nfi:g' \ + -e '# Remove Install noise' \ + -e 's:^\(\s*\)\(echo "Running\):\1#\2:g' \ + -e '# Block the usage of chkconfig' \ + -e 's:/usr/bin/chkconfig:/usr/bin/true:g' \ + -e '# Remove noise for defunct chkconfig' \ + -e 's:^\(\s\+\)\(echo "Added\):\1#\2:g' \ + -e '# Automatically bring back pacsave file on reinstall' \ + -e 's:^if \[ -f /etc/dgrp:if [ -s "/etc/dgrp.backing.store.pacsave" -a ! -s "/etc/dgrp.backing.store" ]; then\n mv "/etc/dgrp.backing.store.pacsave" "/etc/dgrp.backing.store"\nfi\n&:g' \ + -e '# No need to upgrade and back up a blank file' \ + -e 's:-f \(/etc/dgrp.backing.store\):-s \1:g' \ + -e '# Why depend on /tmp when we can use the /etc folder which is where admin will be looking to fix their non working hardware' \ + -e 's:/tmp/dgrp/dgrp.backing.store:/etc/dgrp.backing.store:g' \ + -e '# The rest is done in package.' \ + -e 's:^echo "Checking:exit 0\n&:g' \ + -e '# Prepare the links for package to use them' \ + -e 's:^\(\s\+\)ln -s /usr/bin/\([^ ]\+\) \(.\+\)$:\1ln -sf "\2" "${_DESTDIR}\3":g' \ + -e "# All that's left is config conversion" \ + 'scripts/postinstall' + #cp -p 'scripts/preuninstall' 'scripts/preuninstall.Arch' # For comparison + sed -i -e '# Some security for root' \ + -e 's:^#!\s*/bin/sh$:&\nif [ "${EUID}" -ne 0 ]; then\n echo "Must be root!"\n exit 1\nfi:g' \ + -e '# Remove UnInstall noise' \ + -e 's:^\(\s*\)\(echo "Running\):\1#\2:g' \ + -e '# Block the usage of chkconfig' \ + -e 's:/usr/bin/chkconfig:/usr/bin/true:g' \ + -e '# Remove more noise' \ + -e 's:^\(\s\+\)\(echo "Removed\):\1#\2:g' \ + -e '# No need to sleep. The daemons are shut down by systemd' \ + -e 's:^sleep :#&:g' \ + -e '# pacman handles the links and files' \ + -e 's;if \[ -L ;if ! : \&\& [ -L ;g' \ + -e 's;^\(\s*\)\(rm -f \);\1: #\2;g' \ + -e '# Fixing this file was almost useless. All it does after we disable everything is an rmmod' \ + 'scripts/preuninstall' + test ! -f 'scripts/postinstall.Arch' -a ! -f 'scripts/preuninstall.Arch' + ./configure -q --sbindir='/usr/bin' --prefix='/usr' --mandir='/usr/share/man' # the module and DESTDIR-RPM_BUILD_ROOT dirs seem unsettable so are handled elsewhere # Produce a "file_locations" that we can pull in here. - if [ ! -f 'config/file_locations.Arch' ]; then - echo "# patched by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR" > 'config/file_locations.Arch' - sed -e 's/^DGRP/_DGRP/g' 'config/file_locations' >> 'config/file_locations.Arch' - fi - . 'config/file_locations.Arch' - - #export mandir=/usr/share/man - #export CFLAGS="$CFLAGS -DTTY_CLOSING=7" - #export MYMANDIR=/usr/share/man # didn't work - #sed -i -e 's/CPPFLAGS =/CPPFLAGS = -DTTY_CLOSING=7/g' Makefile # didn't work - #sed -i -e 's/MANDIR=.*$/MANDIR = \/usr\/share\/man/g' Makefile.inc # didn't work - #sed -i -e 's/-DDGRP_TRACER/-DDGRP_TRACER -DTTY_CLOSING=7/g' driver/build/Makefile.in # didn't work - #sed -i -e 's:\$(RPM_BUILD_ROOT)\$(MYMANDIR):/usr/share:g' driver/build/Makefile # I'm gonna get you, one way or another! - #sed -i -e 's:\$(MANDIR):/usr/share/man:g' */Makefile # these changes are all ignored. I'm not gonna... - - # /usr/sbin /sbin and /lib are deprecated as soft links and aren't permitted in packages - sed -i -e 's:/usr/sbin:/usr/bin:g' 'Makefile' */Makefile driver/*/Makefile - # sed will perform a replace on already replaced text, but only once. - # That doesn't make sense to me but I can get around it by ensuring - # the from string isn't in the to string and doing it twice. - sed -i -e 's:/lib/:/usr/lIb/:g' Makefile */Makefile driver/*/Makefile - sed -i -e 's:/lIb/:/lib/:g' Makefile */Makefile driver/*/Makefile - - # I'd like to use /usr/local/bin but I suspect that this change would be - # even more work than what I've already done and much to different from - # Digi's install. - - # Patch a source for a constant that has been removed from the kernel. - # Digi should fix this since it will eventually not work right. + #if [ ! -f 'config/file_locations.Arch' ]; then + # echo "# for ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR" > 'config/file_locations.Arch' + # sed -e 's/^DGRP/local _&/g' 'config/file_locations' >> 'config/file_locations.Arch' + #fi + #. 'config/file_locations.Arch' + + # Patch a source for a constant that has been removed from the kernel. + # Digi should patch this constant away since whatever it does will eventually not work. # See https://lkml.org/lkml/2014/10/16/632 [PATCH -next 09/27] tty: Remove TTY_CLOSING - LKML.ORG # See http://lkml.iu.edu/hypermail/linux/kernel/1411.0/03202.html [PATCH -next v2 09/26] tty: Remove TTY_CLOSING - echo '' >> 'driver/build/include/dgrp_net_ops.h' - echo "/* patched by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR */" >> 'driver/build/include/dgrp_net_ops.h' - echo '/* http://aur.archlinux.org/ */' >> 'driver/build/include/dgrp_net_ops.h' - echo '#ifndef TTY_CLOSING' >> 'driver/build/include/dgrp_net_ops.h' - echo '#define TTY_CLOSING (7)' >> 'driver/build/include/dgrp_net_ops.h' - echo '#endif' >> 'driver/build/include/dgrp_net_ops.h' + cat >> 'driver/build/include/dgrp_net_ops.h' << EOF +/* patched by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR */ +/* http://aur.archlinux.org/ */ +#ifndef TTY_CLOSING +#define TTY_CLOSING (7) +#endif +EOF set +u } build() { - set - - cd "${_pkgnamever}" - . 'config/file_locations.Arch' - - # The instructions say we can only use pkgdir in package() but fortunately it exists here - # This bit of magic might work on other RPM based commercial drivers - echo "RPM_BUILD_ROOT=${pkgdir}" > 'Makefile.inc' - cat 'Makefile.inc.Arch' >> 'Makefile.inc' - make all -s -j $(nproc) - # This package doesn't seem to support threaded make + set -u + cd dgrp-*/ + #. 'config/file_locations.Arch' + make all -s # -j $(nproc) # This package doesn't support threaded make and it's too small to fix set +u } -_daemons='daemon ditty' +_daemons=('daemon' 'ditty') package() { - set - - cd "${_pkgnamever}" - . 'config/file_locations.Arch' - make install - # Leave the user with a properly modified Makefile.inc so the make commands in - # the release notes mostly work in the Arch environment. - cp -p 'Makefile.inc.Arch' 'Makefile.inc' - - if [ "${_opt_defaultmode}" != '' ]; then - mv "${pkgdir}/tmp/dgrp/10-dgrp.rules" "${pkgdir}/tmp/dgrp/10-dgrp.rules.Arch" - cat > "${pkgdir}/tmp/dgrp/10-dgrp.rules" << EOF + set -u + cd dgrp-*/ + #. 'config/file_locations.Arch' + + # I don't want Linux version info showing on AUR web. After a few months 'linux<0.0.0' makes it look like an out of date package. + local _kernelversionsmall="$(uname -r)" + _kernelversionsmall="${_kernelversionsmall%%-*}" + conflicts=("linux>${_kernelversionsmall}" "linux<${_kernelversionsmall}") + if [ "${_opt_LocktoKernel}" -ne 0 ]; then + depends+=("linux=${_kernelversionsmall}") + else + depends+=('linux') # Prevent installation into Docker + fi + + make -s RPM_BUILD_ROOT="${pkgdir}" install + install -m644 'dinc/dinc.1' -t "${pkgdir}/usr/share/man/man1/" # They bypass the Makefile that does this + chmod 644 "${pkgdir}/usr/bin/dgrp/config"/{dgrp.gif,file_locations} + chmod 744 "${pkgdir}/usr/bin/"{dgelreset,dgipserv} + # Create the links, customized for us by prepare above + _DESTDIR="${pkgdir}" sh -eu <(grep 'ln -sf ' 'scripts/postinstall') + #rmdir "${pkgdir}/usr/share/doc" # The Arch PKGBUILD does this for us + + # Prepend our message on the udev rules file + install -dm755 "${pkgdir}/etc/udev/rules.d/" + touch "${pkgdir}/${backup[0]}" # postinstall handles the pacsave file automatically + chmod 644 "${pkgdir}/${backup[0]}" + cat > "${pkgdir}/etc/udev/rules.d/10-dgrp.rules" << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR # http://aur.archlinux.org/ @@ -282,38 +240,31 @@ package() { # Then copy this file into the folder with PKGBUILD. +$(cat "${pkgdir}/tmp/dgrp/10-dgrp.rules") EOF - cat "${pkgdir}/tmp/dgrp/10-dgrp.rules.Arch" >> "${pkgdir}/tmp/dgrp/10-dgrp.rules" - rm -f "${pkgdir}/tmp/dgrp/10-dgrp.rules.Arch" - sed -i -e 's:^\(KERNEL=="tty_dgrp\)\(.*\)$:\1\2, MODE="'"${_opt_defaultmode}"'":g' "${pkgdir}/tmp/dgrp/10-dgrp.rules" - cp -p "${srcdir}/10-dgrp.rules" "${pkgdir}/tmp/dgrp/10-dgrp.rules" || : + rm -f "${pkgdir}/tmp/dgrp/10-dgrp.rules" + rmdir "${pkgdir}/tmp/dgrp" "${pkgdir}/tmp" # errors out if other files ever show up in /tmp/dgrp + if [ ! -z "${_opt_defaultmode:-}" ]; then + sed -i -e 's:^\(KERNEL=="tty_dgrp\)\(.*\)$:\1\2, MODE="'"${_opt_defaultmode}"'":g' "${pkgdir}/etc/udev/rules.d/10-dgrp.rules" + fi + if [ -s "${srcdir}/../10-dgrp.rules" ]; then + cp "${srcdir}/../10-dgrp.rules" "${pkgdir}/etc/udev/rules.d/10-dgrp.rules" # no cp -p in case this file has any wrong user:group fi + chmod 644 "${pkgdir}/etc/udev/rules.d/10-dgrp.rules" - # we need this to be safe just in case this points to the real /etc instead of pkg/etc as we expect - # as non root we'll be unable to erase any of these things from the real /etc. On Arch Linux none will exist anyways - mv -n "${pkgdir}/etc/init.d/dgrp_daemon" "${pkgdir}/etc/init.d/dgrp_ditty" "${pkgdir}/usr/bin/dgrp/daemon/" - rm -f "${pkgdir}/etc/init.d/dgrp_daemon" "${pkgdir}/etc/init.d/dgrp_ditty" - rmdir "${pkgdir}/etc/init.d" "${pkgdir}/etc" - chmod 1777 "${pkgdir}/tmp" # /tmp is not allowed in packages. We're not making a binary distro so having /tmp here shouldn't be a problem. - chmod 700 "${pkgdir}/usr/bin/dgelreset" "${pkgdir}/usr/bin/dgipserv" "${pkgdir}/usr/bin/dgrp/config/postinstall" "${pkgdir}/usr/bin/dgrp/config/preuninstall" - # It's not really clear to me why these are in the man pages but not in the path so you can use them. - cd "${pkgdir}/usr/bin" - for _exes in 'dgrp_cfg_node' 'dgrp_gui'; do - ln -s "dgrp/config/${_exes}" "${_exes}" - done - # ditty: You might need this if you have scripts that depend on ditty. It is commented out in case you have another ditty on your system. - # ln -s ditty-rp ditty - #rmdir "${pkgdir}/usr/share/doc" # The Arch PKGBUILD does for us + install -Dpm755 "${pkgdir}/etc/init.d"/{dgrp_daemon,dgrp_ditty} -t "${pkgdir}/usr/bin/dgrp/daemon/" + rm -f "${pkgdir}/etc/init.d"/{dgrp_daemon,dgrp_ditty} + rmdir "${pkgdir}/etc/init.d" - # systemd integration. Umask is 000 on my system. I don't know how makepkg gets the right permissions on this mkdir. - mkdir -p "${pkgdir}/usr/lib/systemd/system/" + # systemd integration. + install -dm755 "${pkgdir}/usr/lib/systemd/system/" local _daemon - for _daemon in ${_daemons}; do - cat > "dgrp_${_daemon}.service" << EOF + for _daemon in "${_daemons[@]}"; do + cat > "${pkgdir}/usr/lib/systemd/system/dgrp_${_daemon}.service" << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR # http://aur.archlinux.org/ [Unit] -Description="Digi ${_RealPort} ${_daemon}" +Description="Digi ${_opt_RealPort} ${_daemon}" After=network.target [Service] @@ -325,25 +276,22 @@ ExecReload=/usr/bin/dgrp/daemon/dgrp_${_daemon} reload [Install] WantedBy=multi-user.target EOF - install -m 644 "dgrp_${_daemon}.service" "${pkgdir}/usr/lib/systemd/system/" - rm -f "dgrp_${_daemon}.service" + chmod 644 "${pkgdir}/usr/lib/systemd/system/dgrp_${_daemon}.service" done - # Install my custom drpadmin with man page. This automatically detects if the files aren't provided. - sed -i -e "s/RealPort/${_RealPort}/gI" "${pkgdir}/usr/share/man/man8/"*.8 "${pkgdir}/usr/share/man/man1/"*.1 - if [ -s "${srcdir}/drpadmin" ]; then - install -Dm755 "${srcdir}/drpadmin" "${pkgdir}/usr/bin/" - sed -i -e 's/^#distro=:::$/distro="Arch Linux"/g' \ - -e "s/RealPort/${_RealPort}/gI" "${pkgdir}/usr/bin/drpadmin" - if [ -s "${srcdir}/drpadmin.1" ]; then - install -Dm444 "${srcdir}/drpadmin.1" "${pkgdir}/usr/share/man/man1/" - sed -i -e "s/RealPort/${_RealPort}/gI" "${pkgdir}/usr/share/man/man1/drpadmin.1" - fi - fi + # Install my custom drpadmin with man page. + install -Dm755 "${srcdir}/drpadmin" -t "${pkgdir}/usr/bin/" + sed -i -e 's/^#distro=:::$/distro="Arch Linux"/g' \ + -e "s/RealPort/${_opt_RealPort}/gI" "${pkgdir}/usr/bin/drpadmin" + install -Dm444 "${srcdir}/drpadmin.1" -t "${pkgdir}/usr/share/man/man1/" + # Standardize name of RealPort in man pages + sed -i -e "s/RealPort/${_opt_RealPort}/gI" "${pkgdir}/usr/share/man/man8/"*.8 "${pkgdir}/usr/share/man/man1/"*.1 + set +u } +# We generate this file because we have no other way to have adjustable content _geninstall() { -# produce the install script so it doesnt need to be downloaded separately +# produce the Install script so it doesn't need to be downloaded separately # I'm wondering why there isn't a function for this. cat > "${install}" << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR @@ -352,15 +300,16 @@ cat > "${install}" << EOF post_upgrade() { set -u mandb -q - /usr/bin/dgrp/config/postinstall # this runs depmod -a - rmdir '/tmp/dgrp' # postinstall forgets to remove this. Useful on /tmp folders that are not mounted tmpfs + /usr/bin/dgrp/config/postinstall # this used to run depmod -a + depmod -a + # rmdir '/tmp/dgrp' # postinstall forgets to remove this. Useful on /tmp folders that are not mounted tmpfs systemctl daemon-reload # Digi's postinstall automatically loads the daemons so we might as well too - for _daemon in ${_daemons}; do + for _daemon in ${_daemons[@]}; do systemctl enable "dgrp_\${_daemon}.service" systemctl start "dgrp_\${_daemon}.service" done - echo "${_RealPort} (dgrp) startup scripts updated or installed" + #echo "${_opt_RealPort} (dgrp) startup scripts updated or installed" set +u } @@ -382,8 +331,11 @@ pre_remove() { pre_upgrade set -u . '/usr/bin/dgrp/config/file_locations' - if [ -f "\${DGRP_STORE}" ]; then - echo "To clean fully you may want to remove your config: \${DGRP_STORE}" + if [ -f "\${DGRP_STORE}.old" ]; then + echo "To clean fully you may want to remove your config backup: \${DGRP_STORE}.old" + fi + if [ -f "\${DGRP_STORE}.pacsave" ]; then + echo "To clean fully you may want to remove your config backup: \${DGRP_STORE}.pacsave" fi set +u } @@ -392,11 +344,12 @@ post_remove() { set -u mandb -q systemctl daemon-reload - echo "${_RealPort} (dgrp) startup scripts removed" + #echo "${_opt_RealPort} (dgrp) startup scripts removed" set +u } +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR EOF -chmod 644 "${install}" +chmod 644 "${install}" # " } _geninstall set +u |