Rev 408 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 408 | Rev 414 | ||
---|---|---|---|
1 | #!/bin/bash -x
|
1 | #!/bin/bash -x
|
2 | 2 | ||
3 | #Company: PowerCraft Technology
|
3 | #Company: PowerCraft Technology
|
4 | #Author: Copyright Jelle de Jong <jelledejong@powercraft.nl>
|
4 | #Author: Copyright Jelle de Jong <jelledejong@powercraft.nl>
|
5 | #Note: Please send me an email if you enhanced the script
|
5 | #Note: Please send me an email if you enhanced the script
|
6 | #Version: 0.0.3
|
6 | #Version: 0.0.3
|
7 | #Date: 2008-08-21 / 2009-05-14
|
7 | #Date: 2008-08-21 / 2009-05-14
|
8 | #Description: create symbolic links of all *.??? files in one place
|
8 | #Description: create symbolic links of all *.??? files in one place
|
9 | 9 | ||
10 | # This program is free software; you can redistribute it and/or modify
|
10 | # This program is free software; you can redistribute it and/or modify
|
11 | # it under the terms of the GNU General Public License as published by
|
11 | # it under the terms of the GNU General Public License as published by
|
12 | # the Free Software Foundation; either version 2 of the License, or
|
12 | # the Free Software Foundation; either version 2 of the License, or
|
13 | # (at your option) any later version.
|
13 | # (at your option) any later version.
|
14 | 14 | ||
15 | # This program is distributed in the hope that it will be useful,
|
15 | # This program is distributed in the hope that it will be useful,
|
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 | # GNU General Public License for more details.
|
18 | # GNU General Public License for more details.
|
19 | 19 | ||
20 | #~ echo "ITEMS: $ITEMS"
|
20 | #~ echo "ITEMS: $ITEMS"
|
21 | #~ echo "TOPDIR: $TOPDIR"
|
21 | #~ echo "TOPDIR: $TOPDIR"
|
22 | #~ echo "SYMDIR: $SYMDIR"
|
22 | #~ echo "SYMDIR: $SYMDIR"
|
23 | # symdir is resources/<SUBDIR>
|
23 | # symdir is resources/<SUBDIR>
|
24 | # and ITEMS are .sym files
|
24 | # and ITEMS are .sym files
|
25 | 25 | ||
26 | # This is an evil hack
|
26 | # This is an evil hack
|
27 | pwd="$PWD" |
27 | pwd="$PWD" |
28 | pwd=${pwd%"openarm"*} |
28 | pwd=${pwd%"openarm"*} |
29 | pwd+="/openarm/working/scripts/" |
29 | pwd+="/openarm/working/scripts/" |
30 | cd "$pwd" |
30 | cd "$pwd" |
31 | #~ echo "pwd: $PWD"
|
31 | #~ echo "pwd: $PWD"
|
32 | 32 | ||
33 | # OPTIONS+="-mmin -1"
|
33 | # OPTIONS+="-mmin -1"
|
34 | 34 | ||
35 | if [ -n "$1" ] && [ "$1" == "clean" ] |
35 | if [ -n "$1" ] && [ "$1" == "clean" ] |
36 | then
|
36 | then
|
37 | unset OPTIONS
|
37 | unset OPTIONS
|
38 | clean="true" |
38 | clean="true" |
39 | fi
|
39 | fi
|
40 | 40 | ||
41 | if [ -z "$2" ] |
41 | if [ -z "$2" ] |
42 | then
|
42 | then
|
43 | DESTINATION="../pcb/footprints/all" |
43 | DESTINATION="../pcb/footprints/all" |
44 | # ls -hal "$DESTINATION"
|
44 | # ls -hal "$DESTINATION"
|
45 | else
|
45 | else
|
46 | DESTINATION="$1" |
46 | DESTINATION="$1" |
47 | fi
|
47 | fi
|
48 | 48 | ||
49 | if [ -z "$3" ] |
49 | if [ -z "$3" ] |
50 | then
|
50 | then
|
51 | SOURCE="../../doc/" |
51 | SOURCE="../../doc/" |
52 | # ls -hal "$SOURCE"
|
52 | # ls -hal "$SOURCE"
|
53 | else
|
53 | else
|
54 | SOURCE="$1" |
54 | SOURCE="$1" |
55 | fi
|
55 | fi
|
56 | 56 | ||
57 | if [ -n "$clean" ] |
57 | if [ -n "$clean" ] |
58 | then
|
58 | then
|
59 | find -P "$DESTINATION" -maxdepth 1 -type l -exec rm --verbose '{}' \; |
59 | find -P "$DESTINATION" -maxdepth 1 -type l -print0 | xargs -0 rm --verbose ; |
60 | fi
|
60 | fi
|
61 | 61 | ||
62 | IFS=$'\n' |
62 | IFS=$'\n' |
63 | unset list
|
63 | unset list
|
64 | list=($(find "$SOURCE" -maxdepth 3 $OPTIONS -type f -iname "*.fp")) |
64 | list=($(find "$SOURCE" -maxdepth 3 $OPTIONS -type f -iname "*.fp")) |
65 | 65 | ||
66 | for file in "${list[@]}" |
66 | for file in "${list[@]}" |
67 | do
|
67 | do
|
68 | echo "$file" |
68 | echo "$file" |
69 | filename=${file##*/} |
69 | filename=${file##*/} |
70 | location=${file#*"doc"} |
70 | location=${file#*"doc"} |
71 | location=${location%/*} |
71 | location=${location%/*} |
72 | path="../../../../doc" |
72 | path="../../../../doc" |
73 | path+="$location"
|
73 | path+="$location"
|
74 | if [ -e "$DESTINATION"/"$filename" ] |
74 | if [ -e "$DESTINATION"/"$filename" ] |
75 | then
|
75 | then
|
76 | rm "$DESTINATION"/"$filename" |
76 | rm "$DESTINATION"/"$filename" |
77 | fi
|
77 | fi
|
78 | ln --symbolic "$path"/"$filename" "$DESTINATION"/"$filename" |
78 | ln --symbolic "$path"/"$filename" "$DESTINATION"/"$filename" |
79 | done
|
79 | done
|
80 | 80 | ||
81 | exit
|
81 | exit
|
82 | 82 |