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