[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help (Was: Bug#699260: r-cran-genabel: FTBFS: error: subscript out of bounds)

On Tue, 29 Jan 2013, Andreas Tille wrote:
> because I'm lacking the relevant R knowledge (and I also fail in finding
> some relevant R/CRAN packaging team inside Debian) I'm writing to Debian
> Mentors and main R packages maintainer.  I guess with some basic R knowledge
> the problem below is easy to solve.  I checked the source of r-cran-genabel
> package and found the problematic function only in one single file:
> ../r-cran-genabel-1.7-0$ grep -Rl "stringSplit" 
> R/checkPackageVersionOnCRAN.R
> When reading its only quite short function
> checkPackageVersionOnCRAN <- function(packageName,baseUrlCRAN="http://cran.r-project.org/web/packages/";, timeout = 10)
> {
>         # change default timout
>         svtmo <- options("timeout")
>         options("timeout"=timeout)
>         # page to check is
>         pageAddress <- paste(baseUrlCRAN,packageName,sep="/")
> ...
>         # parse the page and get string starting with "Package source:"
>         targetLine <- pageContent[grep("Package source:",pageContent)]
>         # split the string at "Package_" and ".tar.gz"; the element before the last will contain the version
>         splitPattern <- paste(packageName,"_|.tar.gz",sep="")
>         stringSplit <- strsplit(targetLine,splitPattern)
>         cranVersion <- stringSplit[[1]][length(stringSplit[[1]])-1]
>         # return version
>         return(cranVersion)
> }
> this heavily smells like the attempt to verify a web page while
> beeing offline. IMHO the proper fix for this would be to return for
> instance the version of the Debian package or some other reasonable
> thing - but in any case it should be avoided trying to split a
> non-existing string or so.
> Any hint for a reasonable patch?

This sounds like it's trying to figure out what the cran version is,
and then reporting it. I'd personally just get rid of the call to this
function, because there's no reason for it in the Debian package.

However, you can also do something like:

         splitPattern <- paste(packageName,"_|.tar.gz",sep="")
         stringSplit <- strsplit(targetLine,splitPattern)
         if (length(stringSplit) < 1)
              cranVersion <- "Unknown"
         } else {
              cranVersion <- stringSplit[[1]][length(stringSplit[[1]])-1]
         # return version


Don Armstrong

6: I'm human. I have a thousand flaws. I break down. I get up or I
don't get up. I get lost. I make the same mistakes over and over. I
have scars and wounds. Sometimes when I can't bear them anymore, I
drink. You can't fix me. You can't fix any of us. You can't make us
 -- "The Prisoner (2009 Miniseries)" _Checkmate_

http://www.donarmstrong.com              http://rzlab.ucr.edu

Reply to: