[yast-commit] r58065 - in /trunk/printer: src/Printerlib.ycp src/basicadd.ycp src/basicmodify.ycp tools/autodetect_print_queues tools/modify_cupsd_conf
Author: jsmeix
Date: Wed Jul 15 16:44:55 2009
New Revision: 58065
URL: http://svn.opensuse.org/viewcvs/yast?rev=58065&view=rev
Log:
Fixed bnc#520612 - CUPS 1.4: yast2-printer:
several seconds delay until cupsd writes printers.conf
Modified:
trunk/printer/src/Printerlib.ycp
trunk/printer/src/basicadd.ycp
trunk/printer/src/basicmodify.ycp
trunk/printer/tools/autodetect_print_queues
trunk/printer/tools/modify_cupsd_conf
Modified: trunk/printer/src/Printerlib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=58065&r1=58064&r2=58065&view=diff
==============================================================================
--- trunk/printer/src/Printerlib.ycp (original)
+++ trunk/printer/src/Printerlib.ycp Wed Jul 15 16:44:55 2009
@@ -36,7 +36,7 @@
import "Package";
import "Popup";
import "Service";
-import "Map";
+
// Fortunately the tools are for all architectures always
// installed in /usr/lib/YaST2/bin/ (i.e. no "lib64").
// I tested this on Thu Aug 28 2008 using the command
@@ -512,6 +512,35 @@
return true;
}
+// By default there is no DirtyCleanInterval entry in /etc/cups/cupsd.conf
+// and then the default delay until cupsd writes config files like printers.conf
+// is 30 seconds which is also used here as fallback.
+global integer cupsd_conf_dirty_clean_interval = 30;
+
+global boolean DetermineDirtyCleanInterval()
+{ // Determine the DirtyCleanInterval value in /etc/cups/cupsd.conf:
+ if( ExecuteBashCommand( yast_bin_dir + "modify_cupsd_conf DirtyCleanInterval" ) )
+ { string dirty_clean_interval_string = filterchars( result["stdout"]:"30", "0123456789" );
+ if( "" != dirty_clean_interval_string
+ && nil != tointeger( dirty_clean_interval_string )
+ )
+ { cupsd_conf_dirty_clean_interval = tointeger( dirty_clean_interval_string );
+ }
+ else
+ { // Use fallback value when there is no DirtyCleanInterval entry or
+ // when the DirtyCleanInterval value cannot be converted to an integer:
+ cupsd_conf_dirty_clean_interval = 30;
+ }
+ }
+ else
+ { // Use fallback value when the command above failed:
+ cupsd_conf_dirty_clean_interval = 30;
+ return false;
+ }
+ return true;
+}
+
+
global boolean WriteCupsSettings(map ay){
string cups_file="/etc/cups/cupsd.conf";
y2milestone("Create backup of %1 file:%2", cups_file, SCR::Execute(.target.bash, sformat("mv %1 %1.$(date -I)", cups_file)));
@@ -519,7 +548,6 @@
return true;
}
-
global boolean WriteClientSettings(map ay){
string cups_file="/etc/cups/client.conf";
y2milestone("Create backup of %1 file:%2", cups_file, SCR::Execute(.target.bash, sformat("mv %1 %1.$(date -I)", cups_file)));
Modified: trunk/printer/src/basicadd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/basicadd.ycp?rev=58065&r1=58064&r2=58065&view=diff
==============================================================================
--- trunk/printer/src/basicadd.ycp (original)
+++ trunk/printer/src/basicadd.ycp Wed Jul 15 16:44:55 2009
@@ -310,6 +310,35 @@
// After a local queue was added, enforce to show also local queues
// in particular when no local queues were shown before:
Printer::queue_filter_show_local = true;
+ // Up to CUPS 1.3 cupsd writes changes to config files immediately so that the updated files
+ // will be available after the corresponding command, function call, or IPP operation is completed.
+ // Since CUPS 1.4 the new DirtyCleanInterval directive controls the delay when cupsd updates config files,
+ // which defaults to 30 seconds. Setting it to 0 will have it write the changes on the next pass through
+ // the main run loop - less immediate than before, but still should be within a few milliseconds.
+ // To be on the safe side regarding "within a few milliseconds" (which could become much more
+ // depending on which processes the scheduler lets run - in particular cupsd versus yast2-printer)
+ // autodetect_print_queues sleeps in any case at least one second before it reads printers.conf
+ // but any value greater than 0 requires to wait here too:
+ Printerlib::DetermineDirtyCleanInterval();
+ y2milestone( "Waiting DirtyCleanInterval='%1' seconds in 'Add' dialog.",
+ Printerlib::cupsd_conf_dirty_clean_interval
+ );
+ if( Printerlib::cupsd_conf_dirty_clean_interval > 0 )
+ { Popup::ShowFeedback( _("Created New Printer Setup"),
+ _("It needs up to half a minute for the new setup to become ready to operate...")
+ );
+ if( Printerlib::cupsd_conf_dirty_clean_interval <= 30 )
+ { sleep( 1000 * Printerlib::cupsd_conf_dirty_clean_interval );
+ Popup::ClearFeedback();
+ }
+ else
+ { sleep( 30000 );
+ Popup::ClearFeedback();
+ Popup::TimedMessage( _("Must wait some more time until the new printer setup is ready to operate..."),
+ Printerlib::cupsd_conf_dirty_clean_interval - 30
+ );
+ }
+ }
Wizard::EnableBackButton();
Wizard::EnableNextButton();
// Exit this dialog in any case:
Modified: trunk/printer/src/basicmodify.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/basicmodify.ycp?rev=58065&r1=58064&r2=58065&view=diff
==============================================================================
--- trunk/printer/src/basicmodify.ycp (original)
+++ trunk/printer/src/basicmodify.ycp Wed Jul 15 16:44:55 2009
@@ -604,6 +604,35 @@
}
}
}
+ // Up to CUPS 1.3 cupsd writes changes to config files immediately so that the updated files
+ // will be available after the corresponding command, function call, or IPP operation is completed.
+ // Since CUPS 1.4 the new DirtyCleanInterval directive controls the delay when cupsd updates config files,
+ // which defaults to 30 seconds. Setting it to 0 will have it write the changes on the next pass through
+ // the main run loop - less immediate than before, but still should be within a few milliseconds.
+ // To be on the safe side regarding "within a few milliseconds" (which could become much more
+ // depending on which processes the scheduler lets run - in particular cupsd versus yast2-printer)
+ // autodetect_print_queues sleeps in any case at least one second before it reads printers.conf
+ // but any value greater than 0 requires to wait here too:
+ Printerlib::DetermineDirtyCleanInterval();
+ y2milestone( "Waiting DirtyCleanInterval='%1' seconds in 'Modify' dialog.",
+ Printerlib::cupsd_conf_dirty_clean_interval
+ );
+ if( Printerlib::cupsd_conf_dirty_clean_interval > 0 )
+ { Popup::ShowFeedback( _("Modified Printer Setup"),
+ _("It needs up to half a minute for the modified configuration to become usable...")
+ );
+ if( Printerlib::cupsd_conf_dirty_clean_interval <= 30 )
+ { sleep( 1000 * Printerlib::cupsd_conf_dirty_clean_interval );
+ Popup::ClearFeedback();
+ }
+ else
+ { sleep( 30000 );
+ Popup::ClearFeedback();
+ Popup::TimedMessage( _("Must wait some more time until the modified printer configuration is usable..."),
+ Printerlib::cupsd_conf_dirty_clean_interval - 30
+ );
+ }
+ }
Wizard::EnableBackButton();
Wizard::EnableNextButton();
}
Modified: trunk/printer/tools/autodetect_print_queues
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/autodetect_print_queues?rev=58065&r1=58064&r2=58065&view=diff
==============================================================================
--- trunk/printer/tools/autodetect_print_queues (original)
+++ trunk/printer/tools/autodetect_print_queues Wed Jul 15 16:44:55 2009
@@ -127,7 +127,7 @@
# a local queue (in /etc/cups/printers.conf) and a remote queue (on another host) and
# therefore /etc/cups/printers.conf is directly inspected to distinguish local and remote queues.
# Reason:
-# In the CUPS sources systemv/lpstat.c uses CUPS_PRINTER_REMOTE to distinguish between
+# In the CUPS sources systemv/lpstat.c uses only CUPS_PRINTER_REMOTE to distinguish between
# its output "Connection: remote" and "Connection: direct".
# But the new support for "hard-wired" remote printers has muddied the waters:
# CUPS_PRINTER_REMOTE means that the printer is hosted (does filtering) on a remote system.
@@ -135,13 +135,21 @@
# If both bits are set, then the queue is a traditional CUPS browsing remote printer.
# If CUPS_PRINTER_DISCOVERED is not set, it is a local queue but filtering happens remote.
# Summary table:
-# Type CUPS_PRINTER_RREMOTE CUPS_PRINTER_DISCOVERED
-# --------------------- -------------------- -----------------------
-# Local queue No No
-# CUPS-browsing printer Yes Yes
-# Raw IPP queue Yes No
-# Bonjour queue Yes No
-
+# Type CUPS_PRINTER_RREMOTE CUPS_PRINTER_DISCOVERED exists in printers.conf
+# --------------------- -------------------- ----------------------- -----------------------
+# Local queue No No Yes
+# CUPS-browsing printer Yes Yes No
+# Raw IPP queue Yes No Yes
+# Bonjour queue Yes No (I don't know)
+# Up to CUPS 1.3 cupsd writes changes to config files immediately so that the updated files
+# will be available after the corresponding command, function call, or IPP operation is completed.
+# Since CUPS 1.4 the new DirtyCleanInterval directive controls the delay when cupsd updates config files,
+# which defaults to 30 seconds. Setting it to 0 will have it write the changes on the next pass through
+# the main run loop - less immediate than before, but still should be within a few milliseconds.
+# To be on the safe side regarding "within a few milliseconds" (which could become much more
+# depending on which processes the scheduler lets run - in particular cupsd versus yast2-printer)
+# it sleeps in any case at least one second before it reads printers.conf.
+sleep 1
exec <$TMP_DATA
while read KEY VALUE
do case "$KEY" in
Modified: trunk/printer/tools/modify_cupsd_conf
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/modify_cupsd_conf?rev=58065&r1=58064&r2=58065&view=diff
==============================================================================
--- trunk/printer/tools/modify_cupsd_conf (original)
+++ trunk/printer/tools/modify_cupsd_conf Wed Jul 15 16:44:55 2009
@@ -40,6 +40,9 @@
echo " (The policy-name must exist as a '<Policy policy-name>' section)" 1>&2
echo "ErrorPolicy [ stop-printer | retry-job | abort-job ]" 1>&2
echo " (if ErrorPolicy is not set, stop-printer is the CUPS default)" 1>&2
+ echo "DirtyCleanInterval [ seconds ] (since CUPS 1.4)" 1>&2
+ echo "e.g.: DirtyCleanInterval 30 (default 30 seconds delay until cupsd writes config files)" 1>&2
+ echo " DirtyCleanInterval 0 (update config files like printers.conf almost immediately)" 1>&2
echo "For the syntax for keywords and values see 'man cupsd.conf'" 1>&2
echo "and http://www.cups.org/documentation.php/ref-cupsd-conf.html" 1>&2
echo "In case of ambiguity use the syntax which is described above." 1>&2
@@ -83,15 +86,22 @@
then # Try to substitute an existing active Browsing line (ignore case).
# (If there is more than one active Browsing line it is a broken config file):
sed -i -e "s/^[[:space:]]*$KEY.*/$KEY $VALUE/i" $CUPSDCONF
- # There may exist no Browsing line:
+ # There may exist no Browsing line or the above substitute may have failed
+ # (therefore it tests not only for "^$KEY" but for "^$KEY $VALUE$"):
if ! grep -q "^$KEY $VALUE$" $CUPSDCONF
then # Append a Browsing line below the last active 'Brows' line (ignore case)
# to have the new Browsing line at the matching place
- # but if no 'Brows' line exists, append at the end of the file:
+ # but if no 'Brows' line exists, append below the first empty line
+ # which is usually the line after the initial comment block
+ # and if even no empty line exists, append at the end of the file:
LAST_BROWSE_LINE_NUMBER="$( sed -n -e '/^[^#]*Brows/I=' $CUPSDCONF | tail -n 1 )"
if test -n "$LAST_BROWSE_LINE_NUMBER"
then sed -i -e "${LAST_BROWSE_LINE_NUMBER}a$KEY $VALUE" $CUPSDCONF
- else echo -en "\n$KEY $VALUE\n\n" >>$CUPSDCONF
+ else FIRST_EMPTY_LINE_NUMBER="$( sed -n -e '/^[[:space:]]*$/=' $CUPSDCONF | head -n 1 )"
+ if test -n "$FIRST_EMPTY_LINE_NUMBER"
+ then sed -i -e "${FIRST_EMPTY_LINE_NUMBER}a$KEY $VALUE\n" $CUPSDCONF
+ else echo -en "\n$KEY $VALUE\n\n" >>$CUPSDCONF
+ fi
fi
fi
fi
@@ -123,11 +133,17 @@
sed -i -e '/^[[:space:]]*BrowseOrder.*/Id' $CUPSDCONF
# Append the new BrowseOrder line below the last active 'Brows' line (ignore case)
# to have the new BrowseOrder line at the matching place
- # but if no 'Brows' line exists, append at the end of the file:
+ # but if no 'Brows' line exists, append below the first empty line
+ # which is usually the line after the initial comment block
+ # and if even no empty line exists, append at the end of the file:
LAST_BROWSE_LINE_NUMBER="$( sed -n -e '/^[^#]*Brows/I=' $CUPSDCONF | tail -n 1 )"
if test -n "$LAST_BROWSE_LINE_NUMBER"
then sed -i -e "${LAST_BROWSE_LINE_NUMBER}aBrowseOrder allow,deny" $CUPSDCONF
- else echo -en "\nBrowseOrder allow,deny\n\n" >>$CUPSDCONF
+ else FIRST_EMPTY_LINE_NUMBER="$( sed -n -e '/^[[:space:]]*$/=' $CUPSDCONF | head -n 1 )"
+ if test -n "$FIRST_EMPTY_LINE_NUMBER"
+ then sed -i -e "${FIRST_EMPTY_LINE_NUMBER}aBrowseOrder allow,deny\n" $CUPSDCONF
+ else echo -en "\nBrowseOrder allow,deny\n\n" >>$CUPSDCONF
+ fi
fi
# All existing active BrowseAllow lines are removed (ignore case).
# Those lines can be removed because YaST supports BrowseAllow lines
@@ -188,10 +204,16 @@
# Insert the mandatory 'Listen localhost' line (see http://www.cups.org/str.php?L2834
# "What is *not* supported is a configuration where only a domain socket is enabled")
# to have the new Listen line where the first active Listen line was
- # but if no 'Listen' line exists, append at the end of the file:
+ # but if no 'Listen' line exists, append below the first empty line
+ # which is usually the line after the initial comment block
+ # and if even no empty line exists, append at the end of the file:
if test -n "$FIRST_LISTEN_LINE_NUMBER"
then sed -i -e "${FIRST_LISTEN_LINE_NUMBER}iListen localhost:631" $CUPSDCONF
- else echo -en "\nListen localhost:631\n\n" >>$CUPSDCONF
+ else FIRST_EMPTY_LINE_NUMBER="$( sed -n -e '/^[[:space:]]*$/=' $CUPSDCONF | head -n 1 )"
+ if test -n "$FIRST_EMPTY_LINE_NUMBER"
+ then sed -i -e "${FIRST_EMPTY_LINE_NUMBER}iListen localhost:631\n" $CUPSDCONF
+ else echo -en "\nListen localhost:631\n\n" >>$CUPSDCONF
+ fi
fi
# Append a Listen line for the domain socket (if such a line was there):
if test -n "$LISTEN_DOMAIN_SOCKET_LINE_CONTENT"
@@ -254,10 +276,16 @@
# Set 'Order allow,deny' in the root location to deny packets by default
# and then allow them from certain sources via Allow entries
# and finally deny from certain sources via Deny entries.
- # but if no root location was there, append at the end of the file:
+ # If no root location was there, append it below the first empty line
+ # which is usually the line after the initial comment block
+ # and if even no empty line exists, append at the end of the file:
if test -n "$ROOT_LOCATION_LINE_NUMBER"
then sed -i -e "${ROOT_LOCATION_LINE_NUMBER}i<Location />\nOrder allow,deny\nAllow 127.0.0.2\n</Location>" $CUPSDCONF
- else echo -en "\n<Location />\nOrder allow,deny\nAllow 127.0.0.2\n</Location>\n\n" >>$CUPSDCONF
+ else FIRST_EMPTY_LINE_NUMBER="$( sed -n -e '/^[[:space:]]*$/=' $CUPSDCONF | head -n 1 )"
+ if test -n "$FIRST_EMPTY_LINE_NUMBER"
+ then sed -i -e "${FIRST_EMPTY_LINE_NUMBER}a<Location />\nOrder allow,deny\nAllow 127.0.0.2\n</Location>\n" $CUPSDCONF
+ else echo -en "\n<Location />\nOrder allow,deny\nAllow 127.0.0.2\n</Location>\n\n" >>$CUPSDCONF
+ fi
fi
# Determine (again) where the new root location starts (exact match):
ROOT_LOCATION_LINE_NUMBER="$( sed -n -e '/
participants (1)
-
jsmeix@svn.opensuse.org