@@ -4,8 +4,40 @@ set -euo pipefail
44
55# Constants
66ROOTDIR=" $PWD "
7- OPTMODDIR=" modules/optional"
7+ OPTMODDIR=" ${ROOTDIR} / modules/optional"
88OUTPUTDIR=" output-MinGW-i386"
9+ OPTIONALURL=" https://svn.reactos.org/optional"
10+ REQUIREDFILES=(
11+ " DroidSansFallback.ttf"
12+ " wine_gecko*.msi"
13+ " winevdm_setup.exe"
14+ )
15+
16+ download_required_files () {
17+ accept=$( IFS=,; echo " ${REQUIREDFILES[*]} " )
18+
19+ if ! wget -r -np -nd -nH \
20+ -A " ${accept} " \
21+ " ${OPTIONALURL} /" ; then
22+ echo
23+ echo " FAILED: Could not reach ${OPTIONALURL} "
24+ return 1
25+ fi
26+ }
27+
28+ check_required_files () {
29+ if [ ! -d " ${OPTMODDIR} " ]; then
30+ return 1
31+ fi
32+
33+ for file in " ${REQUIREDFILES[@]} " ; do
34+ if ! compgen -G " ${OPTMODDIR} /${file} " > /dev/null; then
35+ return 1
36+ fi
37+ done
38+
39+ return 0
40+ }
941
1042echo
1143echo " *******************************************************************************"
@@ -26,11 +58,10 @@ if [ ! -d "${ROOTDIR}/.git" ]; then
2658fi
2759
2860# Check for internet connection.
29- wget -q --spider https://reactos.org
30-
31- if [ $? -eq 0 ]; then
61+ if wget -q --spider https://reactos.org; then
3262 internet=true
3363else
64+ internet=false
3465 echo " Warning: No internet connection detected."
3566 echo " Optional modules cannot be downloaded and origin cannot be fetched."
3667 echo
5687# Clean repository, excluding the modules/optional folder and its contents.
5788git clean -d -f -f -x --exclude=" /modules/optional/*"
5889# Fetch changes from origin if we have an internet connection.
59- if [ " $internet " ] ; then
90+ if $internet ; then
6091 git fetch origin
6192fi
6293# Reset to the head of the branch
6596
6697# Download the "optional" folder from svn.reactos.org if it isn't already downloaded.
6798# Ensure the optional modules folder is there and contains the modules we need.
68- if [ -d " ${OPTMODDIR} " ] && [ -f " ${OPTMODDIR} /DroidSansFallback.ttf " ] && compgen -G " ${OPTMODDIR} /wine_gecko*.msi " > /dev/null ; then
99+ if check_required_files ; then
69100 echo " Optional modules already downloaded. Skipping."
70101 echo " If you have an issue with the optional modules, re-run this script after deleting the directory:"
71- echo " ${ROOTDIR} / ${ OPTMODDIR}"
72- elif [ " ${ internet} " ] ; then
102+ echo " ${OPTMODDIR} "
103+ elif $ internet; then
73104 echo " Downloading optional modules..."
74105 if [ -d " ${OPTMODDIR} " ]; then
75106 rm -rf " ${OPTMODDIR} "
76107 fi
77108 mkdir " ${OPTMODDIR} "
78109 cd " ${OPTMODDIR} "
79- wget --recursive --level=1 --no-directories --no-parent --execute robots=off " https://svn.reactos.org/optional "
110+ download_required_files
80111 # Check that all mandatory files were downloaded.
81- if [ ! -f " DroidSansFallback.ttf" ]; then
82- echo " DroidSansFallback CJK font missing!"
83- exit 1
84- fi
85- if ! compgen -G " wine_gecko*.msi" > /dev/null; then
86- echo " wine_gecko MSI package missing!"
112+ if ! check_required_files; then
113+ echo " FAILED: One or more required files are missing."
87114 exit 1
88115 fi
89116else
90- echo " FAILED: Missing optional modules and no internet connection."
117+ echo " FAILED: Missing required files and no internet connection to download them ."
91118 exit 1
92119fi
93120echo
@@ -117,7 +144,7 @@ cd "${ROOTDIR}"
117144git archive --format=zip --prefix=" ${EXPORTDIR} /" -9 --output=" ${ROOTDIR} /${DELIVERDIR} /${SOURCEZIP} " " $( git rev-parse HEAD) "
118145
119146# We're done!
120- if [ -z " $internet " ] ; then
147+ if ! $internet ; then
121148 echo
122149 echo " Warning: No internet connection. HEAD may be stale."
123150 echo " HEAD: $( git describe) "
0 commit comments