99
1010# debug msg
1111if [[ " $DEBUG " == " true" ]]; then
12- echo " $VERSION "
12+ echo " Processing pandoc version $VERSION "
1313fi
1414
1515# url to pandoc version
1616url=" https://github.com/jgm/pandoc/releases/tag/$VERSION "
1717# debug msg
1818if [[ " $DEBUG " == " true" ]]; then
19- echo " $url "
19+ echo " Obtaining binaries from $url "
2020fi
2121
2222# get url to pandoc binaries
23- debUrlPartial=$( curl -L " $url " | grep -o ' /jgm/pandoc/releases/download/.*\.deb' )
24- pkgUrlPartial=$( curl -L " $url " | grep -o ' /jgm/pandoc/releases/download/.*\.pkg' )
25- msiUrlPartial=$( curl -L " $url " | grep -o ' /jgm/pandoc/releases/download/.*\.msi' )
26- zipUrlPartial=$( curl -L " $url " | grep -o ' /jgm/pandoc/archive/.*\.zip' )
27- tarUrlPartial=$( curl -L " $url " | grep -o ' /jgm/pandoc/archive/.*\.tar\.gz' )
23+ html=$( curl -L --fail " $url " )
24+ if [[ $? != 0 ]]; then
25+ echo " Cannot retrieve $url . Check if version $VERSION is valid."
26+ exit 1
27+ fi
28+
29+ debUrlPartial=$( printf ' %s' " $html " | grep -o ' /jgm/pandoc/releases/download/.*\.deb' )
30+ pkgUrlPartial=$( printf ' %s' " $html " | grep -o ' /jgm/pandoc/releases/download/.*\.pkg' )
31+ msiUrlPartial=$( printf ' %s' " $html " | grep -o ' /jgm/pandoc/releases/download/.*\.msi' )
32+ zipUrlPartial=$( printf ' %s' " $html " | grep -o ' /jgm/pandoc/archive/.*\.zip' )
33+ tarUrlPartial=$( printf ' %s' " $html " | grep -o ' /jgm/pandoc/archive/.*\.tar\.gz' )
2834# debug msg
2935if [[ " $DEBUG " == " true" ]]; then
30- echo " $debUrlPartial "
31- echo " $pkgUrlPartial "
32- echo " $msiUrlPartial "
33- echo " $zipUrlPartial "
34- echo " $tarUrlPartial "
36+ echo " URL to deb: $debUrlPartial "
37+ echo " URL to pkg: $pkgUrlPartial "
38+ echo " URL to msi: $msiUrlPartial "
39+ echo " URL to source code in zip: $zipUrlPartial "
40+ echo " URL to source code in tar.gz: $tarUrlPartial "
3541fi
3642
3743# prepare dist folder
@@ -56,6 +62,8 @@ if [[ ! -z "$debUrlPartial" ]]; then
5662 mv " $DEB " dist/
5763 mv " $debZip " dist/
5864 mv " $debWoExt .tar.gz" dist/
65+ else
66+ echo " deb package not found"
5967fi
6068# # macOS
6169if [[ ! -z " $pkgUrlPartial " ]]; then
@@ -78,6 +86,8 @@ if [[ ! -z "$pkgUrlPartial" ]]; then
7886 # to dist/
7987 mv " $PKG " dist/
8088 mv " $pkgZip " dist/
89+ else
90+ echo " pkg package not found"
8191fi
8292# # Windows
8393if [[ ! -z " $msiUrlPartial " ]]; then
@@ -95,6 +105,8 @@ if [[ ! -z "$msiUrlPartial" ]]; then
95105 # to dist/
96106 mv " $MSI " dist/
97107 mv " $msiZip " dist/
108+ else
109+ echo " msi package not found"
98110fi
99111# # Source Code
100112# ## .zip
@@ -104,8 +116,10 @@ if [[ ! -z "$zipUrlPartial" ]]; then
104116 ZIP=" ${zipUrl##*/ } "
105117 # download
106118 wget " $zipUrl "
107- # rename & to dist/
108- mv " $ZIP " " dist/pandoc-source-code-$ZIP "
119+ # rename & to dist/
120+ mv " $ZIP " " dist/pandoc-source-code-$ZIP "
121+ else
122+ echo " source code not found in zip"
109123fi
110124# ## .tar.gz
111125if [[ ! -z " $tarUrlPartial " ]]; then
@@ -114,6 +128,8 @@ if [[ ! -z "$tarUrlPartial" ]]; then
114128 TAR=" ${tarUrl##*/ } "
115129 # download
116130 wget " $tarUrl "
117- # rename & to dist/
131+ # rename & to dist/
118132 mv " $TAR " " dist/pandoc-source-code-$TAR "
133+ else
134+ echo " source code not found in tag.gz"
119135fi
0 commit comments