Bug 1828 - Script tags "size" property not being properly accounted for.
Status: RESOLVED FIXED
Alias: None
Product: Loki Setup
Classification: Unclassified
Component: General
Version: unspecified
Hardware: All Linux
: P2 normal
Assignee: St
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2004-06-28 12:11 EDT by Derek Gaston
Modified: 2004-06-28 15:42:51 EDT
0 users

See Also:



Description Derek Gaston 2004-06-28 12:11:33 EDT
In the XML specification it says that you can specify a size for scripts (in
case they copy some files).  But in reality the interface doesn't reflect this
when you select an option that contains script elements.

This change makes the program account for script "size" elements properly.

Again - I apologize for the format of the diff - I have no CVS access from here.


--- copy.c.old      2004-04-30 21:53:10.000000000 -0600
+++ copy.c      2004-06-28 08:58:06.000000000 -0600
@@ -746,6 +746,8 @@
 {
     struct cdrom_elem *cdrom;
     struct cdrom_elem *cdrom_start;
+    char *symlink = xmlGetProp(node, "size");
+
     int rc;

        if ( corrupts ) { /* Don't run any scripts while restoring files */
@@ -1198,32 +1200,48 @@
 /* Get the install size of an option tree, in bytes */
 unsigned long long size_tree(install_info *info, xmlNodePtr node)
 {
-    unsigned long long size = 0;
+       unsigned long long size = 0;

-    while ( node ) {
-        char *wanted;
+       while ( node )
+       {
+               char *wanted;

-               if ( ! strcmp(node->name, "option") ) {
+               if ( ! strcmp(node->name, "option") )
+               {
                        wanted = xmlGetProp(node, "install");
-                       if ( wanted  && (strcmp(wanted, "true") == 0) ) {
+                       if ( wanted  && (strcmp(wanted, "true") == 0) )
+                       {
                                size += size_node(info, node);
                                size += size_tree(info, node->childs);
                        }
+
                        xmlFree(wanted);
-               } else if ( !strcmp(node->name, "exclusive") ) {
+               }
+               else if ( !strcmp(node->name, "exclusive") )
+               {
                        size += size_tree(info, node->childs);
-        } else if ( !strcmp(node->name, "component") ) {
-            if ( match_arch(info, xmlGetProp(node, "arch")) &&
-                 match_libc(info, xmlGetProp(node, "libc")) &&
-                                match_distro(info, xmlGetProp(node, "distro")) ) {
-                size += size_tree(info, node->childs);
-            }
-               } else if ( !strcmp(node->name, "readme") || !strcmp(node->name,
"eula") ) {
+               }
+               else if ( !strcmp(node->name, "component") )
+               {
+                       if ( match_arch(info, xmlGetProp(node, "arch")) &&
+                               match_libc(info, xmlGetProp(node, "libc")) &&
+                               match_distro(info, xmlGetProp(node, "distro")) )
+                       {
+                               size += size_tree(info, node->childs);
+                       }
+               }
+               else if ( !strcmp(node->name, "readme") || !strcmp(node->name,
"eula") )
+               {
                        size += size_readme(info, node);
                }
-        node = node->next;
-    }
-    return size;
+               else if ( !strcmp(node->name, "script") )
+               {
+                       size += size_node(info, node);
+               }
+               node = node->next;
+       }
+
+       return size;
 }

 int has_binaries(install_info *info, xmlNodePtr node)
Comment 1 St 2004-06-28 14:03:14 EDT
OK, that sounds like a legitimate bug. In the future though, avoid changing the indentations of code too 
much in your patches because it increases the size needlessly and makes it harder to follow...
Comment 2 St 2004-06-28 14:11:57 EDT
The fix is now in CVS.
Comment 3 Derek Gaston 2004-06-28 14:43:38 EDT
Right, sorry about that.

I wouldn't normally do that - but the indentation in that part of the code was
so terrible that I couldn't decipher it.

I'll not do that in the future.
Comment 4 Derek Gaston 2004-06-28 15:27:12 EDT
Something else I just noticed in my patch... the:

char *symlink = xmlGetProp(node, "size");

line that is at the top need NOT be present for this patch to work.  That is
part of a different patch that I'm working on (so that the progress bars are
updated correctly for scripts).  Sorry about that - I will screen my diffs a
little better in the future.

Derek
Comment 5 St 2004-06-28 15:42:51 EDT
Not to worry... I screened your patch and only manually included the relevant four lines that fixed the 
bug. ;-)