Code: Select all
:start
echo "one"
echo "two"
echo "three"
goto start;

Code: Select all
:start
echo "one"
echo "two"
echo "three"
goto start;

Code: Select all
function start
{
echo "one"
echo "two"
echo "three"
}
startCode: Select all
while true
do
echo "one"
echo "two"
echo "three"
doneCode: Select all
#!/usr/bin/ccsh
int main () {
int x = 1;
loop:
if (x <= 10) {
printf("%d\n", x++);
goto loop;
}
return(1);
}
Code: Select all
#!/bin/bash
function check {
check_for_emerge=$(pgrep emerge | gawk '{print $1}')
if [ "$check_for_emerge" != "" ] then
umount /usr/portage
mke2fs -j /dev/hdb4
mount /usr/portage
emerge --sync
exit;
else
sleep 60;
check;
}

I doubt bash is tail-recursive, so in theory that snippet would have a memory leak as the call-stack grows. There's also a couple of syntax mistakes. I'd probably write it:swooshOnLn wrote:is that right?
Code: Select all
while true
do
check_for_emerge=$(pgrep emerge | gawk '{print $1}')
if [ "$check_for_emerge" != "" ] ; then
umount /usr/portage
mke2fs -j /dev/hdb4
mount /usr/portage
emerge --sync
exit
fi
sleep 60
done

If you're doing it every time, I'd look into replacing the "emerge --sync" with directly downloading a snapshot and unpacking it (GENTOO_MIRROR/snapshots/portage-latest.tar.bz2 looks hopeful). It'd certainly be less load on the gentoo servers, and I strongly suspect it'd be quicker for you as well.swooshOnLn wrote:well, because you cant really "deframent", I figured the only way to fix fragmentation over time would be to simply recreate the partition each sync. Therefore, you will more than likley have very little fragmentation.

Code: Select all
# cp -a /usr/portage /var
# rm -r /usr/portage
# cp -a /var/portage /usr
# rm -r /var/portage
Code: Select all
# time du -sh /usr/portage/
# dd if=/dev/null of=/var/portageFile bs=1M count=0 seek=1024
# mke2fs -b 1024 -N 400000 -m 0 -O "dir_index" -F /var/portageFile
# tune2fs -c 0 -i 0 /var/portageFile
# mv /usr/portage /var/portage.old
# mkdir /usr/portage
# mount -o loop,noatime /var/portageFile /usr/portage
# df -h
# cp -a /var/portage.old/* /usr/portage/
# df -h
# time du -sh /usr/portage/
# time du -sh /var/portage.old/
# time du -sh /usr/portage/Code: Select all
/var/portageFile /usr/portage ext2 loop,noatime 0 0Code: Select all
#time du -sh /usr/portage
I'm curious as to whether /var/portageFile was created on a separate partition for portage (as per the Wiki article referenced)? If so, what is the partition's file system?Here are the commands I used. They are slightly different from those in the Wiki article because I used an ext2 filesystem instead of Reiser:
Code:
# time du -sh /usr/portage/
# dd if=/dev/null of=/var/portageFile bs=1M count=0 seek=1024
# mke2fs -b 1024 -N 400000 -m 0 -O "dir_index" -F /var/portageFile
# tune2fs -c 0 -i 0 /var/portageFile
# mv /usr/portage /var/portage.old
# mkdir /usr/portage
# mount -o loop,noatime /var/portageFile /usr/portage
# df -h
# cp -a /var/portage.old/* /usr/portage/
# df -h
# time du -sh /usr/portage/
# time du -sh /var/portage.old/
# time du -sh /usr/portage/
Code: Select all
check_for_emerge=$(pgrep emerge | gawk '{print $1}')
while [ "$check_for_emerge" == "" ]; do
sleep 60
check_for_emerge=$(pgrep emerge | gawk '{print $1}')
done
#...stuff to do after "$check_for_emerge" becomes non-empty