/+junk/build-libffmpeg-for-chromium

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/build-libffmpeg-for-chromium
1 by Gustav Hartvigsson
initial coode
1
#/usr/bin/env bash
2
FALSE=0
3
TRUE=1
4
5
_IGNORE_PANDOC_CROSSREF=${FALSE}
6
_FOUND_PANDOC=${FALSE}
7
_FOUND_PANDOC_CROSSREF=${FALSE}
8
_FOUND_XDG=${FALSE}
9
10
_PDF_NAME=libffmpeg_from_source
11
_MD_NAME=document
12
13
___help___ () {
14
  echo ""
15
  echo "    Build script for the document."
16
  echo ""
17
  echo "--ignore-pandoc-crossref      Does not check if pandoc-crossref is"
18
  echo "                              installed. May create errors in PDF file."
19
}
20
21
___parse_args___ () {
22
  while [[ $# -gt 0 ]]
23
  do
24
    
25
    case "${1}" in
26
      --ignore-pandoc-crossref)
27
      _IGNORE_PANDOC_CROSSREF=${TRUE}
28
      ;;
29
      -h|--help)
30
      ___help___
31
      shift
32
      ;;
33
      *)
34
      ___help___
35
      exit
36
      shift
37
      ;;
38
      --)
39
      shift
40
      break
41
      ;;
42
    esac
43
  done
44
}
45
46
___test_pandoc___ () {
47
  which pandoc > /dev/null
48
  
49
  if [[ $? -eq 0 ]]
50
  then
51
    _FOUND_PANDOC=${TRUE}
52
  fi
53
}
54
55
___test_pandoc_crossref___ () {
56
  which pandoc-crossref > /dev/null
57
  
58
  if [[ $? -eq 0 ]]
59
  then
60
    _FOUND_PANDOC_CROSSREF=${TRUE}
61
  fi
62
}
63
64
___test_xdg___ () {
65
  which xdg-run > /dev/null
66
  
67
  if [[ $? -eq 0 ]]
68
  then
69
    _FOUND_XDG=${TRUE}
70
  fi
71
}
72
73
___main___ () {
74
  ___parse_args___ "${@}"
75
  ___test_pandoc___
76
  
77
  if [[ ${_IGNORE_PANDOC_CROSSREF} -ne ${TRUE} ]]
78
  then
79
    ___test_pandoc_crossref___
80
  fi
81
  
82
  if [[ ${_FOUND_PANDOC} -ne ${TRUE} ]]
83
  then
84
    echo
85
    echo -e "\e[31m     pandoc not found!\e[0m"
86
    echo ""
87
    echo "  Please install pandoc to build the PDF."
88
    echo ""
89
    exit 127
90
  fi
91
  
92
  if [[ ${_FOUND_PANDOC_CROSSREF} -ne ${TRUE} ]]
93
  then
94
    echo ""
95
    echo -e "\e[31m    pandoc-crossref not found!\e[0m"
96
    echo ""
97
    echo "  To build properly you will need pandoc-crossref,"
98
    echo "this may not not be installed by default. Please refer to"
99
    echo "https://github.com/lierdakil/pandoc-crossref"
100
    echo "for information on how to build and (add to \$PATH)."
101
    echo ""
102
    echo "  If you want to build anyway, provide the"
103
    echo "--ignore-pandoc-crossref flag to the script."
104
    echo "This will produce errors."
105
    exit 127
106
  fi
107
  
2 by Gustav Hartvigsson
Added first set of tests. (More to come).
108
  pandoc -s -F pandoc-crossref\
109
         --from markdown --to latex\
1 by Gustav Hartvigsson
initial coode
110
         --reference-links\
111
         ${_MD_NAME}.md\
2 by Gustav Hartvigsson
Added first set of tests. (More to come).
112
         -o ${_PDF_NAME}_pre.tex
113
  
114
  cat ${_PDF_NAME}_pre.tex | ./tex_table_verts.py > ${_PDF_NAME}_post.tex
115
  
3 by Gustav Hartvigsson
Made sure the title is fine (with space after
116
  # We need to run this twice to make sure that LaTeX knows the size of things.
4 by Gustav Hartvigsson
Use XeLaTeX so we get the correct font
117
  xelatex ${_PDF_NAME}_post.tex
118
  xelatex ${_PDF_NAME}_post.tex
2 by Gustav Hartvigsson
Added first set of tests. (More to come).
119
  mv ${_PDF_NAME}_post.pdf ${_PDF_NAME}.pdf
120
  rm *.tex *.toc *.aux *.log
1 by Gustav Hartvigsson
initial coode
121
  
122
  ___test_xdg___
123
  
124
  if [[ ${_FOUND_PANDOC} -eq ${TRUE} ]]
125
  then
126
    xdg-open ${_PDF_NAME}.pdf
127
  fi
128
  
129
}
130
131
___main___