schhist/schhist-qi-update-all |
| 1 | #!/bin/bash |
| 2 | |
| 3 | # |
| 4 | # Only run one instance of this script. |
| 5 | # |
| 6 | |
| 7 | if pidof -x $(basename $0) > /dev/null; then |
| 8 | for p in $(pidof -x $(basename $0)); do |
| 9 | if [ $p -ne $$ ]; then |
| 10 | echo "Script $0 is already running: exiting" |
| 11 | exit |
| 12 | fi |
| 13 | done |
| 14 | fi |
| 15 | |
| 16 | # |
| 17 | # the assumption is we run in /home/schhist/eda-tools/schhist and |
| 18 | # other relevant dirs are /home/schhist/git and /home/schhist/output |
| 19 | # |
| 20 | cd ../.. |
| 21 | |
| 22 | [ ! -d git ] && mkdir git |
| 23 | |
| 24 | # |
| 25 | # pull_all is set once a day in case we are missing a commit event |
| 26 | # |
| 27 | |
| 28 | if [ -e git/pull_all ]; then |
| 29 | rm git/pull_all |
| 30 | pull_all=1 |
| 31 | else |
| 32 | pull_all=0 |
| 33 | fi |
| 34 | |
| 35 | # eeschema segfaults if DISPLAY is not set |
| 36 | export DISPLAY=:0 |
| 37 | |
| 38 | # |
| 39 | # $1 url to git repo |
| 40 | # $2 local directory name |
| 41 | # |
| 42 | |
| 43 | function is_git_updated |
| 44 | { |
| 45 | if [ ! -d git/$2 ]; then |
| 46 | rm -f git/$2.last git/$2.pull_needed |
| 47 | (cd git && git clone $1 $2) |
| 48 | elif [ $pull_all -gt 0 ] || [ -e git/$2.pull_needed ]; then |
| 49 | rm -f git/$2.pull_needed |
| 50 | (cd git/$2 && git pull) |
| 51 | fi |
| 52 | if [ -e git/$2.last ]; then |
| 53 | LAST_COMMIT=`cat git/$2.last` |
| 54 | fi |
| 55 | CURRENT_COMMIT=`cd git/$2 && git rev-parse @{0}` |
| 56 | if [ "$LAST_COMMIT" != "$CURRENT_COMMIT" ]; then |
| 57 | echo $CURRENT_COMMIT > git/$2.last |
| 58 | return 1 |
| 59 | fi |
| 60 | return 0 |
| 61 | } |
| 62 | |
| 63 | # |
| 64 | # run_schhist2web parameters |
| 65 | # -n -f -S -c cache: will be passed to schhist2web |
| 66 | # --order order: will become SCHHIST_ORDER |
| 67 | # --title title: will become SCHHIST_TITLE |
| 68 | # $1 local git directory |
| 69 | # $2 root schematic |
| 70 | # $3 output directory |
| 71 | # $4 remote url home |
| 72 | # $5 remote url commit template |
| 73 | # |
| 74 | |
| 75 | function run_schhist2web |
| 76 | { |
| 77 | unset SCHHIST_TITLE |
| 78 | unset SCHHIST_ORDER |
| 79 | while true; do |
| 80 | case "$1" in |
| 81 | -n | -f | -S) schhist2web_options="$schhist2web_options $1" |
| 82 | shift;; |
| 83 | -c) schhist2web_options="$schhist2web_options $1 $2" |
| 84 | shift 2;; |
| 85 | --order) export SCHHIST_ORDER=$2; shift 2;; |
| 86 | --title) export SCHHIST_TITLE=$2; shift 2;; |
| 87 | *) break;; |
| 88 | esac |
| 89 | done |
| 90 | export SCHHIST_HOME_URL=$4 |
| 91 | export SCHHIST_COMMIT_TEMPLATE=$5 |
| 92 | export SCHHIST_ADDLIBS=device |
| 93 | ./eda-tools/schhist/schhist2web $schhist2web_options git/$1 $2 $3 |
| 94 | } |
| 95 | |
| 96 | # |
| 97 | # main |
| 98 | # |
| 99 | |
| 100 | is_git_updated git://projects.qi-hardware.com/kicad-libs.git kicad-libs |
| 101 | |
| 102 | is_git_updated git://projects.qi-hardware.com/ben-wpan.git ben-wpan || ( |
| 103 | |
| 104 | run_schhist2web -S --title ben-wpan/atusb --order atusb:USB:RF \ |
| 105 | ben-wpan atusb/atusb.sch output/atusb \ |
| 106 | http://projects.qi-hardware.com/p/ben-wpan/ \ |
| 107 | "http://projects.qi-hardware.com/p/ben-wpan/source/commit/{}/" |
| 108 | |
| 109 | run_schhist2web -S --title ben-wpan/cntr \ |
| 110 | ben-wpan cntr/cntr.sch output/cntr \ |
| 111 | http://projects.qi-hardware.com/p/ben-wpan/ \ |
| 112 | "http://projects.qi-hardware.com/p/ben-wpan/source/commit/{}/" |
| 113 | |
| 114 | run_schhist2web -S --title ben-wpan/atben \ |
| 115 | ben-wpan atben/atben.sch output/atben \ |
| 116 | http://projects.qi-hardware.com/p/ben-wpan/ \ |
| 117 | "http://projects.qi-hardware.com/p/ben-wpan/source/commit/{}/" |
| 118 | ) |
| 119 | |
| 120 | is_git_updated https://github.com/milkymist/board-m1.git board-m1 || ( |
| 121 | |
| 122 | run_schhist2web -S --title "Milkymist One" --order m1:POWER:FPGA_Dec:FPGA_BANK0:FPGA_BANK1:FPGA_BANK2:FPGA_BANK3:EXPANSION_RESET:DRAM:NOR_FLASH:AUDIO:DVI-I:VIDEO_IN:MISC_CONTROL:ETHERNET:USB_A-B:USB_C-D:USB_E-F:MISC \ |
| 123 | board-m1 r4/m1.sch output/board-m1 \ |
| 124 | https://github.com/milkymist/board-m1/ \ |
| 125 | "https://github.com/milkymist/board-m1/commit/{}" |
| 126 | ) |
| 127 | |
| 128 | is_git_updated https://github.com/kristianpaul/m1-gps-expansion.git m1-gps-expansion || ( |
| 129 | |
| 130 | run_schhist2web -S --title "M1 GPS expansion board" \ |
| 131 | m1-gps-expansion gps.sch output/m1-gps-expansion \ |
| 132 | https://github.com/kristianpaul/m1-gps-expansion/ \ |
| 133 | "https://github.com/kristianpaul/m1-gps-expansion/commit/{}" |
| 134 | |
| 135 | ) |
| 136 | |
| 137 | is_git_updated git://projects.qi-hardware.com/m1.git m1 || ( |
| 138 | |
| 139 | run_schhist2web -S --title "Milkymist One JTAG-serial" \ |
| 140 | m1 jtag-serial/usb_jtag.sch output/m1-jtag-serial \ |
| 141 | http://projects.qi-hardware.com/p/m1/ \ |
| 142 | "http://projects.qi-hardware.com/p/m1/source/commit/{}/" |
| 143 | ) |
| 144 | |
| 145 | is_git_updated git://projects.qi-hardware.com/ben-blinkenlights.git ben-blinkenlights || ( |
| 146 | |
| 147 | run_schhist2web -S --title "Ben Blinkenlights" \ |
| 148 | ben-blinkenlights bbl.sch output/ben-blinkenlights \ |
| 149 | http://projects.qi-hardware.com/p/ben-blinkenlights/ \ |
| 150 | "http://projects.qi-hardware.com/p/ben-blinkenlights/source/commit/{}/" |
| 151 | |
| 152 | run_schhist2web -S --title "UBB VGA (ben-blinkenlights)" \ |
| 153 | ben-blinkenlights ubb-vga/ubb-vga.sch output/ubb-vga \ |
| 154 | http://projects.qi-hardware.com/p/ben-blinkenlights/ \ |
| 155 | "http://projects.qi-hardware.com/p/ben-blinkenlights/source/commit/{}/" |
| 156 | ) |
| 157 | |
| 158 | is_git_updated git://projects.qi-hardware.com/board-qi-avt2.git board-qi-avt2 || ( |
| 159 | |
| 160 | run_schhist2web -S --title AVT2 \ |
| 161 | board-qi-avt2 main/Qi_AVT2.sch output/board-qi-avt2 \ |
| 162 | http://projects.qi-hardware.com/p/board-qi-avt2/ \ |
| 163 | "http://projects.qi-hardware.com/p/board-qi-avt2/source/commit/{}/" |
| 164 | ) |
| 165 | |
| 166 | is_git_updated git://projects.qi-hardware.com/f32xbase.git f32xbase || ( |
| 167 | |
| 168 | run_schhist2web -S --title c2ben \ |
| 169 | f32xbase c2ben/c2ben.sch output/f32xbase_c2ben \ |
| 170 | http://projects.qi-hardware.com/p/f32xbase/ \ |
| 171 | "http://projects.qi-hardware.com/p/f32xbase/source/commit/{}/" |
| 172 | ) |
| 173 | |
| 174 | is_git_updated git://projects.qi-hardware.com/wernermisc.git wernermisc || ( |
| 175 | |
| 176 | run_schhist2web -S --title labsw \ |
| 177 | wernermisc labsw/labsw.sch output/labsw \ |
| 178 | http://projects.qi-hardware.com/p/wernermisc/ \ |
| 179 | "http://projects.qi-hardware.com/p/wernermisc/source/commit/{}/" |
| 180 | ) |