rpms/cups-pdf/F-8 cups-pdf-desktop.patch, NONE, 1.1 cups-pdf.spec, 1.6, 1.7

Remi Collet (remi) fedora-extras-commits at redhat.com
Sat Nov 24 15:42:28 UTC 2007


Author: remi

Update of /cvs/extras/rpms/cups-pdf/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19938

Modified Files:
	cups-pdf.spec 
Added Files:
	cups-pdf-desktop.patch 
Log Message:
add patch for desktop path and selinux

cups-pdf-desktop.patch:

--- NEW FILE cups-pdf-desktop.patch ---
--- src/cups-pdf.c.orig	2007-05-04 13:48:54.000000000 +0200
+++ src/cups-pdf.c	2007-09-15 11:59:41.000000000 +0200
@@ -287,6 +287,45 @@
   return 0;
 }
 
+static char *getdesktopdir(struct passwd *passwd) {
+	static char bufret[BUFSIZE];
+	char *need, *ret, buftmp[BUFSIZE];
+	FILE *fic;
+
+	// Default (if not found) = $HOME
+	ret=passwd->pw_dir;
+
+	snprintf(buftmp, BUFSIZE, "%s/.config/user-dirs.dirs", passwd->pw_dir);
+	fic = fopen(buftmp, "r");
+	if (fic) {
+		while (fgets(buftmp, BUFSIZE, fic)) {
+			need=strstr(buftmp, "XDG_DESKTOP_DIR=");
+			if (need) {
+				need+=16;
+				// Remove opening quote
+				if (*need='"') need++;
+				if (memcmp(need, "$HOME", 5)) {
+					strncpy(bufret, need, BUFSIZE);
+				}
+				else {
+					snprintf(bufret, BUFSIZE, "%s%s", passwd->pw_dir, need+5);
+				}
+				// Remove closing quote
+				need=strrchr(bufret, '"');
+				if (need) *need=0;
+				// Return internal buffer
+				ret = bufret;
+				
+			        log_event(CPDEBUG, "XDG_DESKTOP_DIR:", ret);
+			}
+		} 
+		fclose(fic);
+	}
+	else
+	        log_event(CPERROR, "Can't read", buftmp);
+	return ret;
+}
+
 static char *preparedirname(struct passwd *passwd, char *uname) {
   int size;
   char bufin[BUFSIZE], bufout[BUFSIZE], *needle, *cptr;
@@ -297,6 +336,15 @@
 
   strncpy(bufin, conf.out, BUFSIZE);
   do {
+    needle=strstr(bufin, "${DESKTOP}");
+    if (needle == NULL)
+      break;
+    needle[0]='\0';
+    cptr=needle+10;
+    snprintf(bufout, BUFSIZE, "%s%s%s", bufin, getdesktopdir(passwd), cptr);
+    strncpy(bufin, bufout, BUFSIZE);
+  } while (needle != NULL);
+  do {
     needle=strstr(bufin, "${HOME}");
     if (needle == NULL)
       break;


Index: cups-pdf.spec
===================================================================
RCS file: /cvs/extras/rpms/cups-pdf/F-8/cups-pdf.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- cups-pdf.spec	23 Aug 2007 15:28:19 -0000	1.6
+++ cups-pdf.spec	24 Nov 2007 15:41:55 -0000	1.7
@@ -12,13 +12,14 @@
 Summary(fr):    Extension de CUPS pour créer des fichiers PDF
 Name:           cups-pdf
 Version:        2.4.6
-Release:        3%{?dist}
+Release:        4%{?dist}
 Group:          Applications/Publishing
 Source0:        http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/src/%{name}_%{version}.tar.gz
 Source1:        INSTALL.cups-pdf
 Source2:        INSTALL.fedora.cups-pdf
 Source3:        %{module}.te
 Patch1:         cups-pdf-conf.patch
+Patch2:         cups-pdf-desktop.patch
 URL:            http://cip.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/
 License:        GPLv2+
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -63,6 +64,7 @@
 de l'utilisateur (dossier Desktop du répertoire d'accueil de l'utilisateur).
 Ce comportement peut être modifié en éditant le fichier de configuration.
 
+
 %prep
 echo CIBLE = %{name}-%{version}-%{release}
 %setup -q -n %{name}-%{version}
@@ -70,7 +72,8 @@
 %{__cp} %{SOURCE2} INSTALL.fedora
 
 # Relocate output on user's Desktop
-%patch1 -p0
+%patch1 -p0 -b .oldconf
+%patch2 -p0 -b .desktop
 
 %if %{usesel}
 echo Will Use SE Linux
@@ -78,11 +81,13 @@
 echo Will NOT use SE Linux
 %endif
 
+
 %build
 pushd src
 %{__cc} $RPM_OPT_FLAGS -o cups-pdf cups-pdf.c
 popd
 
+
 %if %{usesel}
 # SElinux 
 %{__mkdir} selinux
@@ -99,6 +104,7 @@
 %{__chmod} -x contrib/cups-pdf-dispatch-0.1/cups-pdf-dispatch
 %{__chmod} -x contrib/SELinux-HOWTO/update-module
 
+
 %install
 rm -rf %{buildroot}
 %{__mkdir_p} %{buildroot}%{CPBACKEND}
@@ -119,9 +125,11 @@
 %{__install} -m644 selinux/%{module}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/%{module}.pp
 %endif
 
+
 %clean
 rm -rf %{buildroot}
 
+
 %files
 %defattr(-,root,root)
 %doc ChangeLog COPYING README INSTALL INSTALL.fedora contrib/
@@ -134,6 +142,7 @@
 %{_datadir}/selinux/packages/%{name}/%{module}.pp
 %endif
 
+
 %post
 %if %{usesel}
 # Install/update Selinux policy
@@ -141,6 +150,7 @@
 fixfiles -R %{name} restore
 %endif
 
+
 # First install : create the printer if cupsd is running
 if [ "$1" -eq "1" -a -f "%{_var}/run/cupsd.pid" ]
 then
@@ -155,6 +165,7 @@
     fi
 fi
 
+
 %postun
 if [ "$1" -eq "0" ]; then
     # Delete the printer
@@ -166,7 +177,11 @@
 %endif
 fi
 
+
 %changelog
+* Sat Nov 24 2007 Remi Collet <Fedora at FamilleCollet.com> 2.4.6-4
+- add cups-pdf-desktop.patch to work with xdg prefs
+
 * Thu Aug 23 2007 Remi Collet <Fedora at FamilleCollet.com> 2.4.6-3
 - Fix License
 - F-8 rebuild (BuildID)




More information about the fedora-extras-commits mailing list