Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 17072 - /mnt/.init.d/depcache becomes corrupt if a /etc/init.d/ script specifies no dependencies
Summary: /mnt/.init.d/depcache becomes corrupt if a /etc/init.d/ script specifies no d...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-08 03:59 UTC by Daniel Armyr
Modified: 2004-02-29 10:38 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Armyr 2003-03-08 03:59:55 UTC
If oe tries to rc-update add <script> <runlevel> and <script> contains an empty
depend() {} funtion, /mnt/init.d/depcach is reported as being corrupt.

Reproducible: Always
Steps to Reproduce:
1. copy the vcron to foo
2. remove contents of depend() in foo
3. rc-update add foo default
4. read output
Actual Results:  
a syntax error in /mnt/.init.d/depcache is reported, along with reported failure
to find dependencies of three packages. Two of these packages have their
dependencies recorded immediately before foo.
The syntax error is "Unexpected }" on the line after the second depend(). See
transcript:

quadii init.d # rc-update add tleds default
 * tleds already installed in runlevel default; skipping
 * Caching service dependencies...
/mnt/.init.d/depcache: line 446: syntax error near unexpected token `}'
/mnt/.init.d/depcache: line 446: `}'
 * NEED:  can't find service modules needed by crypto-loop;
 *        continuing...
 * NEED:  can't find service hostname needed by sysklogd;
 *        continuing...
 * NEED:  can't find service checkfs needed by localmount;
 *        continuing...
[ ok ]
 * rc-update complete.

Expected Results:  
When reading the depcache, rc-update should be aware that the depend() function
can be empty, and therefore be aware that the lie directly after depend() { can
be a }. If all startups require a dependency, this should be reported as the
error, and not an unsecified syntax error.

If a dependency is added, and the rc-update add <...> is run again, no error is
reported. The /mnt/.init.d/depcache is unchanged though. Deinstalling and
reinstalling produces a correct depcache.
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2003-03-08 21:13:34 UTC
It is a bash limitation, so not much I can do about it.

--------------------------------
nosferatu tmp # cat foo.sh
#!/bin/sh

source /etc/init.d/functions.sh

blah() {
}

dolisting "/mnt/.init.d/started/net.*"
nosferatu tmp # bash foo.sh 
foo.sh: line 6: syntax error near unexpected token `}'
foo.sh: line 6: `}'
nosferatu tmp # 
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2003-04-06 11:10:34 UTC
Bash limitation that cannot be fixed.
Comment 3 Sheldon Hearn 2004-02-29 08:59:47 UTC
Bash limitation?  It's a syntax error! :-)

  depend() {
    return 0
  }

  # Actual depend() {
    return 0
  }

  # Actual depend() function ...
  depend() {
        use net
        return 0
  }

Note the "# Actual depend() {" line?  Two lines below it is a closing brace that  looks like it expects to close the block opened in the commented out line.

Where does /var/lib/init.d/depcache come from anyway?  qpkg -f can't find it, so I assume it's generated, but apparently not by rc-update.  If I could find its creator, I could probably send you a patch.
Comment 4 Martin Schlemmer (RETIRED) gentoo-dev 2004-02-29 10:38:39 UTC
Or syntax error.  Point being, you cannot have an empty bash function (or
if statement, etc for that matter).  If the script was valid in the
first place, it would have been Ok.