#!/bin/bash # script for building extra printing drivers # Epson, Canon, Pantum etc for Porteus # Version 2025-02-09 # Copyright 2023-2030, Blaze, Dankov, Russia # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # root check if [ `whoami` != "root" ]; then echo -e "\nYou need to be root to run this script.\n" exit 1 fi VERSION=$(date +%Y-%m-%d) BUILD=${BUILD:-1} BOLD=${BOLD:-"\e[1m"} CYAN=${CYAN:-"\e[96m"} GREEN=${GREEN:-"\e[92m"} RED=${RED:-"\e[31m"} RESET=${RESET:-"\e[0m"} CWD=$(pwd) TMPDIR=/tmp/portch OUTPUT=${OUTPUT:-/tmp} ARCH=$( uname -m ) if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi set -e cleanup(){ [ -d $TMPDIR ] && rm -rf $TMPDIR [ -d $PKG ] && rm -rf $PKG exit } echo "Please set model of your printer for download and build extra printing module:" echo "1) Canon" echo "2) Epson" echo "3) HP" echo "4) Pantum" echo "5) Samsung" echo read model case "$model" in 1|Canon|canon) echo -e "\n${BOLD}Canon${RESET} chosen. Downloading:" PRGNAM=${PRGNAM:-canon} PKG=${TMPDIR}/package-${PRGNAM} PKGINFO=${PKG}/var/lib/pkgtools/packages DEP1NAM=${DEPNAM:-jbigkit} DEP1VER=$(lynx --source https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/.SRCINFO?ref_type=heads | grep pkgver | cut -d'=' -f2 | tr -d ' ') SOURCE1=$(lynx --source https://aur.archlinux.org/packages/cnrdrvcups-lb-bin | egrep -0 "' -f2 | cut -d'<' -f1) SOURCE2=$(lynx --source https://aur.archlinux.org/packages/cnrdrvcups-sfp | egrep -0 "' -f2 | cut -d'<' -f1) SOURCE3=$(echo http://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-${DEP1VER}.tar.gz) rm -rf $PKG mkdir -p $TMPDIR $PKG $DEP1NAM-$DEP1VER cd $PKG wget -q --show-progress $SOURCE1 $SOURCE2 $SOURCE3 tar xf linux-UFRII-drv-*.tar.gz tar xf linux-UFRIILT-drv-*.tar.gz tar xf jbigkit-${DEP1VER}.tar.gz rm -f *.tar.gz # jbigkit (Canon dep) cd $DEP1NAM-$DEP1VER wget -q https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/jbigkit-${DEP1VER}-shared_lib.patch wget -q https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/jbigkit-${DEP1VER}-build_warnings.patch wget -q https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/jbigkit-${DEP1VER}-ldflags.patch wget -q https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/jbigkit-${DEP1VER}-coverity.patch wget -q https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/0013-new-jbig.c-limit-s-maxmem-maximum-decoded-image-size.patch wget -q https://gitlab.archlinux.org/archlinux/packaging/packages/jbigkit/-/raw/main/0015-jbg_newlen-check-for-end-of-file-within-MARKER_NEWLE.patch # instead of a static library, create a shared library patch -Np1 -i jbigkit-2.1-shared_lib.patch # fix build warnings patch -Np1 -i jbigkit-2.1-build_warnings.patch # apply distribution LDFLAGS patch -Np1 -i jbigkit-2.1-ldflags.patch # fix coverity issues patch -Np1 -i jbigkit-2.1-coverity.patch # security fixes from upstream patch -Np1 -i 0013-new-jbig.c-limit-s-maxmem-maximum-decoded-image-size.patch patch -Np1 -i 0015-jbg_newlen-check-for-end-of-file-within-MARKER_NEWLE.patch make EXTRA_CFLAGS="$SLKCFLAGS" mkdir -p $PKG/usr/{bin,lib$LIBDIRSUFFIX} install -vDm 755 libjbig/*.so.* -t "$PKG/usr/lib$LIBDIRSUFFIX" for lib in libjbig.so libjbig85.so; do ln -sv "$lib.$DEP1VER" "$PKG/usr/lib$LIBDIRSUFFIX/$lib" done install -vDm 755 pbmtools/{jbgtopbm{,85},pbmtojbg{,85}} -t "$PKG/usr/bin" ### fake Slackware type package info: super dumb version mkdir -p $PKGINFO echo "PACKAGE NAME: $DEP1NAM-$DEP1VER-$ARCH" > $PKGINFO/$DEP1NAM-$DEP1VER-$ARCH cat >> $PKGINFO/$DEP1NAM-$DEP1VER-$ARCH << EOM PACKAGE DESCRIPTION: jbigkit: jbigkit (highly effective lossless compression algorithm) jbigkit: jbigkit: JBIG is a highly effective lossless compression algorithm for jbigkit: high-resolution bi-level images (one bit per pixel), which is jbigkit: particularly suitable for scanned documents or fax pages. jbigkit: jbigkit: JBIG-KIT provides a portable library of compression and decompression jbigkit: functions with a documented interface that you can easily include jbigkit: into your image or document processing software. JBIG-KIT also jbigkit: provides ready-to-use compression and decompression programs with a jbigkit: simple command line interface. FILE LIST: EOM find * | grep -v var >> $PKGINFO/$DEP1NAM-$DEP1VER-$ARCH # extract Canon drivers cd $PKG if [[ "$ARCH" == i686 || "$ARCH" == i586 ]]; then mv $PKG/linux-UFRII-drv-*-m17n/x86/RPM/cnrdrvcups-ufr2-uk-*i386.xzm $PKG mv $PKG/linux-UFRIILT-drv-*-uken/32-bit_Driver/RPM/cnrdrvcups-ufr2lt-uk-*i386.xzm $PKG else mv $PKG/linux-UFRII-drv-*-m17n/x64/RPM/cnrdrvcups-ufr2-uk-*x86_64.rpm $PKG mv $PKG/linux-UFRIILT-drv-*-uken/64-bit_Driver/RPM/cnrdrvcups-ufr2lt-uk-*x86_64.rpm $PKG fi for i in `find . -type f | fgrep .rpm | sort`; do rpm2cpio $i | cpio -idmv &>/dev/null; done DEP2NAM=${DEP2NAM:-cnrdrvcups-ufr2-uk} DEP3NAM=${DEP3NAM:-cnrdrvcups-ufr2lt-uk} DEP2VER=$(ls $DEP2NAM*.rpm | egrep -o "[0-9].[0-9]{2}-[0-9].[0-9]{2}") DEP3VER=$(ls $DEP3NAM*.rpm | egrep -o "[0-9].[0-9]{2}-[0-9]") ### fake Slackware type package info: super dumb version echo "PACKAGE NAME: $DEP2NAM-$DEP2VER-$ARCH" > $PKGINFO/$DEP2NAM-$DEP2VER-$ARCH cat >> $PKGINFO/$DEP2NAM-$DEP2VER-$ARCH << EOM PACKAGE DESCRIPTION: cnrdrvcups-ufr2-uk: CUPS Canon UFR II LIPSLX CARPS2 printer driver for LBP iR MF cnrdrvcups-ufr2-uk: ImageCLASS ImageRUNNER Laser Shot i-SENSYS ImagePRESS ADVANCE cnrdrvcups-ufr2-uk: printers and copiers FILE LIST: EOM ### fake Slackware type package info: super dumb version echo "PACKAGE NAME: $DEP3NAM-$DEP3VER-$ARCH" > $PKGINFO/$DEP3NAM-$DEP3VER-$ARCH cat >> $PKGINFO/$DEP3NAM-$DEP3VER-$ARCH << EOM PACKAGE DESCRIPTION: cnrdrvcups-ufr2lt-uk: Canon UFRII LT Printer Driver for Linux cnrdrvcups-ufr2lt-uk: (LBP112/912, LBP113/913, LBP151dw, LBP6030/LBP6040/LBP6018L, cnrdrvcups-ufr2lt-uk: LBP6230/LBP6240, LBP7100C/LBP7110C, LBP8100) FILE LIST: EOM # cleanup rm -rf $PKG/$DEP1NAM-$DEP1VER $PKG/linux-UFRII-drv-v* $PKG/linux-UFRIILT-drv-v* $PKG/*.rpm rm -rf $PKG/usr/include rm -rf $PKG/usr/lib$LIBDIRSUFFIX/pkgconfig rm -f $PKG/usr/bin/{cnsetuputil2,cnsetuputil2l} rm -rf $PKG/usr/share/{cnsetuputil2,cnsetuputil2l,doc,man} rm -f $PKG/usr/share/applications/{cnsetuputil.desktop,cnsetuputil2l.desktop} rm -rf $PKG/usr/share/locale for i in `find $PKG/usr/lib/Canon/CUPS_SFPR/Utilities/Message -type d ! -name 'Message' ! -name 'en_US'`; do rm -rf $i &>/dev/null; done # creating symbolic links for x86_64 if [[ "$ARCH" == x86_64 ]]; then mkdir -p $PKG/usr/lib$LIBDIRSUFFIX/cups/backend ln -sf /usr/lib/cups/filter/{pdftocpca,rastertoufr2} $PKG/usr/lib$LIBDIRSUFFIX/cups/filter ln -sf /usr/lib/cups/backend/cnusbufr2 $PKG/usr/lib$LIBDIRSUFFIX/cups/backend fi dir2xzm $PKG $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD.xzm # check on Canon xzm file exists in /tmp if [ -f "$OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}$OUTPUT/$PRGNAM-$VERSION-${ARCH}-${BUILD}.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}" else echo -e "\n${RED}${BOLD}Faile. Your $PRGNAM module is not built.${RESET}\n" fi cleanup ;; 2|Epson|epson) echo -e "\n${BOLD}Epson${RESET} chosen. Downloading:" PRGNAM=${PRGNAM:-epson} PNAM=${PNAM:-epson-inkjet-printer-escpr} PNAM2=${PNAM2:-epson-inkjet-printer-escpr2} PKG=${TMPDIR}/package-${PRGNAM} PKGINFO=${PKG}/var/lib/pkgtools/packages SLACKESCPR=$(lynx --source https://slackbuilds.org/slackbuilds/15.0/system/epson-inkjet-printer-escpr/epson-inkjet-printer-escpr.info | grep -i version | cut -d'"' -f2) ARCHESCPR=$(lynx --source https://aur.archlinux.org/packages/epson-inkjet-printer-escpr | grep "Details" | egrep -o "[0-9].[0-9].[0-9]") SLACKESCPR2=$(lynx --source https://slackbuilds.org/slackbuilds/15.0/system/epson-inkjet-printer-escpr2/epson-inkjet-printer-escpr2.info | grep -i version | cut -d'"' -f2) ARCHESCPR2=$(lynx --source https://aur.archlinux.org/packages/epson-inkjet-printer-escpr2 | grep "Details" | egrep -o "[0-9].[0-9].[0-9]{2}") SOURCE1=$(echo https://slackbuilds.org/slackbuilds/15.0/system/epson-inkjet-printer-escpr.tar.gz) SOURCE2=$(lynx --source https://aur.archlinux.org/packages/epson-inkjet-printer-escpr | egrep -0 "' -f2 | cut -d'<' -f1) SOURCE3=$(echo https://slackbuilds.org/slackbuilds/15.0/system/epson-inkjet-printer-escpr2.tar.gz) SOURCE4=$(lynx --source https://slackbuilds.org/repository/15.0/system/epson-inkjet-printer-escpr2/ | grep ".src.rpm" | cut -d'"' -f2) rm -rf $PKG ${OUTPUT}/*.{tgz,txz} mkdir -p $TMPDIR $PKG cd $PKG # download cups as dep for bulding Epson drivers getmod -q cups activate $OUTPUT/cups-*.xzm # Epson Inkjet Printer Driver (ESC/P-R) for Linux wget -q --show-progress $SOURCE1 tar -xf $PNAM.tar.gz && rm -f $PNAM.tar.gz && cd $PNAM wget -q --show-progress $SOURCE2 # 5 lines below fixes for current SlackBuild rpm2cpio $PNAM-*.src.rpm | cpio -idmv && rm -f $PNAM-*.src.rpm > /dev/null sed -i "s|$SLACKESCPR|$ARCHESCPR|" $PNAM.SlackBuild sed -i "s|1lsb3.2|1|" $PNAM.SlackBuild sed -i "s|-mtune=i686|-mtune=i686 -Wno-implicit-function-declaration|g" $PNAM.SlackBuild sed -i "s|-fPIC|-fPIC -Wno-implicit-function-declaration|" $PNAM.SlackBuild ./$PNAM.SlackBuild cd $PKG && rm -rf $PNAM # Epson Inkjet Printer Driver 2 (ESC/P-R) for Linux wget -q --show-progress $SOURCE3 tar -xf $PNAM2.tar.gz && rm -f $PNAM2.tar.gz && cd $PNAM2 wget -q --show-progress $SOURCE4 # 2 lines below fixes for current SlackBuild sed -i "s|-mtune=i686|-mtune=i686 -Wno-implicit-function-declaration|g" $PNAM2.SlackBuild sed -i "s|-fPIC|-fPIC -Wno-implicit-function-declaration|g" $PNAM2.SlackBuild ./$PNAM2.SlackBuild cd $PKG && rm -rf $PNAM2 for i in $(find ${OUTPUT} -type f | grep ".tgz" | sort); do ROOT=$PKG installpkg $i >/dev/null; done deactivate $OUTPUT/cups-*.xzm # cleanup rm -rf $PKG/usr/doc rm -rf $PKG/var/lib/pkgtools/scripts rm -rf ${OUTPUT}/*.{tgz,txz,xzm} dir2xzm $PKG $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD.xzm # check on Canon xzm file exists in /tmp if [ -f "$OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}$OUTPUT/$PRGNAM-$VERSION-${ARCH}-${BUILD}.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}" else echo -e "\n${RED}${BOLD}Faile. Your $PRGNAM module is not built.${RESET}\n" fi cleanup ;; 3|HP|hp) echo -e "\n${BOLD}HP${RESET} chosen. Downloading:" PRGNAM=${PRGNAM:-hp} SLACKVER=$(lynx --source https://slackbuilds.org/slackbuilds/15.0/system/hplip-plugin/hplip-plugin.info | grep -i version | cut -d'"' -f2) PLUGVER=$(lynx --source https://developers.hp.com/hp-linux-imaging-and-printing/plugins | egrep -o "hplip-[0-9].[0-9]{2}.*run\"" | tail -n1 | cut -d'-' -f2) PKG=${TMPDIR}/package-${PRGNAM} PKGINFO=${PKG}/var/lib/pkgtools/packages SOURCE=$(echo https://slackbuilds.org/slackbuilds/15.0/system/hplip-plugin.tar.gz) rm -rf $PKG ${OUTPUT}/*.{tgz,txz} mkdir -p $TMPDIR $PKG cd $PKG getpkg -q hplip # install hplip-plugin (proprietary software) wget -q $SOURCE tar xf hplip-plugin.tar.gz && rm -f hplip-plugin.tar.gz cd hplip-plugin sed -i "s|$SLACKVER|$PLUGVER|" hplip-plugin.SlackBuild wget -q --show-progress https://developers.hp.com/sites/default/files/hplip-${PLUGVER}-plugin.run ./hplip-plugin.SlackBuild cd $PKG && rm -rf hplip-plugin for i in $(find ${OUTPUT} -type f -name "*.txz"); do ROOT=${PKG} installpkg ${i} >/dev/null; done for i in $(find ${OUTPUT} -type f -name "*.tgz"); do ROOT=${PKG} installpkg ${i} >/dev/null; done # cleanup rm -f ${PKG}/etc/xdg/autostart/hplip-systray.desktop rm -rf $PKG/usr/doc rm -rf $PKG/usr/lib/systemd rm -rf ${PKG}/usr/share/applications rm -rf ${PKG}/usr/share/hplip/data/{images,localization} rm -rf $PKG/var/lib/pkgtools/scripts find ${PKG} -type f -name "*.la" -delete find ${PKG} -type f -name "*.a" -delete find ${PKG} -type f -name "*.h" -delete rm -f ${OUTPUT}/*.{tgz,txz} dir2xzm $PKG $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD.xzm # check on Canon xzm file exists in /tmp if [ -f "$OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}$OUTPUT/$PRGNAM-$VERSION-${ARCH}-${BUILD}.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}" else echo -e "\n${RED}${BOLD}Faile. Your $PRGNAM module is not built.${RESET}\n" fi cleanup ;; 4|Pantum|pantum) echo -e "\n${BOLD}Pantum${RESET} chosen. Downloading:" PRGNAM=${PRGNAM:-pantum} PANVER=$(lynx -head -dump "https://github.com/ArticExploit/pantum-driver/releases/latest" | grep Location | grep -o "[0-9].*$") PKG=${TMPDIR}/package-${PRGNAM} PKGINFO=${PKG}/var/lib/pkgtools/packages SOURCE=$(lynx --source https://aur.archlinux.org/packages/pantum-driver | egrep -0 "' -f2 | cut -d'<' -f1) rm -rf $PKG ${OUTPUT}/*.{tgz,txz} mkdir -p $TMPDIR $PKG cd ${OUTPUT} wget -q --show-progress -P ${OUTPUT} $SOURCE unzip -q -d ${OUTPUT} "Pantum.Ubuntu.Driver*.zip" rm -f ${OUTPUT}/Pantum.Ubuntu.Driver*.zip cd "${OUTPUT}/Pantum Ubuntu Driver V${PANVER}/Resources" if [[ "$ARCH" == i686 || "$ARCH" == i586 ]]; then mkdir -p pantum-${PANVER}-i386 cd pantum-${PANVER}-i386 ar p "../pantum_${PANVER}-1_i386.deb" data.tar.xz | tar xJ cd usr/lib # tweak for i386 cp -a i386-linux-gnu/* . rm -r *-linux-gnu* cd ../.. rm -rf usr/local cp -a "$PKG/Pantum Ubuntu Driver V${PANVER}/Resources/pantum-${PANVER}-i386" $PKG cp -a $PKG/pantum-${PANVER}-i386/* $PKG elif [[ "$ARCH" == x86_64 ]]; then mkdir -p pantum-${PANVER}-${ARCH} cd pantum-${PANVER}-${ARCH} ar p "../pantum_${PANVER}-1_amd64.deb" data.tar.xz | tar xJ cd usr/lib # tweak for x86_64 mv x86_64-linux-gnu ../lib64 cp -a cups ../lib64 cd ../.. rm -rf usr/local usr/lib cp -a "${OUTPUT}/Pantum Ubuntu Driver V${PANVER}/Resources/pantum-${PANVER}-${ARCH}" $PKG cp -a $PKG/pantum-${PANVER}-${ARCH}/* $PKG fi # cleanup rm -rf "${OUTPUT}/Pantum Ubuntu Driver V${PANVER}" $PKG/pantum-${PANVER}-${ARCH} #find ${PKG} -type f -maxdepth 1 -name "*.zip" -delete rm -rf ${PKG}/usr/share/doc cd $PKG # create a symbolic link on libjpeg8 (Pantum dep) # Pantum is requests libjpeg8 an old package but it is not available in many distribution. # This package replaced by a new libjpeg-turbo package instead. Although it is originally # forked off the legacy libjpeg v6b codebase (which explains the version number), # it also includes the ABIs of libjpeg v7 and v8, so it should be compatible. ln -s /usr/lib${LIBDIRSUFFIX}/libjpeg.so.62 $PKG/usr/lib${LIBDIRSUFFIX}/libjpeg.so.8 ### fake Slackware type package info: super dumb version mkdir -p $PKGINFO echo "PACKAGE NAME: $PRGNAM-$PANVER-$ARCH" > $PKGINFO/$PRGNAM-$PANVER-$ARCH cat >> $PKGINFO/$PRGNAM-$PANVER-$ARCH << EOM PACKAGE DESCRIPTION: pantum: Linux driver for Pantum printers FILE LIST: EOM find * | grep -v var >> $PKGINFO/$PRGNAM-$PANVER-$ARCH dir2xzm $PKG $OUTPUT/$PRGNAM-$PANVER-$ARCH-$BUILD.xzm # check on Canon xzm file exists in /tmp if [ -f "$OUTPUT/${PRGNAM}-${PANVER}-${ARCH}-${BUILD}.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}$OUTPUT/$PRGNAM-$PANVER-${ARCH}-${BUILD}.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}" else echo -e "\n${RED}${BOLD}Faile. Your $PRGNAM module is not built.${RESET}\n" fi cleanup ;; 5|Samsung|Samsung) echo -e "\n${BOLD}Samsung${RESET} chosen. Downloading:" PRGNAM=${PRGNAM:-samsung-unified-driver} VERSION=V1.00.39 PKG=${TMPDIR}/package-${PRGNAM} PKGINFO=${PKG}/var/lib/pkgtools/packages SOURCE1=$(echo http://downloadcenter.samsung.com/content/DR/201704/20170407143829533/uld_V1.00.39_01.17.tar.gz) SOURCE2=$(echo https://aur.archlinux.org/cgit/aur.git/plain/xerox_mfp-smfp.conf?h=samsung-unified-driver) rm -rf $PKG ${OUTPUT}/*.{tgz,txz} mkdir -p $TMPDIR $PKG cd $OUTPUT wget -q --show-progress -P ${OUTPUT} $SOURCE1 tar -xf uld_${VERSION}_*.tar.gz && rm -f uld_${VERSION}_*.tar.gz if [ "$ARCH" = "i586" ]; then mkdir -p "$PKG"/usr/lib cp "$OUTPUT"/uld/i386/libscmssc.so "$PKG"/usr/lib mkdir -p "$PKG"/usr/lib/cups/backend cp "$OUTPUT"/uld/i386/smfpnetdiscovery "$PKG"/usr/lib/cups/backend mkdir -p "$PKG"/usr/lib/cups/filter cp "$OUTPUT"/uld/i386/pstosecps "$PKG"/usr/lib/cups/filter cp "$OUTPUT"/uld/i386/rastertospl "$PKG"/usr/lib/cups/filter ln -s rastertospl "$PKG"/usr/lib/cups/filter/rastertosplc mkdir -p "$PKG"/usr/share/ppd/suld for ppd in "$OUTPUT"/uld/noarch/share/ppd/*.ppd; do gzip < "$ppd" > "$PKG"/usr/share/ppd/suld/"${ppd##*/}".gz done mkdir -p "$PKG"/usr/share/ppd/suld/cms for cts in "$OUTPUT"/uld/noarch/share/ppd/cms/*.cts; do cp "$cts" "$PKG"/usr/share/ppd/suld/cms done fi if [ "$ARCH" = "x86_64" ]; then mkdir -p "$PKG"/usr/lib64 cp "$OUTPUT"/uld/x86_64/libscmssc.so "$PKG"/usr/lib64 mkdir -p "$PKG"/usr/lib64/cups/backend cp "$OUTPUT"/uld/x86_64/smfpnetdiscovery "$PKG"/usr/lib64/cups/backend mkdir -p "$PKG"/usr/lib64/cups/filter cp "$OUTPUT"/uld/x86_64/pstosecps "$PKG"/usr/lib64/cups/filter cp "$OUTPUT"/uld/x86_64/rastertospl "$PKG"/usr/lib64/cups/filter ln -s rastertospl "$PKG"/usr/lib64/cups/filter/rastertosplc mkdir -p "$PKG"/usr/share/ppd/suld for ppd in "$OUTPUT"/uld/noarch/share/ppd/*.ppd; do gzip < "$ppd" > "$PKG"/usr/share/ppd/suld/"${ppd##*/}".gz done mkdir -p "$PKG"/usr/share/ppd/suld/cms for cts in "$OUTPUT"/uld/noarch/share/ppd/cms/*.cts; do cp "$cts" "$PKG"/usr/share/ppd/suld/cms done fi if [ "$ARCH" = "i586" ]; then mkdir -p "$PKG"/etc/sane.d #xerox_mfp-smfp.conf - https://aur.archlinux.org/packages/samsung-unified-driver/ lynx --source $SOURCE2 > "$OUTPUT"/xerox_mfp-smfp.conf cp "$OUTPUT"/uld/noarch/etc/smfp.conf "$PKG"/etc/sane.d cp "$OUTPUT"/xerox_mfp-smfp.conf "$PKG"/etc/sane.d mkdir -p "$PKG"/etc/sane.d/dll.d echo smfp > "$PKG"/etc/sane.d/dll.d/smfp-scanner echo xerox_mfp-smfp > "$PKG"/etc/sane.d/dll.d/smfp-scanner-fix mkdir -p "$PKG"/usr/lib/sane cp "$OUTPUT"/uld/i386/libsane-smfp.so.1.0.1 "$PKG"/usr/lib/sane ln -s libsane-smfp.so.1.0.1 "$PKG"/usr/lib/sane/libsane-smfp.so.1 ln -s libsane-smfp.so.1 "$PKG"/usr/lib/sane/libsane-smfp.so mkdir -p "$PKG"/etc/udev/rules.d ( OEM_FILE="$OUTPUT"/uld/noarch/oem.conf INSTALL_LOG_FILE=/dev/null source "$OUTPUT"/uld/noarch/scripting_utils source "$OUTPUT"/uld/noarch/package_utils source "$OUTPUT"/uld/noarch/scanner-script.pkg fill_full_template "$OUTPUT"/uld/noarch/etc/smfp.rules.in "$PKG"/etc/udev/rules.d/60_smfp_samsung.rules chmod 644 "$PKG"/etc/udev/rules.d/60_smfp_samsung.rules mkdir -p "$PKG"/opt/samsung/scanner/share cp "$OEM_FILE" "$PKG"/opt/samsung/scanner/share ) fi if [ "$ARCH" = "x86_64" ]; then mkdir -p "$PKG"/etc/sane.d #xerox_mfp-smfp.conf - https://aur.archlinux.org/packages/samsung-unified-driver/ lynx --source https://aur.archlinux.org/cgit/aur.git/plain/xerox_mfp-smfp.conf?h=samsung-unified-driver > "$OUTPUT"/xerox_mfp-smfp.conf cp "$OUTPUT"/uld/noarch/etc/smfp.conf "$PKG"/etc/sane.d cp "$OUTPUT"/xerox_mfp-smfp.conf "$PKG"/etc/sane.d mkdir -p "$PKG"/etc/sane.d/dll.d echo smfp > "$PKG"/etc/sane.d/dll.d/smfp-scanner echo xerox_mfp-smfp > "$PKG"/etc/sane.d/dll.d/smfp-scanner-fix mkdir -p "$PKG"/usr/lib64/sane cp "$OUTPUT"/uld/x86_64/libsane-smfp.so.1.0.1 "$PKG"/usr/lib64/sane ln -s libsane-smfp.so.1.0.1 "$PKG"/usr/lib64/sane/libsane-smfp.so.1 ln -s libsane-smfp.so.1 "$PKG"/usr/lib64/sane/libsane-smfp.so mkdir -p "$PKG"/etc/udev/rules.d ( OEM_FILE="$OUTPUT"/uld/noarch/oem.conf INSTALL_LOG_FILE=/dev/null source "$OUTPUT"/uld/noarch/scripting_utils source "$OUTPUT"/uld/noarch/package_utils source "$OUTPUT"/uld/noarch/scanner-script.pkg fill_full_template "$OUTPUT"/uld/noarch/etc/smfp.rules.in "$PKG"/etc/udev/rules.d/60_smfp_samsung.rules chmod 644 "$PKG"/etc/udev/rules.d/60_smfp_samsung.rules mkdir -p "$PKG"/opt/samsung/scanner/share cp "$OEM_FILE" "$PKG"/opt/samsung/scanner/share ) fi # cleanup rm -rf $OUTPUT/{uld,xerox_mfp-smfp.conf} cd $PKG ### fake Slackware type package info: super dumb version mkdir -p $PKGINFO echo "PACKAGE NAME: $PRGNAM-$VERSION-$ARCH" > $PKGINFO/$PRGNAM-$VERSION-$ARCH cat >> $PKGINFO/$PRGNAM-$VERSION-$ARCH << EOM PACKAGE DESCRIPTION: samsung-unified-driver: Samsung Unified Linux Driver for printers and scanners. samsung-unified-driver: samsung-unified-driver: http://www.samsung.com/ samsung-unified-driver: FILE LIST: EOM find * | grep -v var >> $PKGINFO/$PRGNAM-$VERSION-$ARCH dir2xzm $PKG $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD.xzm # check on Canon xzm file exists in /tmp if [ -f "$OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}$OUTPUT/$PRGNAM-$VERSION-${ARCH}-${BUILD}.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}" else echo -e "\n${RED}${BOLD}Faile. Your $PRGNAM module is not built.${RESET}\n" fi cleanup ;; *) echo "Sorry, but your model of printer is not in the list." exit 0 ;; esac