Rev 408 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 408 | jelle | 1 | #!/bin/bash -x |
| 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.3 |
||
| 7 | #Date: 2008-08-21 / 2009-05-14 |
||
| 8 | #Description: create symbolic links of all *.??? 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 | |||
| 20 | #~ echo "ITEMS: $ITEMS" |
||
| 21 | #~ echo "TOPDIR: $TOPDIR" |
||
| 22 | #~ echo "SYMDIR: $SYMDIR" |
||
| 23 | # symdir is resources/<SUBDIR> |
||
| 24 | # and ITEMS are .sym files |
||
| 25 | |||
| 26 | # This is an evil hack |
||
| 27 | pwd="$PWD" |
||
| 28 | pwd=${pwd%"openarm"*} |
||
| 29 | pwd+="/openarm/working/scripts/" |
||
| 30 | cd "$pwd" |
||
| 31 | #~ echo "pwd: $PWD" |
||
| 32 | |||
| 33 | # OPTIONS+="-mmin -1" |
||
| 34 | |||
| 35 | if [ -n "$1" ] && [ "$1" == "clean" ] |
||
| 36 | then |
||
| 37 | unset OPTIONS |
||
| 38 | clean="true" |
||
| 39 | fi |
||
| 40 | |||
| 41 | if [ -z "$2" ] |
||
| 42 | then |
||
| 43 | DESTINATION="../pcb/footprints/all" |
||
| 44 | # ls -hal "$DESTINATION" |
||
| 45 | else |
||
| 46 | DESTINATION="$1" |
||
| 47 | fi |
||
| 48 | |||
| 49 | if [ -z "$3" ] |
||
| 50 | then |
||
| 51 | SOURCE="../../doc/" |
||
| 52 | # ls -hal "$SOURCE" |
||
| 53 | else |
||
| 54 | SOURCE="$1" |
||
| 55 | fi |
||
| 56 | |||
| 57 | if [ -n "$clean" ] |
||
| 58 | then |
||
| 414 | agaran | 59 | find -P "$DESTINATION" -maxdepth 1 -type l -print0 | xargs -0 rm --verbose ; |
| 408 | jelle | 60 | fi |
| 61 | |||
| 62 | IFS=$'\n' |
||
| 63 | unset list |
||
| 64 | list=($(find "$SOURCE" -maxdepth 3 $OPTIONS -type f -iname "*.fp")) |
||
| 65 | |||
| 66 | for file in "${list[@]}" |
||
| 67 | do |
||
| 68 | echo "$file" |
||
| 69 | filename=${file##*/} |
||
| 70 | location=${file#*"doc"} |
||
| 71 | location=${location%/*} |
||
| 72 | path="../../../../doc" |
||
| 73 | path+="$location" |
||
| 74 | if [ -e "$DESTINATION"/"$filename" ] |
||
| 75 | then |
||
| 76 | rm "$DESTINATION"/"$filename" |
||
| 77 | fi |
||
| 78 | ln --symbolic "$path"/"$filename" "$DESTINATION"/"$filename" |
||
| 79 | done |
||
| 80 | |||
| 81 | exit |