Problems running pkgdb -fF

Parv parv at pair.com
Mon Mar 19 23:04:07 UTC 2007


in message <1174330341.26866.32.camel at shumai.marcuscom.com>,
wrote Joe Marcus Clarke thusly...
>
> Running pkgdb -Ff today gives me the following error:
> 
> Stale origin: 'multimedia/totem-gstreamer': perhaps moved or obsoleted.
> -> The port 'multimedia/totem-gstreamer' was moved to 'multimedia/totem' on 2007-03-19 because:
>         "multimedia/totem now uses gstreamer by default"
> sed: 1: "s|^\(@comment[": unbalanced brackets ([])
> Failed to rewrite /var/db/pkg/totem-gstreamer-2.16.5/+CONTENTS: Command failed [exit code 1]: "sed" "\"s|^\\\\(@comment[\"" "\"\"" "\"][\"" "\"\"" "\"]*ORIGIN:\\\\).*\\\$|\\\\1multimedia/totem|\"" "<" "/var/db/pkg/totem-gstreamer-2.16.5/+CONTENTS" ">" "/tmp/+CONTENTS.71426.0"
> 
> This is with portupgrade 2.2.6_2,2 on both 6-STABLE i386 and
> 7-CURRENT amd64.  I don't think I did anything funky with the
> totem MOVED entry.  This seems to be a problem with pkgdb.

Looks like sed command gets broken on unescaped|uncared-for otherwise
important space character.  The command is being made in
modify_origin() in pkgtools.rb ...

 792   if grep_q_file(/^@comment[ \t]+ORIGIN:/, contents_file)
 793     command = shelljoin('sed',
 794             "s|^\\(@comment[ \t][ \t]*ORIGIN:\\).*$|\\1#{origin}|")
 795   else
 796     command = "(cat; echo '@comment ORIGIN:#{origin}')"
 797   end
 798
 799   filter_file(command, contents_file)


... which is being executed in filter_file() ...

 838   xsystem("#{command} < #{file} > #{tmpfile}")


Here is minimized case which causes above problem ...

  #  for shelljoin()
  require "pkgmisc"

  origin = 'some/where'
  file = '/tmp/in-file'
  tmpfile = '/tmp/out-file'

  cmd = shelljoin('sed', "s|^\\(@comment[ \t][ \t]*ORIGIN:\\).*$|\\1#{origin}|")
  system("#{cmd} < #{file} > #{tmpfile}")


Perhaps another version of shelljoin() is needed specifically tuned
for sed.  I myself would do the substitution in Ruby itself, or failing
that in Perl or awk.


  - Parv

-- 



More information about the freebsd-ports mailing list