You are not logged in.

#1 2019-04-14 23:55:08

razerei
Member
Registered: 2019-04-14
Posts: 5
Website

PKGBUILD feedback request: brscan5

Hey all,
This is my first submission to the AUR, so I thought it'd be good to get some feedback since I'm so new to this. This is also hardware-dependent so I'll feel really lucky if anyone has a recent Brother scanner (like the ADS-1700W they sell at Best Buy right now) to also test if this works for them like it does for me.

Here's the repo (haven't pushed to AUR yet): https://github.com/dbernheisel/aur-brscan5

It's based on https://aur.archlinux.org/packages/brscan4 and brscan5 doesn't stray too much from what they did with the earlier version. I actually started with a copy/paste and then modified to the differences of brscan5 (Brother added a couple more linked libraries).

Here's the PKGBUILD for convenience:

# Maintainer: David Bernheisel <david@bernheisel.com>
# Based on the brscan4 PKGBUILD by Harey

license=('GPL' 'custom:Brother')
arch=('i686' 'x86_64')
pkgname=brscan5
pkgver=1.1.0_0
pkgrel=1
pkgdesc="SANE drivers from Brother for brscan5 compatible models"
depends=('sane' 'libusb-compat')
optdepends=('gtk2: for running brscan_gnetconfig')
url="http://support.brother.com"
install=brscan5.install

[ "$CARCH" = "x86_64" ] && pkg="dlf104036/${pkgname}-${pkgver/_/-}.x86_64.rpm" || pkg="dlf104035/${pkgname}-${pkgver/_/-}.i386.rpm"
[ "$CARCH" = "x86_64" ] && pkg_md5sum="5453ba052048780120a37d319cef1ce8" || pkg_md5sum="18988663fc0c958d12668ddee9e36bd5"

source=(
  "https://download.brother.com/welcome/$pkg"
  "http://www.brother.com/agreement/English_sane/agree.html"
  mk-udev-rules
)
md5sums=(
  $pkg_md5sum
  'ccffb9a6f6d436b21be25b0241068981'
  'ca07cab058b704b7b12ba076d00be2f0'
)

