File: maketarget

package info (click to toggle)
net-snmp 5.9+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 36,760 kB
  • sloc: ansic: 283,039; perl: 17,712; sh: 11,887; makefile: 2,705; xml: 663; python: 623; pascal: 62; sql: 47
file content (63 lines) | stat: -rwxr-xr-x 1,112 bytes parent folder | download | duplicates (14)
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
54
55
56
57
58
59
60
61
62
63
: maketarget

DIRS=`find . -name targets -prune -o -type d ! -name . -print | grep -v CVS | sed s/..//`
TARGET=${1-`./config.guess`}

rebuild=0

echo Target directory: $TARGET
echo Sub directories: $DIRS

[ -d targets ] || mkdir targets
cd targets
if [ -d $TARGET ]
then
  /bin/echo Target already exists. Do you want to rebuild it\? '[y]' \\c
  read ans
  case $ans in
  "" | y* | Y* )
    rebuild=1
    ;;
  n* | N* )
    exit 0
    ;;
  *)
    echo Bummer.....
    exit 1
    ;;
  esac
fi

echo Creating target directory: $TARGET
[ -d $TARGET ] || mkdir $TARGET

cd $TARGET
for f in . $DIRS
do
  echo building $f ...
  [ -d $f ] || mkdir $f
  case $f in
  */*/*/*)
    echo Too deep nesting...
    exit 1
    ;;
  */*/*)
    cd $f
    for f in ../../../../../$f/* ; do [ -d $f ] || ln -sf $f . ; done
    cd ../../..
    ;;
  */*)
    cd $f
    for f in ../../../../$f/* ; do [ -d $f ] || ln -sf $f . ; done
    cd ../..
    ;;
  .)
    for f in ../../$f/* ; do [ -d $f ] || ln -sf $f . ; done
    ;;
  *)
    cd $f
    for f in ../../../$f/* ; do [ -d $f ] || ln -sf $f . ; done
    cd ..
    ;;
  esac
done