-
Notifications
You must be signed in to change notification settings - Fork 2
/
makePortageSomething
executable file
·54 lines (43 loc) · 1.18 KB
/
makePortageSomething
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
if [ -z $1 ] || [ "$1" = "-h" -o "$1" = "--help" ];
then
echo
echo "Create directories in TargetDir for each one from /usr/portage "
echo " Usable when you want full structure of portage categories."
echo
echo "USAGE:"
echo " makePortageSomething <tgtdir>"
echo
echo "<tgtdir>: target directory in which new dirs will be created"
echo
exit 1
else
TGTDIR="${1}"
fi
if [ ! -d "${TGTDIR}" ];
then
echo
echo "Error: The given argument is not an directory!"
echo
exit 1
fi
# postara se, ze na konci je lomitko
TGTDIR=`echo ${TGTDIR} | sed "s/\([^\/]\)$/\1\//"`
# ziskat skutecne umisteni portage a prejit do nej
source /etc/make.conf
if [ -z $PORTDIR ]; then PORTDIR="/usr/portage"; fi
# pro kazdy adresar v portage
for DIR in `find ${PORTDIR} -maxdepth 1 -type d | sort`;
do
# nahradit / za \/ aby se mohlo pouzit v sedu (neni zcela bezpecne ... co jine SEDove znaky?
SAFEPORTDIR=`echo $PORTDIR | sed "s/\//[\/]/g"`
# odstranit './' na zacatku
DIR=`echo ${DIR} | sed "s/^${SAFEPORTDIR}\(\/\)\?//"`
if [ "${DIR}" = "" -o "${DIR}" = "." -o "${DIR}" = ".." ];
then
continue;
fi
TGT=${TGTDIR}${DIR}
# vytvorit adresar v cilovem umisteni
mkdir -v ${TGT}
done