#11021: clean up sage-spkg
--------------------------+-------------------------------------------------
   Reporter:  jhpalmieri  |          Owner:  tbd           
       Type:  defect      |         Status:  needs_review  
   Priority:  minor       |      Milestone:  sage-4.7.1    
  Component:  packages    |       Keywords:                
Work_issues:              |       Upstream:  N/A           
   Reviewer:  Kelvin Li   |         Author:  Leif Leonhardy
     Merged:              |   Dependencies:                
--------------------------+-------------------------------------------------

Comment(by leif):

 Replying to [comment:8 ltw]:
 > Replying to [comment:6 leif]:
 > > Ok, though I wouldn't have changed the "error" message; the previous
 one sounds a bit friendlier. (Actually a non-zero status code can have a
 couple of reasons there, but I don't mind. ;-) )
 >
 > A few lines above, there is an error message {{{"Package $PKG_NAME not
 found"}}}. So I thought {{{"File SPKG.txt not found in package
 $PKG_NAME"}}} would follow the same grammar. But I can change it back, no
 problem. :-)

 What about ''"Could not extract SPKG.txt."'' or better ''"Package
 $PKG_NAME appears to have no SPKG.txt."''?

 Redirecting `stderr` '''of the `tar` commands''' to `/dev/null` is a bit
 odd there. On the other hand, the presence of `$PKG_SRC` (the spkg file)
 itself is checked '''twice''' a few lines above, so a non-zero exit code
 of `tar` most probably means either a corrupted tarball or the file to
 extract wasn't found. Maybe the proper way would be to first try to list
 the file (`tar tf - ... 2>/dev/null`) into some shell variable and check
 if it is empty (or, better, list the tarball's whole contents grepping for
 `$PKG_NAME/SPKG.txt`), and use `bunzip2 -t ...` to test whether the spkg
 is compressed in advance.

 Or verify the spkg '''wasn't''' corrupted in case of an error (`$? -ne
 0`):
 {{{
 #!sh
     ...
     if [ $? -ne 0 ]; then
         # Extracting SPKG.txt failed for *some* reason,
         # now check if it's simply missing:
         if (bunzip2 -c "$PKG_SRC" | tar tf -) &>/dev/null ||
            tar tf "$PKG_SRC" &>/dev/null
         then
             echo "Package $PKG_NAME lacks a description (SPKG.txt file)."
             exit 1
         else
             echo "$PKG_SRC seems to be corrupted. Exiting."
             exit 1 # or some other error code
         fi
     fi
     exit 0
 fi
 }}}

 But IMHO a rather minor issue.

 [[BR]]

 > > (We could e.g. pipe the `tar` output to some sort of `sed -e '/==
 Changelog ==/,$d'` and perhaps give some message indicating it was
 omitted.
 >
 > That's pretty hackish in my opinion. It would impose an undocumented
 constraint on the format of SPKG.txt, which does not have any formatting
 validation otherwise. I'm not sure that truncating SPKG.txt is even
 desirable.

 `SPKG.txt` files are supposed to have a quite clear structure, with ReST
 (section) mark-up (which an spkg reviewer should check btw). If there's no
 line matching `== Changelog ==` -- or preferably a more generic, i.e.
 robust pattern, nothing would get omitted.

 But as I said, I have no opinion on truncating them there.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11021#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to