Mercurial > hg > Members > atton > seminar_slides
annotate build.sh @ 128:f557932f62b5
Add slide for seminar
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 01 Mar 2016 19:54:12 +0900 |
parents | b9aeab8d9362 |
children |
rev | line source |
---|---|
1 | 1 #/bin/sh |
2 | |
12
daf59131cdb8
Support generate index on any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
3 cd $(dirname $0) |
daf59131cdb8
Support generate index on any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
4 |
6
f6d65d2a806f
Split const definitions into config/definition.sh
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
4
diff
changeset
|
5 # source definitions |
12
daf59131cdb8
Support generate index on any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
6 . config/definition.sh |
2
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
7 |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
8 # functions |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
9 |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
10 command_check() { |
6
f6d65d2a806f
Split const definitions into config/definition.sh
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
4
diff
changeset
|
11 if !(which ${build_command} >& /dev/null;) then |
f6d65d2a806f
Split const definitions into config/definition.sh
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
4
diff
changeset
|
12 echo ${build_command} not found |
2
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
13 exit |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
14 fi |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
15 } |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
16 |
14
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
17 directory_check() { |
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
18 if !([ -d ${slide_root_dirname} ]); then |
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
19 echo "slide directory not found :" ${slide_root_dirname} |
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
20 exit |
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
21 fi |
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
22 } |
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
23 |
10
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
24 slide_name_from_full_path() { |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
25 echo $1 | sed -e 's/.[^.]*$/.html/' |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
26 } |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
27 |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
28 |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
29 need_build() { |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
30 slide_name=`slide_name_from_full_path $1` |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
31 |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
32 if [ "${slide_name}" -ot "$1" ]; then |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
33 return 0 # if exist slide and newer than src, not needed. |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
34 fi |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
35 |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
36 return 1 |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
37 } |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
38 |
2
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
39 build() { |
6
f6d65d2a806f
Split const definitions into config/definition.sh
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
4
diff
changeset
|
40 ${build_command} build $1 -o `dirname $1` ${build_template_option} |
4
ab0287707334
Support exec build scirpt in any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
41 } |
2
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
42 |
11
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
43 find_sources() { |
12
daf59131cdb8
Support generate index on any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
44 find "${slide_root_dirname}" -name "${build_target_filename}" |
11
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
45 } |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
46 |
4
ab0287707334
Support exec build scirpt in any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
47 build_slides() { |
11
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
48 target_list=`find_sources` |
4
ab0287707334
Support exec build scirpt in any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
49 for target in ${target_list}; do |
10
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
50 if need_build $target; then |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
51 build $target |
455db4624bce
Check update on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
7
diff
changeset
|
52 fi |
4
ab0287707334
Support exec build scirpt in any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
53 done |
2
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
54 } |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
55 |
11
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
56 build_index() { |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
57 rm -f ${index_source_name} |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
58 touch ${index_source_name} |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
59 |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
60 slide_list=`find_sources` |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
61 for slide in ${slide_list}; do |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
62 title=`head -5 $slide | grep "title[ ]*:" | sed -e 's/^title[ ]*:[ ]*//'` |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
63 date=`basename $(dirname $slide)` |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
64 echo "* ${date} : [$title]($(slide_name_from_full_path $slide))" >> ${index_source_name} |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
65 done |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
66 |
27
b9aeab8d9362
Sort by date in index.html
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
25
diff
changeset
|
67 (sort ${index_source_name} | kramdown --template ${index_template_file}) > ${index_file_name} |
25
3fb1e07004fa
Delete index.md on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
14
diff
changeset
|
68 rm ${index_source_name} |
11
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
69 } |
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
70 |
2
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
71 |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
72 # main |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
73 |
635d8af3f795
Fix build script, check command
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
74 command_check |
14
54fed5d73027
Check slide directory on build
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
75 directory_check |
4
ab0287707334
Support exec build scirpt in any working directory
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
76 build_slides |
11
9dca7035ab93
Generate index page for slides
Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
parents:
10
diff
changeset
|
77 build_index |