# # RPM macro set for the LSB Driver Development Kit (LSB DDK) # ---------------------------------------------------------- # # Till Kamppeter, The Linux Foundation # # Please append this file to ~/.rpmmacros or /etc/rpm/macros (or create # appropriate files) to build packages based on the LSB DDK # Redefine all directory macros for installation in /opt %optinstall 0 %install_into_opt %{expand: \ %%define _prefix /opt/%%{supplier} \ %%define _sysconfdir /etc/opt/%%{supplier} \ %%define _localstatedir /var/opt/%%{supplier} \ %%define _exec_prefix %%{_prefix} \ %%define _bindir %%{_prefix}/bin \ %%define _sbindir %%{_prefix}/sbin \ %%define _libdir %%{_prefix}/%%{_lib} \ %%define _pkglibdir %%{_prefix}/lib \ %%define _datadir %%{_prefix}/share \ %%define _mandir %%{_prefix}/man \ %%define _defaultdocdir %%{_prefix}/doc \ %%define _docdir %%{_defaultdocdir} \ %%define _localedir %%{_prefix}/locale \ %%define _rcdir %%{_sysconfdir}/%{name} %%define _pamdir %%{_sysconfdir}/%{name}/pam.d %%define _xinetdir %%{_sysconfdir}/%{name}/xinetd.d %%define _cupsserverroot %%{_prefix}/cups/etc \ %%define _cupsserverbin %%{_prefix}/cups/lib \ %%define _cupsdatadir %%{_prefix}/cups/data \ %%define _cupsppd %%{_prefix}/ppds \ %%define optinstall 1 \ } \ %{nil} %ppdnickname - %{driverstr} %{version}%{extraversion} (%{supplierstr} LSB %{lsbver}) %binexec 0 %has_bin_executables %{expand:%%define binexec 1} %sbinexec 0 %has_sbin_executables %{expand:%%define sbinexec 1} %manpages 0 %has_man_pages %{expand:%%define manpages 1} # This replaces lib, lib32, and lib64 in the %{_libdir} by lib* %_libdirglob `echo %{_libdir} | perl -p -e 's!lib(64|32|)!lib*!'` # Script to put into /etc/profile.d (or to append to /etc/profile) to make # the command line utilities evailable via the $PATH environment variable # and the man pages via the $MANPATH variable # (only needed if we install in /opt) %__spec_prep_post \ if [ "%{?optinstall}" = "1" ]; then \ if [ "%{?binexec}" = "1" ] || \\\ [ "%{?sbinexec}" = "1" ] || \\\ [ "%{?manpages}" = "1" ]; then \ touch %{name}.sh \ if [ "%{?binexec}" = "1" ]; then \ echo 'export PATH=%{_bindir}:\$PATH' >> %{name}.sh \ fi \ if [ "%{?sbinexec}" = "1" ]; then \ echo 'export PATH=%{_sbindir}:\$PATH' >> %{name}.sh \ fi \ if [ "%{?manpages}" = "1" ]; then \ echo \\\ 'oldmanpath=\`manpath 2>/dev/null\` || \\\ oldmanpath=\`man --path 2>/dev/null\` \ export MANPATH=%{_mandir}:\$oldmanpath \ unset oldmanpath' >> %{name}.sh \ fi \ chmod +x %{name}.sh \ fi \ fi \ %{___build_post} # Make sure that LSB compilers get used and that static CUPS and image # libraries get used if demanded %__spec_build_pre \ %{___build_pre} \ export CC=/opt/lsb/bin/lsbcc \ export CXX=/opt/lsb/bin/lsbc++ \ export CFLAGS="$CFLAGS" \ export CXXFLAGS="$CXXFLAGS" \ export LDFLAGS='-L/opt/lsb/%{_lib}' \ %{nil} # Make sure that LSB compilers get used and that static CUPS and image # libraries get used %__spec_install_pre \ %{___build_pre} \ export CC=/opt/lsb/bin/lsbcc \ export CXX=/opt/lsb/bin/lsbc++ \ export CFLAGS="$CFLAGS "`cups-config --cflags` \ export CXXFLAGS="$CXXFLAGS "`cups-config --cflags` \ export LDFLAGS='-L/opt/lsb/%{_lib}' \ %{nil} # To be used after "./configure" and before "make" # Replace auto-detected CUPS directories of the system by our own directories # in /opt %adjust_cups_dirs \ if [ "%{?optinstall}" = "1" ]; then \ if cups-config --version >/dev/null 2>/dev/null; then \ cupsserverbin=`cups-config --serverbin` \ cupsserverroot=`cups-config --serverroot` \ cupsdatadir=`cups-config --datadir` \ cupsppddir=`cups-config --modeldir 2>/dev/null` || \\\ cupsppddir=${cupsdatadir}/model \ else \ cupsserverbin=/usr/lib/cups \ cupsserverroot=/etc/cups \ cupsdatadir=/usr/share/cups \ if [ -d /usr/share/ppd ]; then \ cupsppddir=/usr/share/ppd \ else \ cupsppddir=/usr/share/cups/model \ fi \ fi \ find . -type f -print | \\\ xargs perl -p -i -e "s!$cupsserverroot!%{_cupsserverroot}!g;" \\\ -e "s!$cupsserverbin!%{_cupsserverbin}!g;" \\\ -e "s!$cupsppddir(/[a-zA-Z1-9_\\-]+|)!%{_cupsppd}!g;" \\\ -e "s!$cupsdatadir!%{_cupsdatadir}!g;" \ fi \ %{nil} # This macro corrects settings in config.h, useful if "./configure" # auto-detects certain items in the build system and does not allow manual # setting of these items. By such corrections for example system files # can be installed under /opt and symlinked to the real place in the system # later by the maintainer scripts %config_h_set() \ echo %1 %2 \ %{nil} #%config_h_set() \ #perl -p -i -e 's!^(\\s*\\#define\\s+%1\\s*\\")\\S+(\\"\\s*)$!$1%2$2!' config.h \ #%{nil} #%config_h_set() \ #perl -p -i -e 's!^(\\s*\\#define\\s+%{1}\\s*\\")\\S+(\\"\\s*)$!$1%{2}$2!' config.h \ #%{nil} #%config_h_set() \ #perl -p -i -e 's!^(\\s*\\#define\\s+%{expand:%{1}}\\s*\\")\\S+(\\"\\s*)$!$1%{expand:%{2}}$2!' config.h \ #%{nil} # Replacement for "make", assures that correct destination directories are # used. Normally it is not needed, as "./configure" already sets these paths # correctly in the Makefile %make \ make \\\ prefix=%{_prefix} \\\ exec_prefix=%{_exec_prefix} \\\ bindir=%{_bindir} \\\ sbindir=%{_sbindir} \\\ sysconfdir=%{_sysconfdir} \\\ datadir=%{_datadir} \\\ includedir=%{_includedir} \\\ libdir=%{_libdir} \\\ libexecdir=%{_libexecdir} \\\ localstatedir=%{_localstatedir} \\\ sharedstatedir=%{_sharedstatedir} \\\ docdir=%{_docdir} \\\ mandir=%{_mandir} \\\ infodir=%{_infodir} # To be used anywhere in the build section # This macro builds PPDs from Foomatic XML data. It needs the Foomatic # database (with the Foomatic data of this driver added) in # $RPM_BUILD_DIR/foomatic-db and the source of the foomatic-db-engine # package in $RPM_BUILD_DIR/foomatic-db-engine* ('*' can be anything, # like a version number for example) %build_foomatic_ppds \ cd foomatic-db-engine* \ ./configure \ make CC=gcc inplace \ ./foomatic-compiledb -j 4 %{drivername} \ cd .. \ %{nil} # To be used after "make install" # Remove all developer files (C headers, static libs, ...) %remove_devel_files \ if [ "%{?optinstall}" = "1" ]; then \ rm -rf %{buildroot}%{_libdirglob} \ else \ rm -rf %{buildroot}%{_libdirglob}/pkg* \ rm -f %{buildroot}%{_libdirglob}/*.a \ rm -f %{buildroot}%{_libdirglob}/*.la \ fi \ rm -rf %{buildroot}%{_includedir} \ %{nil} # To be used after "make install" # Make CUPS filter paths in the PPDs absolute, rename and order files to # be compliant with LSB %adjust_ppds \ ( cd %{buildroot}%{_cupsppd} \ # Uncompress the PPDs, so that we can work on them \ for f in `find . -iname '*.ppd.gz' -print`; do \ gunzip "$f"; \ done \ for f in `find . -iname '*.ppd' -print`; do \ # Make link to CUPS filter absolute \ if [ -z "%{?filternames}" ]; then \ perl -p -i -e 's:(\\*cupsFilter\\:\\s*\\"\\S+\\s+\\d+\\s+)(?!foomatic-rip)(?!/)(\\S+\\"):$1%{_cupsserverbin}/filter/$2:' "$f" \ else \ for fn in `echo "%{?filternames}" | tr ',' ' '`; do \ fdir=`echo "$fn" | perl -p -e 's:^(.*?)[^/]+$:$1:' 2> /dev/null` \ if [ -z "$fdir" ]; then \ perl -e 'my $a = join("", <>); $a =~ s:(\\*FoomaticRIPCommandLine\\:\\s+\\"[^\\"]*?)(?!/)('"$fn"'):$1%{_bindir}/$2:sg; print $a' "$f" > "${f}.new" && \\\ mv -f "${f}.new" "$f" \ perl -e 'my $a = join("", <>); $a =~ s:(\\*cupsFilter\\:\\s+\\"[^\\"]*?)(?!/)('"$fn"'):$1%{_cupsserverbin}/filter/$2:sg; print $a' "$f" > "${f}.new" && \\\ mv -f "${f}.new" "$f" \ else \ fn=`echo "$fn" | perl -p -e 's:^.*?([^/]+)$:$1:'` \ perl -e 'my $a = join("", <>); $a =~ s:(\\*(cupsFilter|FoomaticRIPCommandLine)\\:\\s+\\"[^\\"]*?)(?!/)('"$fn"'):$1'"$fdir"'$3:sg; print $a' "$f" > "${f}.new" && \\\ mv -f "${f}.new" "$f" \ fi \ done \ fi \ # Read out manufacturer, model, language \ make=`grep '\\*Manufacturer:' "$f" | cut -d '"' -f 2` \ model=`grep '\\*ModelName:' "$f" | cut -d '"' -f 2 | perl -p -e "s/^${make}\\s+//i"` \ if [ -z "$make" ]; then \ make=`echo "$model" | cut -d ' ' -f 1` \ model=`echo "$model" | perl -p -e "s/^${make}\\s+//i"` \ fi \ # Replace PPD NickName if replacement specified in the specfile \ if [ -n "%{?ppdnickname}" ]; then \ makemodel=`echo "$make $model" | perl -p -e 's/\\s+/ /g'` \ perl -p -i -e 's:(\\*NickName\\:\\s*\\")[^\\"]*(\\"):$1'"$makemodel"'%{ppdnickname}$2:' "$f" \ fi \ # Determine UI language of the PPD \ if grep -q '\\*cupsLanguages:' "$f" 2>/dev/null; then \ lang="" \ else \ langstr=`grep '\\*LanguageVersion:' "$f" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\\r\\n]//gs'` \ case "$langstr" in \ "chinese") lang=zh;; \ "czech") lang=cs;; \ "danish") lang=da;; \ "dutch") lang=nl;; \ "english") lang=en;; \ "finnish") lang=fi;; \ "french") lang=fr;; \ "german") lang=de;; \ "greek") lang=el;; \ "hungarian") lang=hu;; \ "italian") lang=it;; \ "japanese") lang=ja;; \ "korean") lang=ko;; \ "norwegian") lang=no;; \ "polish") lang=pl;; \ "portuguese") lang=pt;; \ "russian") lang=ru;; \ "simplified chinese") lang=zh_CN;; \ "slovak") lang=sk;; \ "spanish") lang=es;; \ "swedish") lang=sv;; \ "traditional chinese") lang=zh_TW;; \ "turkish") lang=tr;; \ *) lang=en;; \ esac \ lang="-$lang" \ fi \ # Create new file name \ make=`echo "$make" | perl -p -e "s/[\\s_\\/]+/_/g" | perl -p -e "s/\\+/plus/g" | perl -p -e 's/_+$//'` \ model=`echo "$model" | perl -p -e "s/[\\s_\\/]+/_/g" | perl -p -e "s/\\+/plus/g" | perl -p -e 's/_+$//'` \ fnew=$make/$make-$model-%{drivername}$lang.ppd \ # Create a directory for the manufacturer if needed \ [ ! -d $make ] && mkdir $make \ # Move and rename it \ mv -f "$f" $fnew 2>/dev/null || : \ # Compress the PPD \ [ ! -e $fnew.gz ] && gzip -9 $fnew || rm -f $fnew \ # Directory where the PPD was located \ olddir=`echo "$f" | perl -p -e 's:^(.*?)/?[^/]+$:$1:' 2> /dev/null` \ # Remove the old directories recursively if empty \ while [ -n "$olddir" ] && rmdir $olddir 2>/dev/null; do \ olddir=`echo $olddir | perl -p -e 's:^(.*?)/?[^/]+$:$1:' 2> /dev/null` \ done \ done \ ) \ %{nil} # To be used after "make install" # Remove startup links generated by "make install", we generate them with # the LSB tools %remove_startup_links \ rm -rf %{buildroot}%{_sysconfdir}/rc?.d \ rm -rf %{buildroot}%{_rcdir}/rc?.d \ %{nil} # Install the script to put into /etc/profile.d (or to append to /etc/profile) # into /opt//profile.d # (only needed if we install in /opt) %__spec_install_post \ if [ "%{?optinstall}" = "1" ]; then \ if [ "%{?binexec}" = "1" ] || \\\ [ "%{?sbinexec}" = "1" ] || \\\ [ "%{?manpages}" = "1" ]; then \ # Install the script for adding the command line tool directories \ # to the $PATH \ mkdir -p %{buildroot}%{_prefix}/profile.d \ cp %{name}.sh %{buildroot}%{_prefix}/profile.d/%{name}.sh \ fi \ fi \ %{?__debug_package:%{__debug_install_post}}\ %{__arch_install_post}\ %{__os_install_post}\ %{nil} # For all maintainer scripts # All maintainer scripts should start with this piece of code, so that # all needed paths and environment variables are set %init_scriptlet \ # Source /etc/profile and all scripts in /etc/profile.d, so that PATHs and \ # other shell settings from other LSB packages get available \ if [ "%{?optinstall}" = "1" ]; then \ . /etc/profile \ for i in /etc/profile.d/*.sh; do if [ -x $i ]; then . $i; fi; done; unset i \ fi \ %{nil} # Bracket steps not to be done on updating the package %update_only \ if test "$1" = "upgrade" || test "$1" -gt "1" 2>/dev/null; then \ %{nil} %end_update_only \ fi \ %{nil} # For the pre-install script # Create directories for /opt installation %create_opt_dirs \ # Create some directories if they are missing. Usually, they should exist \ if [ "%{?optinstall}" = "1" ]; then \ mkdir /opt 2>/dev/null || true \ mkdir /etc/opt 2>/dev/null || true \ mkdir /var/opt 2>/dev/null || true \ fi \ %{nil} # For the post-install script # LSB requires that a login shell executes all .sh scripts in the # /etc/profile.d directory, unfortunately, many distros (Debian, Ubuntu, # LSB Build Environment) do not fulfill this. So work around by appending # the /etc/profile.d/%{name}.sh script to the file /etc/profile if the distro # is Debian-based ($1 is a string and not a number in a .deb package) or # if /etc/profile.d is missing (for example in the LSB Build Environment). %set_opt_paths \ if [ "%{?optinstall}" = "1" ]; then \ if test "$1" -ge "0" 2>/dev/null && test "$1" -le "9" 2>/dev/null && \\\ [ -d /etc/profile.d ]; then \ # RPM-based distro, /etc/profile.d \ ( /usr/lib/lsb/lsbinstall --package=%{name} --type=profile %{_prefix}/profile.d/%{name}.sh 2>/dev/null || \\\ ln -sf %{_prefix}/profile.d/%{name}.sh /etc/profile.d/ 2>/dev/null ) \ else \ # Debian-based distro (/etc/profile.d/ not supported, not LSB-compliant) \ # Remove old script \ perl -e 'my $a = join("", <>); $a =~ s/### LSB-RPM %{name}\\n.*\\n### LSB-RPM %{name}\\n//sg; print $a' /etc/profile > /etc/profile.new && \\\ mv -f /etc/profile.new /etc/profile \ # Add current script \ ( echo '### LSB-RPM %{name}'; \\\ cat %{_prefix}/profile.d/%{name}.sh; \\\ echo '### LSB-RPM %{name}' ) >> /etc/profile \ fi \ fi \ %{nil} # Symlink CUPS filters, backends and filter rules in /opt to the # system's CUPS directories so that CUPS finds them # This is only needed if the driver includes CUPS backends, CUPS # filters for file conversion, file type detection or file conversion # rules. # For a simple driver only containing a CUPS filter defined in the # PPD, using foomatic-rip, or consisting of only PPDs (e. g. for # PostScript printers) this is not needed. %set_cups_links \ if [ "%{?optinstall}" = "1" ]; then \ # Unfortunately, many distribution vendors put "cups-config" into the -devel \ # package of CUPS although having it in the standard installation is very \ # useful for driver developers to be able to make distribution-independent \ # install scripts. So we must fall back to standard locations if needed. \ if cups-config --version >/dev/null 2>/dev/null; then \ serverbin=`cups-config --serverbin` \ serverroot=`cups-config --serverroot` \ else \ serverbin=/usr/lib/cups \ serverroot=/etc/cups \ fi \ # Make filters available to CUPS \ if [ "%{?symlinkcupsfilters}" = "1" ] && \ [ -d $serverbin/filter ] && [ -d %{_cupsserverbin}/filter/ ]; then \ ( cd %{_cupsserverbin}/filter/ \ for f in `ls -1`; do \ ln -sf %{_cupsserverbin}/filter/$f $serverbin/filter/ \ done \ ) \ fi \ # Make backends available to CUPS \ if [ -d $serverbin/backend ] && [ -d %{_cupsserverbin}/backend/ ]; then \ ( cd %{_cupsserverbin}/backend/ \ for f in `ls -1`; do \ ln -sf %{_cupsserverbin}/backend/$f $serverbin/backend/ \ done \ ) \ fi \ # Register special file types and conversion rules to CUPS \ if [ -d $serverroot ] && [ -d %{_cupsserverroot} ]; then \ ( cd %{_cupsserverroot} \ for f in `ls -1 *.types *.convs 2>/dev/null`; do \ ln -sf %{_cupsserverroot}/$f $serverroot/0-%{name}-$f \ done \ ) \ fi \ fi \ %{nil} # Symlink the PPD directory in /opt to the system's PPD directory %set_ppd_links \ if [ "%{?optinstall}" = "1" ]; then \ ppddir=/usr/share/ppd \ # Remove old links to PPD file directory \ [ -h $ppddir/%{supplier}/ppds ] && rm -f $ppddir/%{supplier}/ppds \ [ -h $ppddir/%{supplier} ] && rm -f $ppddir/%{supplier} \ # Make PPD files available to CUPS \ ln -sf %{_cupsppd} $ppddir/%{supplier} 2>/dev/null || true \ fi \ %{nil} # Update PPD files of existing queues using a version of this driver # package Note that this is a specialized but therefore very fast # method. It only works if the PPDs were renamed by the %%adjust_ppds # macro and if the NickNames contain "OpenPrinting". Note that PPDs # get only updated if the CUPS daemon is running and if the CUPS tools # "lpadmin", "lpstat", and "lpinfo" are installed. If this is not the # case no error message will be displayed. %update_ppds_fast \ driverstr="%{driverstr}" \ supplier=%{supplier} \ supplierstr="%{supplierstr}" \ ppdrepo=%{_cupsppd} \ if cups-config --version >/dev/null 2>/dev/null; then \ serverroot=`cups-config --serverroot` \ else \ serverroot=/etc/cups \ fi \ cd $serverroot/ppd \ for ppd in *.ppd; do \ [ -r "$ppd" ] || continue \ queue=${ppd%.ppd} \ lpstat -h 127.0.0.1:631 -p "$queue" >/dev/null 2>&1 || continue \ if grep -qE '\\*NickName:.*\\b'"$driverstr"'\\b.*\\b'"$supplierstr"'\\b' "$ppd" 2> /dev/null; then \ make=`grep '\\*Manufacturer:' "$ppd" | cut -d '"' -f 2 | perl -p -e "s/[\\s_\\/]+/_/g" | perl -p -e "s/\\+/plus/g" | perl -p -e 's/_+$//'` \ model=`grep '\\*ModelName:' "$ppd" | cut -d '"' -f 2 | perl -p -e "s/[\\s_\\/]+/_/g" | perl -p -e "s/\\+/plus/g" | perl -p -e 's/_+$//' | perl -p -e "s/^${make}_+//i"` \ if [ -z "$make" ]; then \ make=`echo "$model" | cut -d '_' -f 1` \ model=`echo "$model" | perl -p -e "s/^${make}_+//i"` \ fi \ if grep -q '\\*cupsLanguages:' "$ppd" 2>/dev/null; then \ lang="" \ else \ langstr=`grep '\\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\\r\\n]//gs'` \ case "$langstr" in \ "chinese") lang=zh;; \ "czech") lang=cs;; \ "danish") lang=da;; \ "dutch") lang=nl;; \ "english") lang=en;; \ "finnish") lang=fi;; \ "french") lang=fr;; \ "german") lang=de;; \ "greek") lang=el;; \ "hungarian") lang=hu;; \ "italian") lang=it;; \ "japanese") lang=ja;; \ "korean") lang=ko;; \ "norwegian") lang=no;; \ "polish") lang=pl;; \ "portuguese") lang=pt;; \ "russian") lang=ru;; \ "simplified chinese") lang=zh_CN;; \ "slovak") lang=sk;; \ "spanish") lang=es;; \ "swedish") lang=sv;; \ "traditional chinese") lang=zh_TW;; \ "turkish") lang=tr;; \ *) lang=en;; \ esac \ lang="-$lang" \ fi \ if [ -z "$lpinfocache" ]; then \ trap 'rm -f "$lpinfocache" 2>/dev/null; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM 2>/dev/null || true \ lpinfocache=`mktemp -t %{name}-postinst.XXXXXX 2>/dev/null` \ [ -n "$lpinfocache" ] || lpinfocache="%{name}-postinst.$$" \ lpinfo -h 127.0.0.1:631 -m > "$lpinfocache" 2>/dev/null \ fi \ if [ -n "$lpinfocache" ]; then \ ppduri=`cat "$lpinfocache" | \\\ grep "$supplier/$make/$make-$model-%{drivername}$lang.ppd" | \\\ cut -d " " -f 1` && \\\ lpadmin -h 127.0.0.1:631 -p "$queue" -m "$ppduri" 2>/dev/null || true \ fi \ fi \ done \ [ -n "$lpinfocache" ] && rm -f $lpinfocache \ %{nil} # Try at first the LSB way to set up the daemons for automatic startup, # fall back to Red Hat and Debian methods on failure %setup_services \ if [ -n "%{?services}" ]; then \ for s in `echo "%{?services}" | tr ',' ' '`; do \ if [ "%{?optinstall}" = "1" ]; then \ # In case of an /opt installation, link the startup script \ # to the place where the LSB requires it \ mkdir -p /etc/init.d 2>/dev/null || true \ ln -sf %{_rcdir}/init.d/$s /etc/init.d/ 2>/dev/null \ fi \ if [ -x /etc/init.d/$s ]; then \ /usr/lib/lsb/install_initd /etc/init.d/$s 2>/dev/null || \\\ ( /sbin/chkconfig --add $s 2>/dev/null \ /sbin/chkconfig $s on 2>/dev/null ) || \\\ update-rc.d $s multiuser 19 >/dev/null 2>/dev/null \ fi \ done \ fi \ %{nil} # If there are PAM config files, link them to /etc/pam.d %setup_pam \ if [ "%{?optinstall}" = "1" ]; then \ if [ -d %{_pamdir} ] && [ -d /etc/pam.d ]; then \ ( cd %{_pamdir} \ for f in `ls -1`; do \ ln -sf %{_pamdir}/$f /etc/pam.d/ \ done \ ) \ fi \ fi \ %{nil} # For the post-install and the post-uninstall script # Restart CUPS to register special data types and PPD updates for existing # print queues (and the PPDs in case of CUPS 1.1.x) %restart_cups \ if [ -x /etc/init.d/cups ]; then \ cups="cups" \ else \ if [ -x /etc/init.d/cupsys ]; then \ cups="cupsys" \ fi \ fi \ if [ ! -z "$cups" ]; then \ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then \ invoke-rc.d $cups restart 2>/dev/null || true \ else \ /etc/init.d/$cups restart 2>/dev/null || true \ fi \ fi \ %{nil} # Restart daemons coming with this package %restart_services \ if [ -n "%{?services}" ]; then \ for s in `echo "%{?services}" | tr ',' ' '`; do \ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then \ invoke-rc.d $s restart 2>/dev/null || true \ else \ /etc/init.d/$s restart 2>/dev/null || true \ fi \ done \ fi \ %{nil} # For all ...-uninstall scripts # Bracket steps not to be done on RPM update with the following two # This has to be done on things removing infrastructure, as on an update # RPM runs the post-install of the new package before the uninstall scripts # of the old package, which makes the stuff set up by the post-install # removed again. %not_on_rpm_update \ if test "$1" != "1"; then \ %{nil} %end_not_on_rpm_update \ fi \ %{nil} # For the pre-uninstall script # Remove the script to add the search paths for the executables and man pages # in /opt # This is only needed if the driver includes CUPS backends, CUPS # filters for file conversion, file type detection or file conversion # rules. # For a simple driver only containing a CUPS filter defined in the # PPD, using foomatic-rip, or consisting of only PPDs (e. g. for # PostScript printers) this is not needed. %remove_opt_paths \ if [ "%{?optinstall}" = "1" ]; then \ if test "$1" -ge "0" 2>/dev/null && test "$1" -le "9" 2>/dev/null && \\\ [ -d /etc/profile.d ]; then \ # RPM-based distro \ /usr/lib/lsb/lsbinstall --package=%{name} --remove --type=profile %{_prefix}/profile.d/%{name}.sh 2>/dev/null || : \ if [ -h /etc/profile.d/%{name}.sh ]; then \ rm -f /etc/profile.d/%{name}.sh 2>/dev/null \ fi \ else \ # Debian-based distro (/etc/profile.d/ not supported, not LSB-compliant) \ perl -e 'my $a = join("", <>); $a =~ s/### LSB-RPM %{name}\\n.*\\n### LSB-RPM %{name}\\n//sg; print $a' /etc/profile > /etc/profile.new && \\\ mv -f /etc/profile.new /etc/profile \ fi \ fi \ %{nil} # Try at first the LSB way to remove the daemons from automatic startup, # fall back to Red Hat and Debian methods on failure %remove_services \ if [ -n "%{?services}" ]; then \ for s in `echo "%{?services}" | tr ',' ' '`; do \ if [ -x /etc/init.d/$s ]; then \ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then \ invoke-rc.d $s stop 2>/dev/null || true; \ else \ /etc/init.d/$s stop 2>/dev/null || true; \ fi; \ /usr/lib/lsb/remove_initd /etc/init.d/$s 2>/dev/null || \\\ ( /sbin/chkconfig $s off 2>/dev/null \ /sbin/chkconfig --del $s 2>/dev/null ) || \\\ update-rc.d $s remove >/dev/null 2>/dev/null \ fi \ if [ "%{?optinstall}" = "1" ]; then \ # In case of an /opt installation, remove the link of the \ # startup script to the place where the LSB requires it \ [ -h /etc/init.d/$s ] && rm -f /etc/init.d/$s 2>/dev/null \ fi \ done \ fi \ %{nil} # If there are PAM config files, remove them from /etc/pam.d %remove_pam \ if [ "%{?optinstall}" = "1" ]; then \ if [ -d %{_pamdir} ] && [ -d /etc/pam.d ]; then \ ( cd %{_pamdir} \ for f in `ls -1`; do \ [ -h /etc/pam.d/$f ] && rm -f /etc/pam.d/$f 2>/dev/null \ done \ ) \ fi \ fi \ %{nil} # For the post-uninstall script # Remove symlinks for making CUPS files in /opt available to the system's CUPS %remove_cups_links \ if [ "%{?optinstall}" = "1" ]; then \ # Find directories which CUPS is using \ if cups-config --version >/dev/null 2>/dev/null; then \ serverbin=`cups-config --serverbin` \ serverroot=`cups-config --serverroot` \ else \ serverbin=/usr/lib/cups \ serverroot=/etc/cups \ fi \ # Remove links for CUPS filters (symlinks which broke by the removal \ # of the package) \ if [ "%{?symlinkcupsfilters}" = "1" ] && [ -d $serverbin/filter ]; then \ ( cd $serverbin/filter/ \ for f in `ls -1`; do \ [ -h $f ] && [ ! -e $f ] && rm -f $f \ done \ ) \ fi \ # Remove links for CUPS backends (symlinks which broke by the removal \ # of the package) \ if [ -d $serverbin/backend ]; then \ ( cd $serverbin/backend/ \ for f in `ls -1`; do \ [ -h $f ] && [ ! -e $f ] && rm -f $f \ done \ ) \ fi \ # Unegister special file types and conversion rules from CUPS (symlinks \ # which broke by the removal of the package) \ if [ -d $serverroot ]; then \ ( cd $serverroot \ for f in `ls -1 0-%{name}-*.types 0-%{name}-*.convs 2>/dev/null`; do \ [ -h $f ] && [ ! -e $f ] && rm -f $f \ done \ ) \ fi \ fi \ %{nil} # Remove symlinks for making PPD files in /opt available to the system %remove_ppd_links \ if [ "%{?optinstall}" = "1" ]; then \ ppddir=/usr/share/ppd \ # Remove link to PPD file directory \ [ -d %{_cupsppd} ] && rmdir %{_cupsppd} 2> /dev/null \ [ -h $ppddir/%{supplier} ] && [ ! -e $ppddir/%{supplier} ] && \\\ rm -f $ppddir/%{supplier} \ [ -d $ppddir/%{supplier} ] && [ -h $ppddir/%{supplier}/ppds ] && \\\ [ ! -e $ppddir/%{supplier}/ppds ] && rm -f $ppddir/%{supplier}/ppds \ fi \ %{nil}