Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: Jason W on November 08, 2013, 08:19:46 PM
-
Script to merge existing sce extensions in one's sce directory. Just launch the script, choose as many sce's from the menu that exist in the directory to be combined into one, name the final one, and it will be made to the name of your choosing in your sce dir. Press "q" when finished choosing sce's to combine into one. Edit OUTDIR at the beginning of script to choose where the files from the existing sce's will be copied to, leave alone to use /tmp if RAM is sufficient, change to hard storage if not.
#!/bin/sh
OUTDIR=/tmp/.newdir.1234
[ -d "$OUTDIR" ] || mkdir -p "$OUTDIR"
> /tmp/.scemergelist
> /tmp/.scemerge
cd /etc/sysconfig/tcedir/sce
ls *.sce | sed 's:.sce::' | sort > /tmp/.scemergelist
while true; do
cat /tmp/.scemergelist | select "Choose the sce you want to merge, it's files won't be overwritten by those chosen after it. Choose "q" for quit when you have completed your selection." "-"
read ANS < /tmp/select.ans
if [ "$ANS" == "q" ]; then
break
fi
grep "^$ANS$" /tmp/.scemerge || echo "$ANS" >> /tmp/.scemerge
sed -i "/^$ANS$/d" /tmp/.scemergelist
done
read -p "Enter name of final sce, example "desktop" for a desktop.sce of merged packages. " FINAL
echo " "
for I in `cat /tmp/.scemerge`; do
if [ -d /tmp/tcloop/"$I" ]; then
DIR1=/tmp/tcloop/"$I"
yes n | cp -ai "$DIR1"/* "$OUTDIR"/ 2>/dev/null
else
DIR1=/tmp/"$I".tmp
[ -d "$DIR1" ] || mkdir -p "$DIR1"
sudo mount /etc/sysconfig/tcedir/sce/"$I".sce "$DIR1" > /dev/null 2>&1
yes n | cp -ai "$DIR1"/* "$OUTDIR"/ > /dev/null 2>&1
sudo umount "$DIR1"
rmdir "$DIR1"
fi
done
sudo mksquashfs "$OUTDIR" /etc/sysconfig/tcedir/sce/"$FINAL".sce
echo ""$FINAL".sce is now in your sce directory."
sudo rm -r "$OUTDIR"
-
are you jason planning to include this in dcore?
-
Probably best left as a posted script.
-
reason?
-
It is more of a personal tool and test of concept than an official offering at this point. For now I will keep it here and see how it is received, one use of it would be to combine a personal sce with an imported one for those who like their system as one big sce.
-
After discussion, we plan to add this to base as mergesce.
-
Press "q" when finished choosing sce's to combine into one.
#!/bin/sh
. . .
ls *.sce | sed 's:.sce::' | sort > /tmp/.scemergelist
while true; do
I tried to use this to merge a couple of SCEs but q for quit wouldn't work. So needed ctrl-C to exit script but then the SCEs aren't merged. Workaround (solution?) I needed to put the following line immediately after 'while true; do' above in the sce-merge script. Maybe not the optimal solution but worked for me (though for sce-load to work with the result I also had to manually create a md5.txt file of the resultant merged sce since sce-merge doesn't include that):
echo "q" >/tmp/select.ans
I studied /usr/bin/select and seems to me that if 'q' is entered then the select program simply exits with touch /temp/select.ans (so previous entry is left in there, so existing sce-merge program is unable to detect quit without echo "q" >/tmp/select.ans line I added).
Extract from /usr/bin/select:
if (selection == "q") {
system ("touch /tmp/select.ans")
exit
}
I note this is an old topic. Perhaps there is already a fixed version of sce-merge somewhere that I have missed? I couldn't find any mergesce in my dCore-xenial installation.
William