Hello,
Can someone explain when and how this function is used?
I'm having troubles understanding this part:
# remove local files that have not changed from
# the installed version of this package
rm -f $(cat $PKGDIR/$pkg.sha1 | sed '/ -/d' | \
sha1sum -c 2>/dev/null | grep OK | sed 's/: OK$//')
for file in $(cat $TMP/$SESSIONID.changed); do
if [ "$2" = 1 ]; then
test -f $file && echo "$pkg upgrade failed - config file(s) are
changed, try manual upgrade" && return 1
fi
test -f $file && apkg.merge $PKGROOT . $file
test -f $file && mv $file $PKGROOT/$file
done
When $2 = 1 that means to 'freshen'. But if a local config file has changed,
then abort the upgrade.
First of all, what is the point of this (to "freshen")? And secondly, why test
for "local" changes, then abort if true ("return 1") inside the for loop,
especially after the potential deletion of lots of--unchanged--files, from the
"installed version"?
Seems like this has the potential to leave an LRP in a broken/inconsistent
state.
Also note: create_sha1 $pkg is being called to create a *running* .sha1 file
list even when the *updated* package doesn't contain a .local file. Shouldn't
the running .local and .sha1 be deleted instead?
Complete code:
# ---------------------------------------------------------
# upgrade - upgrades a package
upgrade () {
local pkg pth
if [ -z "$1" ]; then
echo "No package name given." ; return 1
fi
pth=$( makeFN $1 )
pkg=$( package_part $pth )
if [ -z "$pkg" ]; then
echo "No package name given."; return 1
fi
if ! list_pkgs "$pkg" >/dev/null; then
echo "$pkg not installed."; return 1
fi
if [ ! -f "$pth" ]; then
echo "$pth not found."; return 1
fi
# ok, its there, installed... let's upgrade it...
(
if [ -f $PKGDIR/$pkg.local ]; then
package_changed_files $pkg >$TMP/$SESSIONID.changed
mkdir $TMP/$SESSIONID.tmpdir
cd $TMP/$SESSIONID.tmpdir
tar -zxpf $pth $LRPKG/$pkg.local
if [ -f $LRPKG/$pkg.local ] ; then
tar -zxpf $pth -T $LRPKG/$pkg.local
tar -ztf $pth >$LRPKG/$pkg.list
find $(cat $LRPKG/$pkg.local) -type f | \
xargs sha1sum > $LRPKG/$pkg.sha1
# remove local files that have not changed from
# the installed version of this package
rm -f $(cat $PKGDIR/$pkg.sha1 | sed '/ -/d' | \
sha1sum -c 2>/dev/null | grep OK | sed 's/: OK$//')
for file in $(cat $TMP/$SESSIONID.changed); do
if [ "$2" = 1 ]; then
test -f $file && echo "$pkg upgrade failed - config
file(s) are changed, try manual upgrade" && return 1
fi
test -f $file && apkg.merge $PKGROOT . $file
test -f $file && mv $file $PKGROOT/$file
done
tar -zxpf $pth -X $TMP/$SESSIONID.changed -C $PKGROOT
mv $LRPKG/$pkg.list $PKGDIR
mv $LRPKG/$pkg.sha1 $PKGDIR
else
tar -zxvpf $pth -C $PKGROOT >$PKGDIR/$pkg.list
create_sha1 $pkg
fi
else
tar -zxvpf $pth -C $PKGROOT >$PKGDIR/$pkg.list
create_sha1 $pkg
fi
)
if [ $? -eq 0 ]; then
echo "$pkg upgraded"
# process any package dependencies by recursively calling install()...
deplist=""
if [ -f $PKGDIR/$pkg.deplrp ] ; then
for deplrp in `cat $PKGDIR/$pkg.deplrp` ; do
[ -f "$PKGDIR/$deplrp.list" ] || deplist="$deplist $deplrp"
done
fi
[ -n "$deplist" ] && echo "Required packages that are missed: $deplist"
return 0
else
return $?
fi
}
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
leaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-devel