WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: sce-merge  (Read 6698 times)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
sce-merge
« on: November 08, 2013, 11: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.

Code: [Select]
#!/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"





Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: sce-merge
« Reply #1 on: November 09, 2013, 09:54:47 AM »
are you jason planning to include this in dcore?
dCore user

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: sce-merge
« Reply #2 on: November 09, 2013, 10:21:06 AM »
Probably best left as a posted script. 

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: sce-merge
« Reply #3 on: November 09, 2013, 11:40:46 AM »
reason?
dCore user

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: sce-merge
« Reply #4 on: November 09, 2013, 01:34:55 PM »
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. 


Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: sce-merge
« Reply #5 on: December 01, 2013, 01:43:06 PM »
After discussion, we plan to add this to base as mergesce.

Offline mcewanw

  • Full Member
  • ***
  • Posts: 102
Re: sce-merge
« Reply #6 on: March 17, 2017, 05:21:17 AM »
Press "q" when finished choosing sce's to combine into one.
Code: [Select]
#!/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):

Code: [Select]
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:

Code: [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