Rev 153 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 153 | Rev 156 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 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.1
|
6 | #Version: 0.0.2
|
| 7 | #Date: 20-08-2008
|
7 | #Date: 2008-08-21
|
| 8 | #Description: create symbolic links of all *.sym files in one place
|
8 | #Description: create symbolic links of all *.sym 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
|
| Line 15... | Line 15... | ||
| 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 | # that vars are passed by makefiles, if anything else is needed let me know
|
- | |
| 21 | - | ||
| 22 | echo $ITEMS |
20 | #~ echo "ITEMS: $ITEMS"
|
| 23 | echo $TOPDIR |
21 | #~ echo "TOPDIR: $TOPDIR"
|
| 24 | echo $SYMDIR |
22 | #~ echo "SYMDIR: $SYMDIR"
|
| 25 | # symdir is resources/<SUBDIR>
|
23 | # symdir is resources/<SUBDIR>
|
| 26 | # and ITEMS are .sym files
|
24 | # and ITEMS are .sym files
|
| 27 | 25 | ||
| 28 | exit;
|
- | |
| 29 | - | ||
| 30 | # This is an evil hack
|
26 | # This is an evil hack
|
| 31 | pwd="$PWD" |
27 | pwd="$PWD" |
| 32 | pwd=${pwd%"working"*} |
28 | pwd=${pwd%"working"*} |
| 33 | pwd+="working/scripts/" |
29 | pwd+="working/scripts/" |
| 34 | cd $pwd |
30 | cd $pwd |
| - | 31 | #~ echo "pwd: $PWD"
|
|
| 35 | 32 | ||
| - | 33 | OPTIONS+="-mmin -1"
|
|
| 36 | 34 | ||
| 37 | if [ -n "$1" ] && [ "$1" == "update" ] |
35 | if [ -n "$1" ] && [ "$1" == "clean" ] |
| 38 | then
|
36 | then
|
| 39 | OPTIONS+="-mmin -1"
|
37 | unset OPTIONS
|
| - | 38 | clean="true" |
|
| 40 | fi
|
39 | fi
|
| 41 | 40 | ||
| 42 | if [ -z "$2" ] |
41 | if [ -z "$2" ] |
| 43 | then
|
42 | then
|
| 44 | DESTINATION="../gschem/sym/all" |
43 | DESTINATION="../gschem/sym/all" |
| Line 51... | Line 50... | ||
| 51 | SOURCE="../gschem/sym/resources" |
50 | SOURCE="../gschem/sym/resources" |
| 52 | else
|
51 | else
|
| 53 | SOURCE="$1" |
52 | SOURCE="$1" |
| 54 | fi
|
53 | fi
|
| 55 | 54 | ||
| 56 | echo "pwd: $PWD" |
55 | if [ -n "$clean" ] |
| 57 | 56 | then
|
|
| 58 | find -P "$DESTINATION" -maxdepth 1 -type l -exec rm --verbose '{}' \; |
57 | find -P "$DESTINATION" -maxdepth 1 -type l -exec rm --verbose '{}' \; |
| - | 58 | fi
|
|
| 59 | 59 | ||
| 60 | unset list
|
60 | unset list
|
| 61 | list=($(find "$SOURCE" -maxdepth 3 $OPTIONS -type f -iname "*.sym")) |
61 | list=($(find "$SOURCE" -maxdepth 3 $OPTIONS -type f -iname "*.sym")) |
| 62 | 62 | ||
| 63 | for file in "${list[@]}" |
63 | for file in "${list[@]}" |
| Line 65... | Line 65... | ||
| 65 | filename=${file##*/} |
65 | filename=${file##*/} |
| 66 | location=${file#*"resources"} |
66 | location=${file#*"resources"} |
| 67 | location=${location%/*} |
67 | location=${location%/*} |
| 68 | path="../resources" |
68 | path="../resources" |
| 69 | path+="$location"
|
69 | path+="$location"
|
| - | 70 | if [ -e "$DESTINATION/$filename" ] |
|
| - | 71 | then
|
|
| - | 72 | rm "$DESTINATION/$filename" |
|
| - | 73 | fi
|
|
| 70 | ln --symbolic $path/$filename $DESTINATION/$filename |
74 | ln --symbolic $path/$filename $DESTINATION/$filename |
| 71 | done
|
75 | done
|
| 72 | 76 | ||
| 73 | exit
|
77 | exit
|