[Pbuilder-maint] Bug#338976: readlink -f/-e
Markus Kolb
debian-mkolb at tower-net.de
Wed Nov 16 19:21:21 UTC 2005
Hello,
does readlink in cowprotect really need the -f argument for any purpose
I don't know?
-f, --canonicalize canonicalize by following every symlink in every
component of the given name recursively; all but the last component must
exist
-e, --canonicalize-existing canonicalize by following every symlink in
every component of the given name recursively, all components must
exist
$BUILDPLACE/etc/shadow doesn't exist at the grep and cowprotect is
called on it.
In cowprotect the non-existent shadow file would be renamed to shadow~
==> error.
So -e argument should be fine here. If $A doesn't exist we don't need to
do the mv/cp/rm because of hardlinks.
BTW what is cow/cowdancer? It isn't very descriptive...
function cowprotect () {
# a hack for cowdancer, used when a file is edited in-place;
# Copy the file to create a new i-node so that hardlinked original
# is intact
for A in "$@"; do
if readlink -e "$A"; then
A=$(readlink -e "$A")
mv "$A" "$A"~
cp -a "$A"~ "$A"
rm -f "$A"~
fi
done
}
function createbuilduser () {
# create the build user
if [ -n "$SUTOUSER" ]; then
if ! grep -q ^$BUILDUSERNAME: $BUILDPLACE/etc/passwd; then
cowprotect $BUILDPLACE/etc/passwd
echo "$BUILDUSERNAME:x:$BUILDUSERID:$BUILDUSERID:,,,:/tmp/buildd:/bin/sh" >> $BUILDPLACE/etc/passwd
fi
if ! grep -q ^$BUILDUSERNAME: $BUILDPLACE/etc/group; then
cowprotect $BUILDPLACE/etc/group
echo "$BUILDUSERNAME:*:$BUILDUSERID:" >> $BUILDPLACE/etc/group
fi
if ! grep -q ^$BUILDUSERNAME: $BUILDPLACE/etc/shadow; then
cowprotect $BUILDPLACE/etc/shadow
echo "$BUILDUSERNAME:!:::::::" >> $BUILDPLACE/etc/shadow
fi
unset LOGNAME || true
else
unset LOGNAME || true
fi
}
Patch:
--- pbuilder-buildpackage-funcs.orig 2005-11-16 20:06:36.000000000 +0100
+++ pbuilder-buildpackage-funcs 2005-11-16 19:39:24.000000000 +0100
@@ -70,8 +70,8 @@
# a hack for cowdancer, used when a file is edited in-place;
# Copy the file to create a new i-node so that hardlinked original
# is intact
for A in "$@"; do
- if readlink -f "$A"; then
- A=$(readlink -f "$A")
+ if readlink -e "$A"; then
+ A=$(readlink -e "$A")
mv "$A" "$A"~
cp -a "$A"~ "$A"
rm -f "$A"~
More information about the Pbuilder-maint
mailing list