Rev 152 | Go to most recent revision | 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 |
||
| 6 | #Version: 0.0.1 |
||
| 7 | #Date: 20-08-2008 |
||
| 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 | |||
| 153 | agaran | 20 | # that vars are passed by makefiles, if anything else is needed let me know |
| 21 | |||
| 22 | echo $ITEMS |
||
| 23 | echo $TOPDIR |
||
| 24 | echo $SYMDIR |
||
| 25 | # symdir is resources/<SUBDIR> |
||
| 26 | # and ITEMS are .sym files |
||
| 27 | |||
| 28 | exit; |
||
| 29 | |||
| 152 | jelle | 30 | # This is an evil hack |
| 31 | pwd="$PWD" |
||
| 32 | pwd=${pwd%"working"*} |
||
| 33 | pwd+="working/scripts/" |
||
| 34 | cd $pwd |
||
| 35 | |||
| 153 | agaran | 36 | |
| 145 | jelle | 37 | if [ -n "$1" ] && [ "$1" == "update" ] |
| 38 | then |
||
| 152 | jelle | 39 | OPTIONS+="-mmin -1" |
| 145 | jelle | 40 | fi |
| 41 | |||
| 42 | if [ -z "$2" ] |
||
| 43 | then |
||
| 44 | DESTINATION="../gschem/sym/all" |
||
| 45 | else |
||
| 46 | DESTINATION="$1" |
||
| 47 | fi |
||
| 48 | |||
| 49 | if [ -z "$3" ] |
||
| 50 | then |
||
| 51 | SOURCE="../gschem/sym/resources" |
||
| 52 | else |
||
| 53 | SOURCE="$1" |
||
| 54 | fi |
||
| 55 | |||
| 152 | jelle | 56 | echo "pwd: $PWD" |
| 57 | |||
| 145 | jelle | 58 | find -P "$DESTINATION" -maxdepth 1 -type l -exec rm --verbose '{}' \; |
| 59 | |||
| 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" |
||
| 70 | ln --symbolic $path/$filename $DESTINATION/$filename |
||
| 71 | done |
||
| 72 | |||
| 73 | exit |