brscan5: 1.2.7-0 -> 1.2.9.0 (#164903)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
Matt Christ 2022-03-27 06:43:16 -05:00 committed by GitHub
parent 46bfc04d4b
commit c5fac1f611
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,21 +5,22 @@ let
${stdenv.glibc}/lib/ld-linux${optionalString stdenv.is64bit "-x86-64"}.so.2 \
${file}
'';
system = stdenv.hostPlatform.system;
in
stdenv.mkDerivation rec {
pname = "brscan5";
version = "1.2.7-0";
version = "1.2.9-0";
src = {
"i686-linux" = fetchurl {
url = "https://download.brother.com/welcome/dlf104034/${pname}-${version}.i386.deb";
sha256 = "647d06f629c22408d25be7c0bf49a4b1c7280bf78a27aa2cde6c3e3fa8b6807a";
sha256 = "ac23c9a435818955e7882ab06380adf346203ff4e45f384b40e84b8b29642f07";
};
"x86_64-linux" = fetchurl {
url = "https://download.brother.com/welcome/dlf104033/${pname}-${version}.amd64.deb";
sha256 = "867bd88ab0d90f8e9391dc8127385095127e533cb6bd2d5d13449df602b165ae";
sha256 = "4ec23ff4b457323ae778e871a0f1abcc1848ea105af17850b57f7dcaddcfd96d";
};
}."${stdenv.hostPlatform.system}";
}."${system}" or (throw "Unsupported system: ${system}");
unpackPhase = ''
ar x $src
@ -30,21 +31,28 @@ stdenv.mkDerivation rec {
buildInputs = [ libusb1 avahi-compat stdenv.cc.cc glib ];
dontBuild = true;
postPatch = ''
${myPatchElf "opt/brother/scanner/brscan5/brsaneconfig5"}
${myPatchElf "opt/brother/scanner/brscan5/brscan_cnetconfig"}
${myPatchElf "opt/brother/scanner/brscan5/brscan_gnetconfig"}
postPatch =
let
patchOffsetBytes =
if system == "x86_64-linux" then 84632
else if system == "i686-linux" then 77396
else throw "Unsupported system: ${system}";
in
''
${myPatchElf "opt/brother/scanner/brscan5/brsaneconfig5"}
${myPatchElf "opt/brother/scanner/brscan5/brscan_cnetconfig"}
${myPatchElf "opt/brother/scanner/brscan5/brscan_gnetconfig"}
for a in opt/brother/scanner/brscan5/*.so.* opt/brother/scanner/brscan5/brscan_[cg]netconfig; do
if ! test -L $a; then
patchelf --set-rpath ${lib.makeLibraryPath buildInputs} $a
fi
done
for file in opt/brother/scanner/brscan5/*.so.* opt/brother/scanner/brscan5/brscan_[cg]netconfig; do
if ! test -L $file; then
patchelf --set-rpath ${lib.makeLibraryPath buildInputs} $file
fi
done
# driver is hardcoded to look in /opt/brother/scanner/brscan5/models for model metadata.
# patch it to look in /etc/opt/brother/scanner/models instead, so nixos environment.etc can make it available
printf '/etc/opt/brother/scanner/models\x00' | dd of=opt/brother/scanner/brscan5/libsane-brother5.so.1.0.7 bs=1 seek=84632 conv=notrunc
'';
# driver is hardcoded to look in /opt/brother/scanner/brscan5/models for model metadata.
# patch it to look in /etc/opt/brother/scanner/models instead, so nixos environment.etc can make it available
printf '/etc/opt/brother/scanner/models\x00' | dd of=opt/brother/scanner/brscan5/libsane-brother5.so.1.0.7 bs=1 seek=${toString patchOffsetBytes} conv=notrunc
'';
installPhase = with lib; ''
runHook preInstall