Bruce Dubbs wrote these words on 03/31/08 10:19 CST:
> Looks interesting. Where do you put your DESTDIR? Is it a part of the
> chroot partition? You said you use scripts. Can you post a typical script?
I suppose I should qualify "scripts". Actually, there is only one main
script I use to copy stuff from DESTDIR to /. I've attached it.
Note that it does nothing about the CMMI to destdir. That is in
individual scripts for each package. This attached script is
used after I determine that I like the way the DESTDIR files
are and I'm ready to install them.
Warning:
I am not an accomplished shell scripter. I know just enough to
get by. The script could probably be faster, more efficient,
smaller and much of it could be done better, I'm sure. However,
it works for me.
This was proof of concept most of all. It is not automated, but
I didn't want my first DESTDIR LFS to be. I purposely put user
interaction in it, so there wouldn't be goof-ups (I try to catch
the goof-ups anyway).
I realize I'm not good, so if anyone wants to comment that it
sucks, you could do better then it does and you probably can.
And if you think so, tell me what you think I should do to make
it better.
--
Randy
rmlscsi: [bogomips 1003.22] [GNU ld version 2.16.1] [gcc (GCC) 4.0.3]
[GNU C Library stable release version 2.3.6] [Linux 2.6.14.3 i686]
12:15:00 up 43 days, 3:03, 1 user, load average: 0.00, 0.03, 0.00
#! /bin/sh
getinput()
{
userinput=""
default="$2"
echo
echo -n "$1 [$2]: "
read userinput
if [ "$userinput" = "" ]; then
userinput=$default
fi
}
userabort()
{
echo; echo "Okay, then...Fix the problem...Aborting..."; echo; echo
exit 1
}
testcommand()
{
if [ $? = 0 ]
then echo; echo "$1 process finished normally"
else echo; echo "$1 process failed...Aborting"; echo; echo; exit 1
fi
}
#
# Check for any user/group ownership != root
#
if [ `find destdir ! -user root | wc -l` != 0 -o \
`find destdir ! -group root | wc -l` != 0 ]
then
echo; echo
getinput "Warning - Not all files have root:root ownership - Continue?
(Y,N)" "N"
if [ $userinput = "n" -o $userinput = "N" ]; then userabort; fi
fi
#
# Check man, info and doc files ... move them if necessary
#
if [ -e destdir/usr/man -a ! -e destdir/usr/share/man ]; then
if [ ! -d destdir/usr/share ]; then
mkdir destdir/usr/share
testcommand "Creating destdir/usr/share directory"
fi
mv -v destdir/usr/man destdir/usr/share >>fix_destdir.log 2>&1
testcommand "Move man files"
elif [ -e destdir/usr/man -a -e destdir/usr/share/man ]; then
echo; echo "Man file structure in Destdir is screwed up...Aborting"; echo;
exit 1
fi
if [ -e destdir/usr/info -a ! -e destdir/usr/share/info ]; then
if [ ! -d destdir/usr/share ]; then
mkdir destdir/usr/share
testcommand "Creating destdir/usr/share directory"
fi
mv -v destdir/usr/info destdir/usr/share >>fix_destdir.log 2>&1
testcommand "Move info files"
elif [ -e destdir/usr/info -a -e destdir/usr/share/info ]; then
echo; echo "Info file structure in Destdir is screwed up...Aborting"; echo;
exit 1
fi
if [ -e destdir/usr/doc -a ! -e destdir/usr/share/doc ]; then
if [ ! -d destdir/usr/share ]; then
mkdir destdir/usr/share
testcommand "Creating destdir/usr/share directory"
fi
mv -v destdir/usr/doc destdir/usr/share >>fix_destdir.log 2>&1
testcommand "Move doc files"
elif [ -e destdir/usr/doc -a -e destdir/usr/share/doc ]; then
echo; echo "Doc file structure in Destdir is screwed up...Aborting"; echo;
exit 1
fi
#
# Create and head/tail list of files in Destdir
#
find destdir | sort >destdir_filelist.log 2>&1
testcommand "Find Destdir files"
if [ `wc -l destdir_filelist.log | cut -d" " -f1` -gt 20 ]; then
head destdir_filelist.log
tail destdir_filelist.log
else cat destdir_filelist.log
fi
#
# Continue?
#
getinput "Does it look correct? (Y/N)" "Y"
if [ $userinput != "y" -a $userinput != "Y" ]; then userabort; fi
#
# Find duplicate files (will be overwritten on destination)
#
for FILENAME in `cat destdir_filelist.log`; do
if [ -e $(echo ${FILENAME} | sed 's/destdir//') ]; then
if [ ! -d ${FILENAME} ]; then
echo $(echo ${FILENAME} | sed 's/destdir//') >>overwrite_files.log
2>&1
elif [ ${FILENAME} = "destdir/usr/share/info/dir" ]; then
echo "Bypassing /usr/share/info/dir"
else
echo ${FILENAME} >>dirfiles.log 2>&1
fi
fi
done
testcommand "Find duplicate files"
#
# Display the overwrite filelist
#
if [ ! -e overwrite_files.log ]; then
touch overwrite_files.log
testcommand "Touch overwrite_files.log"
echo; echo "No files will be overwritten"
else
echo; echo "The following files will be overwritten:"
cat overwrite_files.log
fi
#
# Continue?
#
getinput "Copy Destdir files to Destination? (Y/N)" "Y"
if [ $userinput != "y" -a $userinput != "Y" ]; then userabort; fi
#
# Get disk space of Destdir
#
du -scxk destdir >du_destdir.log 2>&1
testcommand "Find Destdir disk space"
cat du_destdir.log
#
# Copy the files
#
cp -vbpr -S .Overwritten_By_${PACKAGE_NAME} destdir/* / >>final_install.log 2>&1
testcommand "Copy to destination"
echo
if [ `wc -l final_install.log | cut -d" " -f1` -gt 20 ]; then
head final_install.log
tail final_install.log
else cat final_install.log
fi
echo
#
# Creating new info dir file (if applicable)
#
if [ -e /usr/share/info/dir.Overwritten_By_${PACKAGE_NAME} ]; then
OLDPATH=${PWD}
cd /usr/share/info
echo "The current path is ${PWD}"
echo "Moving old 'dir' file and dir.Overwritten_By file"; echo
mv -v dir \
${OLDPATH}/../${PACKAGE_LOGDIR}
>>${OLDPATH}/fix_info_dir_file.log 2>&1
testcommand "Moving info dir file"
mv -v dir.Overwritten_By_${PACKAGE_NAME} \
${OLDPATH}/../${PACKAGE_LOGDIR}
>>${OLDPATH}/fix_info_dir_file.log 2>&1
testcommand "Moving info dir.Overwritten... file"
echo; echo "Creating new 'dir' file"
for FILENAME in *; do
if [ -e /tmp/install-info.error ]; then rm -f /tmp/install-info.error;
fi
echo "Installing ${FILENAME}"
>>${OLDPATH}/fix_info_dir_file.log 2>&1
install-info ${FILENAME} dir 2>/tmp/install-info.error
if [ $? != 0 ]; then
grep -q " already exists, for file " /tmp/install-info.error
if [ $? != 0 ]; then
echo "Problem adding ${FILENAME}"
echo "Problem adding ${FILENAME}"
>>${OLDPATH}/fix_info_dir_file.log 2>&1
else
cat /tmp/install-info.error
>>${OLDPATH}/fix_info_dir_file.log 2>&1
fi
fi
done
grep -q "^Problem adding" ${OLDPATH}/fix_info_dir_file.log
if [ $? = 0 ]; then echo; echo; echo; echo "There were problems creating
the info dir file"; echo; fi
ls -l dir; echo
cd ${OLDPATH}
else
echo "${PACKAGE_NAME} package did not have a /usr/share/info/dir file"; echo
fi
#
# Remove the owerwritten files
#
if [ -s overwrite_files.log ]; then
getinput "Move the old overwritten files? (Y/N)" "Y"
if [ $userinput != "y" -a $userinput != "Y" ]; then userabort; fi
for FILENAME in `cat overwrite_files.log`; do
if [ ${FILENAME} = "/usr/share/info/dir" ]; then
echo "Skipping ${FILENAME}"
echo "Skipping ${FILENAME}"
>>move_overwrittens.log 2>&1
else
mv -v ${FILENAME}.Overwritten_By_${PACKAGE_NAME} \
../${PACKAGE_LOGDIR}
>>move_overwrittens.log 2>&1
testcommand "Moving ${FILENAME}"
fi
done
fi
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page