/+junk/build-libffmpeg-for-chromium

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/build-libffmpeg-for-chromium

« back to all changes in this revision

Viewing changes to build-pdf.sh

  • Committer: Gustav Hartvigsson
  • Date: 2021-06-07 17:31:30 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210607173130-ltls48c5mw8ypt6q
initial coode

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
  
 
108
  pandoc -F pandoc-crossref\
 
109
         --from markdown --to pdf\
 
110
         --reference-links\
 
111
         ${_MD_NAME}.md\
 
112
         -o ${_PDF_NAME}.pdf
 
113
  
 
114
  ___test_xdg___
 
115
  
 
116
  if [[ ${_FOUND_PANDOC} -eq ${TRUE} ]]
 
117
  then
 
118
    xdg-open ${_PDF_NAME}.pdf
 
119
  fi
 
120
  
 
121
}
 
122
 
 
123
___main___