build() {
  cd "$srcdir"
  umask 022
  mkdir -p etc/udev/rules.d
  ./mk-udev-rules opt/brother/scanner/brscan5/{brscan5.ini,models/*.ini} > etc/udev/rules.d/40-$pkgname.rules
}

package() {
  cp -r $srcdir/etc $pkgdir
  cp -r $srcdir/opt $pkgdir
  cp -r $srcdir/usr $pkgdir

  install -D -m644 $srcdir/agree.html $pkgdir/usr/share/licenses/$pkgname/LICENSE.html

  mkdir -p $pkgdir/usr/lib/sane
  cd $pkgdir/usr/lib/sane
  mv $pkgdir/opt/brother/scanner/brscan5/*.so.1.0.7 .
  ln -sf libsane-brother5.so.1.0.7 libsane-brother5.so.1
  ln -sf libsane-brother5.so.1 libsane-brother5.so

  cd $pkgdir/usr/lib
  mv $pkgdir/opt/brother/scanner/brscan5/*.so.1.0.0 .
  ln -sf libLxBsNetDevAccs.so.1.0.0 libLxBsNetDevAccs.so.1
  ln -sf libLxBsNetDevAccs.so.1 libLxBsNetDevAccs.so

  ln -sf libLxBsDeviceAccs.so.1.0.0 libLxBsDeviceAccs.so.1
  ln -sf libLxBsDeviceAccs.so.1 libLxBsDeviceAccs.so

  ln -sf libLxBsScanCoreApi.so.1.0.0 libLxBsScanCoreApi.so.1
  ln -sf libLxBsScanCoreApi.so.1 libLxBsScanCoreApi.so

  ln -sf libLxBsUsbDevAccs.so.1.0.0 libLxBsUsbDevAccs.so.1
  ln -sf libLxBsUsbDevAccs.so.1 libLxBsUsbDevAccs.so
}

Offline

#2 2019-04-15 00:04:23

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: PKGBUILD feedback request: brscan5

Sources and checksums have architecture specific variables available (source_x86_64, etc). Use them.
The order of the metadata variables is kind of strange. Not a problem, but convention has them in a certain order.
cd "$srcdir" at the beginning of a function is a no-op.
Paths with variables that you don't control (like $pkgdir and $srcdir) could have spaces. Need quoted.
What's in brscan5.install?
Why in the world would you change umask?
Why are you changing the filename of the license?
udev rule should probably be in /usr, not in /etc
I would probably simplify the link creation with a loop.

Offline

#3 2019-04-15 00:23:20

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: PKGBUILD feedback request: brscan5

@Scimmia for convenience from https://github.com/dbernheisel/aur-brsc … n5.install

# new package version
devices_file="/opt/brother/scanner/brscan5/brsanenetdevice5.cfg"

pre_install() {
  /bin/true
}

# new package version
post_install() {
  echo "Find additional documentation about scanner driver install at:"
  echo "https://support.brother.com/g/s/id/linux/en/instruction_scn1.html"
  echo "For a network installation run the following as root:"
  echo "brsaneconfig5 -a name=\"Brother\" model=\"YOURMODELHERE\" ip=YOUR.SCANNER.IP.HERE"
  /opt/brother/scanner/brscan5/setupSaneScan5 -i
}

# the new package version
# old package version
pre_upgrade() {
  # If user has already configured their scanner then make a config backup
  if [ -f $devices_file ]; then
    cp $devices_file $devices_file.backup || return 1
  fi
}

# new package version
# old package version
post_upgrade() {
  # After upgrade revert user's scanner config and delete a config backup
  if [ -f $devices_file.backup ]; then
    cp $devices_file.backup $devices_file || return 1
    rm $devices_file.backup || return 1
  fi
}

# old package version
pre_remove() {
  /opt/brother/scanner/brscan5/setupSaneScan5 -e
  /bin/true
}

# old package version
post_remove() {
  /bin/true
}

Offline

#4 2019-04-15 00:28:44

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: PKGBUILD feedback request: brscan5

So that should all just go away, most likely.

Offline

#5 2019-04-15 02:15:44

razerei
Member
Registered: 2019-04-14
Posts: 5
Website

Re: PKGBUILD feedback request: brscan5

Thanks for the feedback!

- I didn't know about `md5sums_x86_64` and `md5sums_i686`. Neato. Updated
- Quoted the vars. thanks for catching that.
- I reordered the metadata based on what's in pkgbase. Thanks for pointing that out.
- Removed the "cd $srcdir" I don't know why that's there either. Carried over from brscan4.
- Removed the "umask 022" I don't know why that was needed. Carried over from brscan4.
- I thought it was convention for licenses to be named LICENSE.ext, but I guess it's also good to have it as-is from the source. I can change that back.
- I don't see any udev rules in /usr on my system, but after checking out the wiki on udev, you're right. I'll move them to /usr
- Are you saying that brscan5.install isn't needed at all? I removed some of the backup stuff that didn't seem to work anyway, and kept pre_remove() and post_install() to run brother's install/uninstall scripts.


Revised:

# Maintainer: David Bernheisel <david@bernheisel.com>
# Based on the brscan4 PKGBUILD by Harey

pkgname=brscan5
pkgver=1.1.0_0
pkgrel=1
pkgdesc="SANE drivers from Brother for brscan5 compatible models"
arch=('i686' 'x86_64')
license=('GPL' 'custom:Brother')
url="http://support.brother.com"
depends=('sane' 'libusb-compat')
optdepends=('gtk2: for running brscan_gnetconfig')
source=(
  "http://www.brother.com/agreement/English_sane/agree.html"
  mk-udev-rules
)
md5sums=(
  'ccffb9a6f6d436b21be25b0241068981'
  'ca07cab058b704b7b12ba076d00be2f0'
)
source_x86_64=("https://download.brother.com/welcome/dlf104036/${pkgname}-${pkgver/_/-}.x86_64.rpm")
md5sums_x86_64=('5453ba052048780120a37d319cef1ce8')
source_i686=("https://download.brother.com/welcome/dlf104035/${pkgname}-${pkgver/_/-}.i386.rpm")
md5sums_i686=('18988663fc0c958d12668ddee9e36bd5')
install="brscan5.install"

build() {
  mkdir -p usr/udev/rules.d
  ./mk-udev-rules opt/brother/scanner/brscan5/{brscan5.ini,models/*.ini} > "usr/udev/rules.d/40-$pkgname.rules"
}

package() {
  cp -r "$srcdir/etc" "$pkgdir"
  cp -r "$srcdir/opt" "$pkgdir"
  cp -r "$srcdir/usr" "$pkgdir"

  install -D -m644 "$srcdir/agree.html" "$pkgdir/usr/share/licenses/$pkgname/agree.html"

  mkdir -p "$pkgdir/usr/lib/sane"
  cd "$pkgdir/usr/lib/sane"
  mv "$pkgdir/opt/brother/scanner/brscan5/libsane-brother5.so.1.0.7" .
  ln -sf libsane-brother5.so.1.0.7 libsane-brother5.so.1
  ln -sf libsane-brother5.so.1 libsane-brother5.so

  libs=(libLxBsNetDevAccs libLxBsDeviceAccs libLxBsScanCoreApi libLxBsUsbDevAccs)
  cd "$pkgdir/usr/lib"
  for lib in "${libs[@]}"; do
    mv "$pkgdir/opt/brother/scanner/brscan5/${lib}.so.1.0.0" "$pkgdir/usr/lib"
    ln -sf "$lib.so.1.0.0" "$lib.so.1"
    ln -sf "$lib.so.1" "$lib.so"
  done
}

and brscan5.install

pre_install() {
  /bin/true
}

# new package version
post_install() {
  echo "Find additional documentation about scanner driver install at:"
  echo "https://support.brother.com/g/s/id/linux/en/instruction_scn1.html"
  echo "For a network installation run the following as root:"
  echo "brsaneconfig5 -a name=\"YOURMODELHERE\" model=\"YOURMODELHERE\" ip=YOUR.SCANNER.IP.HERE"
  /opt/brother/scanner/brscan5/setupSaneScan5 -i
}

# the new package version
# old package version
pre_upgrade() {
  /bin/true
}

# new package version
# old package version
post_upgrade() {
  /bin/true
}

# old package version
pre_remove() {
  /opt/brother/scanner/brscan5/setupSaneScan5 -e
  /bin/true
}

# old package version
post_remove() {
  /bin/true
}

Offline

#6 2019-04-15 23:05:45

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: PKGBUILD feedback request: brscan5

pre_install() {
  /bin/true
}

# the new package version
# old package version
pre_upgrade() {
  /bin/true
}

# new package version
# old package version
post_upgrade() {
  /bin/true
}

# old package version
post_remove() {
  /bin/true
}

These are noops

/opt/brother/scanner/brscan5/setupSaneScan5 alters /etc/sane.d/dll.conf instead I would suggest adding /etc/sane.d/dll.d/brother5.conf with the contents brother5 in the PKGBUILD
That would reduce brscan5.install to the post_install() messages

Offline

#7 2019-04-16 13:41:54

razerei
Member
Registered: 2019-04-14
Posts: 5
Website

Re: PKGBUILD feedback request: brscan5

Thanks loqs. Makes a lot of sense.

I removed the noop hooks. They were there from brscan4, and I left them as a template to remind me what the hooks are, but I can always look at the documentation for that.
I added a brother5.conf file and install it into /etc/sane.d/dll.conf/brother5.conf instead of running it in the postinstall and preremove hooks. Now the only hook is a postinstall that only echoes usage messaging.
I also noticed that the rpm extracts with udev rules in /etc as well, so I added another step to remove those so they don't get installed, since we're building them manually into /usr

# Maintainer: David Bernheisel <david@bernheisel.com>
# Based on the brscan4 PKGBUILD by Harey

pkgname=brscan5
pkgver=1.1.0_0
pkgrel=1
pkgdesc="SANE drivers from Brother for brscan5 compatible models"
arch=('i686' 'x86_64')
license=('GPL' 'custom:Brother')
url="http://support.brother.com"
depends=('sane' 'libusb-compat')
optdepends=('gtk2: for running brscan_gnetconfig')
source=(
  "http://www.brother.com/agreement/English_sane/agree.html"
  "mk-udev-rules"
  "brother5.conf"
)
md5sums=(
  'ccffb9a6f6d436b21be25b0241068981'
  'ca07cab058b704b7b12ba076d00be2f0'
  '90bf4aa2e87b68ba2ea1aa7e43b019d9'
)
source_x86_64=("https://download.brother.com/welcome/dlf104036/${pkgname}-${pkgver/_/-}.x86_64.rpm")
md5sums_x86_64=('5453ba052048780120a37d319cef1ce8')
source_i686=("https://download.brother.com/welcome/dlf104035/${pkgname}-${pkgver/_/-}.i386.rpm")
md5sums_i686=('18988663fc0c958d12668ddee9e36bd5')
install="brscan5.install"

build() {
  mkdir -p usr/udev/rules.d
  ./mk-udev-rules opt/brother/scanner/brscan5/{brscan5.ini,models/*.ini} > "usr/udev/rules.d/40-$pkgname.rules"
}

package() {
  cp -r "$srcdir/etc" "$pkgdir"
  cp -r "$srcdir/opt" "$pkgdir"
  cp -r "$srcdir/usr" "$pkgdir"

  rm -rf "$pkgdir/etc/udev"

  install -D -m644 "$srcdir/agree.html" "$pkgdir/usr/share/licenses/$pkgname/agree.html"
  install -D -m644 "brother5.conf" "$pkgdir/etc/sane.d/dll.d/brother5.conf"

  mkdir -p "$pkgdir/usr/lib/sane"
  cd "$pkgdir/usr/lib/sane"
  mv "$pkgdir/opt/brother/scanner/brscan5/libsane-brother5.so.1.0.7" .
  ln -sf libsane-brother5.so.1.0.7 libsane-brother5.so.1
  ln -sf libsane-brother5.so.1 libsane-brother5.so

  libs=(libLxBsNetDevAccs libLxBsDeviceAccs libLxBsScanCoreApi libLxBsUsbDevAccs)
  cd "$pkgdir/usr/lib"
  for lib in "${libs[@]}"; do
    mv "$pkgdir/opt/brother/scanner/brscan5/${lib}.so.1.0.0" "$pkgdir/usr/lib"
    ln -sf "$lib.so.1.0.0" "$lib.so.1"
    ln -sf "$lib.so.1" "$lib.so"
  done
}
# brscan5.install
post_install() {
  echo "Find additional documentation about scanner driver install at:"
  echo "https://support.brother.com/g/s/id/linux/en/instruction_scn1.html"
  echo "For a network installation run the following as root:"
  echo "brsaneconfig5 -a name=\"YOURMODELHERE\" model=\"YOURMODELHERE\" ip=YOUR.SCANNER.IP.HERE"
}

Offline

#8 2019-04-16 13:43:30

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: PKGBUILD feedback request: brscan5

Documentation is better off in a pinned comment or in the Wiki than in post_install

brother5.conf is just "brother5"? Seems like overkill to have a separate file for that.

Last edited by Scimmia (2019-04-16 13:46:26)

Offline

#9 2019-04-16 13:51:47

razerei
Member
Registered: 2019-04-14
Posts: 5
Website

Re: PKGBUILD feedback request: brscan5

ya, that's all it is. I thought about just echoing into a file. I don't really have a preference though.

Offline

#10 2019-04-17 14:36:39

razerei
Member
Registered: 2019-04-14
Posts: 5
Website

Re: PKGBUILD feedback request: brscan5

Thanks @Scimmia and @loqs for all the feedback, I've published it now, https://aur.archlinux.org/packages/brscan5/

Offline

Board footer

Powered by FluxBB