#!/bin/sh
echo ""
echo "mkbase start"
#chmod +x /usr/local/src/*/*/insmod.sh
chmod +x /usr/bin/*
chmod +x /usr/sbin/*
chmod +x /bin/*
chmod +x /sbin/*
rm /mnt/hda5/g2v_base*.tar.bz2 > /dev/null 2>&1
rm -f /var/log/* > /dev/null 2>&1
rm -f /var/log/*/*  > /dev/null 2>&1
rm -f /var/log/*/*/* > /dev/null 2>&1
ln -s /var/log/everything/current /var/log/messages

mkdir /usr/local/share/doc/vdr > /dev/null 2>&1

rm -f /usr/local/share/doc/vdr/*README*
# create docs
cd /usr/local/src/VDR
for i in *READ* HISTORY MANUAL ; do
   cp -f $i /usr/local/share/doc/vdr/
done

cd /usr/local/src/VDR/PLUGINS/src

for i in */README ; do
   FN=$(echo ${i} | cut -f1 -d "/" | cut -f1 -d "-")
   cp -f $i /usr/local/share/doc/vdr/$FN.README
done

cd /

tar -cvjf /mnt/hda5/g2v_base_usr.tar.bz2 \
    --exclude=./usr/portage/* --exclude=./usr/local/gentoo-de/* \
    --exclude=./usr/local/src/* --exclude=./usr/src \
    --exclude=./usr/bin --exclude=./usr/sbin \
    --exclude=./usr/share --exclude=./usr/lib \
    --exclude=./usr/kde --exclude=./usr/X11R6 ./usr/*

tar -cvjf /mnt/hda5/g2v_base_ubin.tar.bz2 ./usr/bin ./usr/sbin
    
tar -cvjf /mnt/hda5/g2v_base_ushr.tar.bz2 ./usr/share
    
tar -cvjf /mnt/hda5/g2v_base_ulib.tar.bz2 ./usr/lib

tar -cvjf /mnt/hda5/g2v_base_var.tar.bz2 --exclude=./var/run/*/* --exclude=*.pid \
    --exclude=./var/cache/*/* --exclude=./var/cache/dhcpcd* --exclude=./var/lib/dhcpc/* \
    --exclude=./var/tmp/* ./var/*

tar -cvjf /mnt/hda5/g2v_base.tar.bz2 --exclude=./_config --exclude=./dev/.d* \
    --exclude=./mnt/*/*  --exclude=./xsh --exclude=./xau --exclude=./tmp/* \
    --exclude=./proc/* --exclude=./etc/* --exclude=./root --exclude=./autorun.* \
    --exclude=./home/* --exclude=vdradmind.pid \
    --exclude=./video/* --exclude=./pictures/* --exclude=./film/* --exclude=./audio/* \
    --exclude=./sys/* --exclude=./media/*/* --exclude=./opt/* \
    --exclude=./tmpfs/* --exclude=./ShoutcastBrowser_Recently_Played \
    --exclude=./usr/* --exclude=./var/* ./*

echo "mkbase end"
echo ""
