Author Topic: /usr/bin/ipkg ignores certain dependencies  (Read 2199 times)

rgrep

  • Full Member
  • ***
  • Posts: 149
    • View Profile
/usr/bin/ipkg ignores certain dependencies
« on: July 11, 2004, 07:53:11 am »
Hi folks, I just posted this to the pdaXrom buglist but since it may affect other ROMs (including the Sharp ROM) I wanted to post it here also:

---

There in a bug in the /usr/bin/ipkg script which causes it to miss certain package dependencies.  The problem arises when a package containing a non-alphanumeric character (i.e. [+.-]) has a dependency whose name does not contain these non-alphanumeric characters and is a substring of the package's name.

That is a very confusing description, so here is an example:

'vim-doc' depends on 'vim', but if you install 'vim-doc', ipkg will never automatically install 'vim' for you.  This is true for all packages who are named in this format, e.g. vim-syntax depends on vim, sdl-net depends on sdl, xscreensaver-hacks depends on xscreensaver.

You can verify yourself by doing the following:

1) Choose a package which matches the above condition.
2) Make sure you don't have the missed dependency installed (i.e. if you want to test vim-syntax, make sure you don't have vim installed).
3) Execute the following (substituting the package name below with the one you chose):

ipkg info xscreensaver-hacks Depends
ipkg depends xscreensaver-hacks

For example, the output of the above for vim-doc and xscreensaver-hacks is:

bash-2.05b# ipkg info vim-doc Depends
Depends: vim
bash-2.05b# ipkg depends vim-doc
vim-doc

bash-2.05b# ipkg info xscreensaver-hacks Depends
Depends: libglade libgtk sudo xscreensaver
bash-2.05b# ipkg depends xscreensaver-hacks
xscreensaver-hacks libglade sudo

Notice that 'vim' and 'xscreensaver' are visible in the "Depends" line from "ipkg info" but are missing from the list generated by "ipkg depends".

The problem is caused by a misconception in the use of the "\<" and "\>" regular expression meta-characters in /usr/bin/ipkg.  They are being used in the script to find the package's name in a list of packages, e.g. "\<$pkg\>".  The definition of these characters from regex(7) states:

"... the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at the beginning and end of a word respectively.  A word is defined as a sequence of word characters which is neither preceded nor followed by word characters.  A word character is an alnum character (as defined by wctype(3)) or an underscore. ..."

That last sentence is important to note, especially since ipkg treats the following characters as valid package name characters:

[a-zA-Z0-9.+-]

As you can see, period (.), plus (+), and minus (-) are valid ipkg package names, but they will be treated by "\<" and "\>" as "the null string at the beginning and end of a word".  So the string "<\vim\>" will match "vim-doc" when that wasn't the intention of the /usr/bin/ipkg script.

A more reliable regular expression to use is "^vim$" since it will never match "vim-doc".  I propose the following patch to /usr/bin/ipkg:

Code: [Select]
549c549
<                       if ! echo $installed_pkgs | grep -q "\<$pkg\>"; then
---
>                       if ! echo $installed_pkgs | tr " " "\n" | grep -q "^$pkg$"; then
556c556
<                       if ! echo $all_deps | grep -q "\<$pkg\>"; then
---
>                       if ! echo $all_deps | tr " " "\n" | grep -q "^$pkg$"; then
648c648
<       local depends=`ipkg_depends $pkg | sed -e "s/\<$pkg\>//"`
---
>       local depends=`ipkg_depends $pkg | sed -e "s/^$pkg$//" -e "s/^$pkg //" -e "s/ $pkg$ / /" -e "s/ $pkg$//"`

I have tested the above fix and stand by it, but please email me if you have any questions or concerns.

Thanks,

Matt
« Last Edit: July 11, 2004, 07:59:22 am by rgrep »
[img]https://www.oesf.org/forums/style_emoticons/default/smile.gif\" border=\"0\" class=\"linked-sig-image\" /] Has: Dynamism C760 / Linksys WCF12 WiFi / Kingston 512MB SD
[img]https://www.oesf.org/forums/style_emoticons/default/biggrin.gif\" border=\"0\" class=\"linked-sig-image\" /] Loves: pdaXrom / Warwalking
[img]https://www.oesf.org/forums/style_emoticons/default/sad.gif\" border=\"0\" class=\"linked-sig-image\" /] Hates: NetGear MA701 WiFi / SanDisk 256MB SD / C760 Charging Faults

Laze

  • Hero Member
  • *****
  • Posts: 704
    • View Profile
    • http://www.pdaXrom.org
/usr/bin/ipkg ignores certain dependencies
« Reply #1 on: July 14, 2004, 07:33:03 pm »
We have seen you bug report and of course fix it in the upcomming release.
C760 running pdaXrom lastest ;-)
SL5500 Running Cacko Qtopia
512 MB SD Card, 128 MB CF Card, Prism2 CF Wlan.

Always visit http://www.pdaXrom.org for latest news.