User:Oldman/A layman's guide/Miscellaneous

From ReactOS Wiki
Jump to: navigation, search

Scripts

In this section you will find some useful scripts, which help you to achieve things already decribed in the sections above.

Use the following scripts at your own discretion. As with other software, the scripts come with no guarantee!

Windows - Create the Tutorial working environment

This script is intended to be used once, to automate (but needs user input) the setting up of a working environment (all the directories, software and ReactOS source code) as described in the Layman's guides. But could also be a useful peice of software to test in ReactOS.

What will this script do?

It first ask the user for a drive letter, then it will use that drive letter to create the following directory structure:

drive letter:\REACTOS_DEVELOPMENT
              +---Compiled
              +---Debug
              +---ISO
              +---Required_Software
              +---RosBE
              +---Source

It then down loads a none zipped, none installable version of wget, then down loads 7-zip, curl, Git for Windows and RosBE. All these software down loads must be saved into the Required_Software directory. After each down load, it will start the software's installer, as required.


Next it will down load and clone https://github.com/reactos/reactos.git into the source directory, then it creates a script Revision.txt, which stores the date and revision number. Then it creates another script update-source.cmd, which can be used to update the local source tree, when required (it will update Revision.txt and also create/update update.txt with commit history). It also creates a script (iso-revisioner.cmd) to move an iso from the Compiled directory to the ISO directory and add the revision number to it, so bootcd.iso will become something like 0.4.9-dev-652-gdffd748 (updated at 19:01:18.70 on 08/04/2018). These scripts will be found in the REACTOS_DEVELOPMENT directory.

Note: The drive letter that was selected in the running script, will also be in the scripts update-source.cmd and iso-revisioner.cmd!

This is the script (below), which has intentionally been reduced in size to fit the page!

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::      This script automates the setting up of a working environment, as per the Layman's guides.     ::
:: I hate EULAs.  ©Nobody.  Use at your own risk! It worked for me and did what it was intended to do. ::
::      It is not the most elegant script and it maybe is over-kill in parts, but it works for me.     ::
::                                             Version 0.3                                             ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
:: Populate the variable, ready for use.
set text= * An error occured down loading
:: RosBE revision number. Change it here and it will be applied throughout the script.
set RBEver=2.1.6
:: Put the URLs into variables, this will save line length later. Some links may need to be changed in the future.
set Wget=https://eternallybored.org/misc/wget/1.19.4/32/wget.exe
set zip=http://www.7-zip.org/a/7z1604.exe
set Curl=https://winampplugins.co.uk/curl/curl_7_53_1_openssl_nghttp2_x86.7z
set GetGit=https://github.com/git-for-windows/git/releases/download/v2.10.0.windows.1/Git-2.10.0-32-bit.exe
set RBE=https://sourceforge.net/projects/reactos/files/RosBE-Windows/i386/%RBEver%/RosBE-%RBEver%.exe/download
:: Put the paths into variables.
set pf=C:\"Program Files"
set R_D=:\ReactOS_Development
set R_Dcmp=:\ReactOS_Development\Compiled
set R_Ddbg=:\ReactOS_Development\Debug
set R_Diso=:\ReactOS_Development\ISO
set R_Dreqs=:\ReactOS_Development\Required_Software
set R_Drbe=:\ReactOS_Development\RosBE
set R_Dscrpt=:\ReactOS_Development\Scripts
set R_Dsrc=:\ReactOS_Development\Source
::
cls
echo  ##############################################################################
echo  # This script will setup a working environment similar to what is described  #
echo  # in the Layman's guides at https://reactos.org/wiki (Windows XP or ReactOS) #
echo  #   Should only need to be run once, but can safely be run several times.    #
echo  ##############################################################################
echo  Now starting the setup!
:choice
echo  Choose which drive to create the directory tree in!
echo  Such as C, D, E, F, etc.
set /p drv= Enter drive letter 
:: Now check to see if the selected drive exists!
if not exist %drv%:\ (echo  * Drive %drv%: does not exist! && goto :choice)
echo  The directory tree will now be created in drive %drv%:
:: Now make the directory tree. If the directory does not exist, then create it.
if not exist %drv%%R_D%  (mkdir %drv%%R_D% && echo  * Created %drv%%R_D%)
if not exist %drv%%R_Dcmp%  (mkdir %drv%%R_Dcmp% && echo  * Created \Compiled)
if not exist %drv%%R_Ddbg%  (mkdir %drv%%R_Ddbg% && echo  * Created \Debug)
if not exist %drv%%R_Diso%  (mkdir %drv%%R_Diso% && echo  * Created \ISO)
if not exist %drv%%R_Dreqs%  (mkdir %drv%%R_Dreqs% && echo  * Created \Required_Software)
if not exist %drv%%R_Drbe%  (mkdir %drv%%R_Drbe% && echo  * Created \RosBE)
if not exist %drv%%R_Dscrpt%  (mkdir %drv%%R_Dscrpt% && echo  * Created \Scripts)
if not exist %drv%%R_Dsrc%  (mkdir %drv%%R_Dsrc% && echo  * Created \Source)
:: Move into the software directory to down load the required software.
cd %drv%%R_Dreqs%
echo  ################## PLEASE READ THE FOLLOWING ##################
echo  wget will be down loaded next, either with dwnl (ReactOS app) 
echo  or with your default browser!
echo  Please make sure that your browser saves it to
echo                  %drv%%R_Dreqs%.
:: Pause here to give time for the above text to be read.
set /p temp="Please note the above and when you are ready, press Enter to continue"
:getwget
if not exist wget.exe (echo  ... Down loading wget! && dwnl %Wget% wget.exe || echo Your browser will now open! && start %Wget% || goto :errorwget) else (echo  * You already have wget.exe && goto :get7-zip)
set /p temp="When wget has been saved to %R_Dreqs%, press Enter to continue"
:get7-zip 
if exist %pf%\7-Zip\7z.exe (echo  * You have 7zip installed && goto :getcurl)
if not exist 7z1604.exe (dwnl %zip% 7z1604.exe || wget %zip% > 7z1604.exe || goto :error7-zip)
set /p temp="When 7zip has been saved to %R_Dreqs%, press Enter to continue"
if exist 7z1604.exe (echo  * 7zip has been successfully down loaded! && goto :inst7-zip)
:inst7-zip
if not exist %pf%\7-Zip\7z.exe (echo  ... Running 7-zip installer && start 7z1604.exe && ping -n 11 127.0.0.1>nul)
if exist %pf%\7-Zip\7z.exe (echo  * 7-zip is now installed! && goto :getcurl)
:getcurl
if exist curl.exe (echo  * You already have curl && goto :getgit)
if not exist curl_7_53_1_openssl_nghttp2_x86.7z (echo  ... Down loading curl. && wget --no-check-certificate %Curl% || goto :errorcurl)
set /p temp="When curl has been saved to %R_Dreqs%, press Enter to continue"
if exist curl_7_53_1_openssl_nghttp2_x86.7z (echo  * curl has been successfully down loaded! && goto :extractcurl)
:extractcurl
if exist curl_7_53_1_openssl_nghttp2_x86.7z (start %pf%\7-Zip\7z.exe e curl_7_53_1_openssl_nghttp2_x86.7z && ping -n 11 127.0.0.1>nul)
if exist curl.exe (echo  * curl is now ready to use!)
:getgit
if not exist %pf%\Git\bin\git.exe (echo  ... Down loading Git && curl --cookie nada --location %GetGit% > Git-2.10.0-32-bit.exe || goto :errorgit) else (echo  * git is already installed! && goto :getRosBE)
set /p temp="When git has been saved to %R_Dreqs%, press Enter to continue"
if exist Git-2.10.0-32-bit.exe (echo  * Git has been successfully down loaded! && goto :instgit)
:instgit
echo  #################### PLEASE READ THE FOLLOWING ####################
echo ** DO NOT select * mintty * in the installation.
echo  Please select * Windows' default consel window * in the installation.
set /p temp="Please note the above and when you are ready, press Enter to continue"
if exist Git-2.10.0-32-bit.exe (echo  ... Starting the Git installer. && start Git-2.10.0-32-bit.exe || echo  * Failed to install git!)
set /p temp="When git has been installed, press Enter to continue"
if exist %pf%\Git\bin\git.exe (echo  *  git has been successfully installed)
:getRosBE
if not exist RosBE-%RBEver%.exe (echo  * Down loading RosBE && curl --cookie nada --location %RBE% > RosBE-%RBEver%.exe || goto :errorRosBE) else (echo  * Found RosBE-%RBEver% installer, so it should be installed! && goto :clone)
set /p temp="When RosBE has been saved to %R_Dreqs%, press Enter to continue"
if exist RosBE-%RBEver%.exe (echo  * RosBE has been successfully down loaded!) 
:instRosBE
echo  #################### PLEASE READ THE FOLLOWING ####################
echo  The RosBE installer will give you the choice where to install it to.
echo  You can install it to it's default directory or here in 
echo  %drv%%R_Drbe% or where ever you choose.
:: Pause here to give time for the above text to be read.
set /p temp="Please note the above and when you are ready, press Enter to continue"
if exist RosBE-%RBEver%.exe (start RosBE-%RBEver%.exe || echo  * Failed to install RosBE!) 
set /p temp="When RosBE has been installed, press Enter to continue"
:clone
if exist %drv%%R_Dsrc%\reactos echo  * The source appears to have already been cloned && goto :make_script
cd %drv%%R_Dsrc%
echo  ... Cloning the ReactOS source tree to a local folder. && git clone https://github.com/reactos/reactos.git || goto :giterror
set /p temp="When the source tree has been cloned, press Enter to continue"
cd %drv%%R_Dsrc%\reactos
echo ~~~~~ %time% - %date% ~~~~~ 1>>  %drv%%R_Dscrpt%\Revision.txt
:: Find the revision number and write it to revision.txt.
git describe 1>> %drv%%R_Dscrpt%\Revision.txt
:make_script
:: Check here to see if the script 'update-source.cmd' has already been created.
if exist %drv%%R_Dscrpt%\update-source.cmd (goto :finish)
:: Start making the script
echo  * Creating the script update-source.cmd
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1>> %drv%%R_Dscrpt%\update-source.cmd
echo :: Automates the updating of your local source tree as per the tutorial.                          :: 1>> %drv%%R_Dscrpt%\update-source.cmd
echo :: I hate EULAs.  ©Nobody. Use at your own risk! It worked for me and did what I wanted it to do. :: 1>> %drv%%R_Dscrpt%\update-source.cmd
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1>> %drv%%R_Dscrpt%\update-source.cmd
echo @echo off 1>> %drv%%R_Dscrpt%\update-source.cmd
echo cls 1>> %drv%%R_Dscrpt%\update-source.cmd
echo echo  * Checking for source code changes and additions! Please give it time to complete. 1>> %drv%%R_Dscrpt%\update-source.cmd
echo cd %drv%%R_Dsrc%\reactos 1>> %drv%%R_Dscrpt%\update-source.cmd
echo git  pull origin 1^>^> %drv%%R_Dscrpt%\update.txt 1>> %drv%%R_Dscrpt%\update-source.cmd
echo :: Find the revision number and write it to Revision.txt. 1>> %drv%%R_Dscrpt%\update-source.cmd
echo for /F "tokens=* usebackq" %%%%v in ^(`git describe`^) do ^(set version=%%%%v^) 1>> %drv%%R_Dscrpt%\update-source.cmd
echo echo #################### %%version%% updated at %%time%% on %%date%% #################### 1^>^> %drv%%R_Dscrpt%\update.txt 1>> %drv%%R_Dscrpt%\update-source.cmd 
echo echo * %%version%% ^(updated at %%time%% on %%date%%^) 1^>^> %drv%%R_Dscrpt%\Revision.txt 1>> %drv%%R_Dscrpt%\update-source.cmd
echo echo             ~~~~~~~~~~~~~~ Finished. ~~~~~~~~~~~~~~ 1>> %drv%%R_Dscrpt%\update-source.cmd
::
:: Make a script to add the revision number to the iso in the Compiled directory and move it to the ISO directory
::
echo  * Creating the script iso-revisioner.cmd
echo @echo off 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo cls 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo ::  This script moves a locally compiled iso, from Compiled directory   :: 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo ::          to the ISO directory, adding the revision number.           :: 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo ::       I hate EULAs.  Copyright  Nobody. Use at your own risk!        :: 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo ::           It worked for me and did what I wanted it to do.           :: 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo echo Changing directory to %drv%%R_Dsrc%\reactos 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo cd %drv%%R_Dsrc%\reactos 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo for /F "tokens=* usebackq" %%%%v in ^(`git describe`^) do ^(set version=%%%%v^) 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo cd %drv%%R_Dcmp% 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd 
echo if exist livecd.iso ^( echo found livecd ^&^& move %drv%%R_Dcmp%\livecd.iso %drv%%R_Diso%\%%version%%-livecd.iso ^) 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo if exist bootcd.iso ^( echo found bootcd ^&^& move %drv%%R_Dcmp%\bootcd.iso %drv%%R_Diso%\%%version%%-bootcd.iso ^) 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo if exist hybrid.iso ^( echo found hybridcd ^&^& move %drv%%R_Dcmp%\hybridcd.iso %drv%%R_Diso%\%%version%%-hybridcd.iso ^) 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
echo echo             ~~~~~~~~~~~~~~ Finished. ~~~~~~~~~~~~~~ 1>> %drv%%R_Dscrpt%\iso-revisioner.cmd
::
echo  #################### PLEASE READ THE FOLLOWING ####################
echo The working environment should now be all setup and ready to use.
echo A batch script 'update-source.cmd' has been created in %drv%%R_Dscrpt%. 
echo Use this script to update the source tree.
echo A batch script 'iso-revisioner.cmd' has been created in %drv%%R_Dscrpt%. 
echo Use this script to move a compiled iso from the Compiled directory
echo into the ISO directory and add the revision number to it.
:finish
echo .
echo             ~~~~~~~~~~~~~~ Finished. ~~~~~~~~~~~~~~
set /p temp="  Press Enter to exit"	
exit
:errorwget
echo  %text% wget. && goto :failed
:error7-zip
echo  %text%  7-zip. && goto :failed
:errorcurl
echo  %text%  curl. && goto :failed
:errorgit
echo  %text%  git. && goto :failed
:errorRosBE
echo  %text% RosBE. && goto :failed
:giterror
:: This was added because the system did not find git the first time. 
echo  * An error occured while trying to clone the ReactOS source tree!
echo  ######################### PLEASE READ THE FOLLOWING #########################
echo  NOTE: If this script is run again from the begining, it will first check
echo  for the needed software, before attempting any more down loads or installs!
echo  So you could run the script at a another time to clone the source.
set /p yes-no= Do you want to retry to clone the ReactOS source now [y/n]?
if %yes-no%==y echo  * Running the clone section again && goto :clone
if %yes-no%==n echo * You can still try again later. && goto :failed
:failed
echo .
echo    *********** Unforutatley, the script as failed to complete! ***********
set /p temp="  Press Enter to exit"
exit

To get the script, just copy from here and paste it into a good text editor (not Windows Notepad.exe), then save it with the file extension of cmd and run it at your leisure. It will save you a lot of typing (if you are happy with the directory names) and only needs to be run once to create a working environment, but can safely be run several times without doing an harm. Before it writes any to your drive, it will check to see if it already exists.

Using the two scripts that it creates:

iso-revisioner.cmd

Use this to move a compiled iso, from the Compiled directory to the ISO directory; it will add the revision number to the front of the iso, so that bootcd.iso becomes something like 0.4.9-dev-652-gdffd748-bootcd.iso

update-source.cmd

Use this to update your local source tree, either by double clicking on it (easiest way) or running it from a command window. It will write to two text files, Revision.txt which stores the revision number with the time and date, update.txt which stores all the commit messages for that update, along with the time and date.


This is what the entries that are written to Revision.txt look like when you use update-source.cmd to update your local source:

* 0.4.9-dev-652-gdffd748 (updated at 19:01:18.70 on 08/04/2018)
* 0.4.9-dev-657-ge195199 (updated at 14:06:56.16 on 09/04/2018) 

.

And this is an entry in update.txt

Updating 10e4517..dffd748
Fast-forward
 dll/apisets/api-ms-win-core-fibers-l1-1-0.spec |   8 +-
 dll/apisets/api-ms-win-core-fibers-l1-1-1.spec |   8 +-
 dll/apisets/api-ms-win-core-synch-l1-1-0.spec  |   2 +-
 dll/apisets/api-ms-win-core-synch-l1-2-0.spec  |   2 +-
 dll/apisets/api-ms-win-core-synch-l1-2-1.spec  |   2 +-
 dll/apisets/update.py                          |  33 ++++--
 dll/win32/kernel32/client/fiber.c              | 148 ++++++++++++++++---------
 dll/win32/kernel32/kernel32.spec               |   8 +-
 dll/win32/kernel32_vista/k32_vista.h           |   1 +
 dll/win32/kernel32_vista/kernel32_vista.spec   |   2 +
 dll/win32/kernel32_vista/sync.c                |  31 +++++-
 win32ss/user/winsrv/usersrv/harderror.c        |  25 ++---
 12 files changed, 171 insertions(+), 99 deletions(-)
#################### 0.4.9-dev-652-gdffd748 updated at 19:01:18.70 on 08/04/2018 ####################   

If you do not want to log the commits, then you will have to open update-source.cmd in a text editor and remove the text highlight in pale blue, as shown in the above image, which will stop update.txt from being created and written to.

iso-revisioner.cmd universal

For the people who have their own directory structure, here is a script that will create another script (iso-revisioner.cmd) to move and rename an iso file as above, but the creating script asks where you want the script to be created, where the iso is to be found, where you want it to be moved to and where the ReactOS source code is (local source tree). It then uses this information to create the correct paths in the iso-revisioner.cmd script, so you only need to run the script to move and add the revision number.

@echo off
cls
echo  *  I hate EULAs.  Copyright  Nobody. Use at your own risk! *
echo  This script will create another script that moves a locally compiled iso file
echo  to another location and prefixes it with the commit number, so that bootcd.iso
echo  becomes like this 0.4.9-dev-652-gdffd748-bootcd.iso.
echo  Where do you want this file to be created?
set /p script_dir= Enter the directory path: 
echo @echo off 1> %script_dir%\iso-revisioner.cmd
echo cls 1>> %script_dir%\iso-revisioner.cmd
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1>> %script_dir%\iso-revisioner.cmd
echo ::             This script moves a locally compiled iso,                :: 1>> %script_dir%\iso-revisioner.cmd
echo ::       from one location to another adding the revision number.       :: 1>> %script_dir%\iso-revisioner.cmd
echo ::        I hate EULAs.  Copyright  Nobody. Use at your own risk!       :: 1>> %script_dir%\iso-revisioner.cmd 
echo ::           It worked for me and did what I wanted it to do.           :: 1>> %script_dir%\iso-revisioner.cmd
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1>> %script_dir%\iso-revisioner.cmd
echo  Where is the iso to be found?
echo  Example "C:\ReactOS_Development\Compiled"
set /p path1= Enter the path to the iso: 
echo  Where do you want to move it to?
echo  Example "C:\ReactOS_Development\ISO" ISO is the directory to move the iso to.
set /p path2= Enter destination path: 
echo  Where is the ReactOS source code located?
echo  Example: "C:\ReactOS_Development\Source\reactos"
set /p path3= Enter directory path to the source code: 
echo cd %path3% 1>> %script_dir%\iso-revisioner.cmd
echo for /F "tokens=* usebackq" %%%%v in ^(`git describe`^) do ^(set version=%%%%v^) 1>> %script_dir%\iso-revisioner.cmd
echo if exist %path1%\livecd.iso ^( echo found livecd ^&^& move %path1%\livecd.iso %path2%\%%version%%-livecd.iso ^) 1>> %script_dir%\iso-revisioner.cmd
echo if exist %path1%\bootcd.iso ^( echo found bootcd ^&^& move %path1%\bootcd.iso %path2%\%%version%%-bootcd.iso ^) 1>> %script_dir%\iso-revisioner.cmd
echo if exist %path1%\hybrid.iso ^( echo found hybridcd ^&^& move %path1%\hybridcd.iso %path2%\%%version%%-hybridcd.iso ^) 1>> %script_dir%\iso-revisioner.cmd

As with the other scripts here, just cut and paste it into a good text editor, then save it with the file type of .cmd and then run it to create the iso-revisioner.cmd script.


UNIX section

Software checker-installer for RosBE

This script will check for any of the required dependancies for the ReactOS Build Environment (RosBE) and if any are found to be missing, then the script will then look for a Package Manager from a list, if your system's Package Manager is in the list, it will then try to install the missing application.

It should work in the following Distros:

   Distro:                           Package Manager:       Package type:
* Antix 17, a debian derivative            apt                deb
* Antix 17, a debian derivative            apt-get            deb
* Fedora 28 (Redhat)                       dnf                rpm
* gecko, a opensuse derivative             zypper             rpm
* Manjaro, a Arch derivative               pacman             pkg.tar.xz
* SME, a CentOS/Fedora derivative          yum                rpm
* Vector, a slackware derivative           slatp-get          txz

It does not work for all distos, because there are lots of different package managers and also some distros put some apps in different packages or name the package differently to other distros.

This is the script:

#!/bin/bash
#######################################################################################################
#        This script checks for missing application and will install them via sudo privilage .        #
#                        I hate EULAs. Copyright Nobody.  Use at your own risk!                       #
#                         It worked for me and did what it was intended to do.                        #
#######################################################################################################

clear

# Text colour
bwhit='\033[1;37m' # Bright White
pblue='\033[1;4m'  # Pale Blue
bred='\033[1;31m'  # Bright Red
bgrun='\033[1;32m' # Bright Green
byel='\033[1;33m'  # Bright Yellow
dyel='\033[0;33m'  # Dark Yellow
rs='\033[0m'       # Reset the text back to the default

mis="MISSING"
got="FOUND"

if [ ! sudo ] # if not installed.
then
    printf " *  Please install sudo\n"
    exit
fi

# OK. This works in Antix, a debian derivative.
function apt_install()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = "as" ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo apt install binutils || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = "makeinfo" ] # 'makeinfo' is in package texinfo
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo apt install texinfo || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = zlib ]
    then
      if ! pkg-config --exists zlib;
      then
        printf " ${byel}*${rs} Installing $have_we\n" && sudo apt install zlib1g zlib1g-dev || printf " * Failed to install $have_we\n"
      fi
    else
	  printf " ${byel}*${rs} Installing $have_we\n" && sudo apt install $have_we || printf " ${bred}*${rs} Failed to install $have_we\n"
    ((cnt++))
    fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

# OK. This works in Antix, a debian derivative.
function apt-get_install()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = "as" ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo apt-get install binutils || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = "makeinfo" ] # 'makeinfo' is in package texinfo
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo apt-get install texinfo || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = zlib ]
    then
      if ! pkg-config --exists zlib;
      then
        printf " ${byel}*${rs} Installing $have_we\n" && sudo apt-get install zlib1g zlib1g-dev || printf " * Failed to install $have_we\n"
      fi
    else
	  printf " ${byel}*${rs} Installing $have_we\n" && sudo apt-get install $have_we || printf " ${bred}*${rs} Failed to install $have_we\n"
    ((cnt++))
    fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

# OK This works in Fedora 28.
function dnf_install()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = as ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo dnf install binutils || printf " ${bgrun}*${rs} Failed to install $have_we\n"
    elif [ $have_we = makeinfo ] # 'makeinfo' is in package texinfo
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo dnf install texinfo || printf " ${bgrun}*${rs} Failed to install $have_we\n"
    elif [ $have_we = g++ ] # 'g++' is in package gcc-c++ possibly for all rpm packages.
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo dnf install gcc-c++ || printf " ${bgrun}*${rs} Failed to install $have_we\n"
    elif [ $have_we = zlib ]  # zlib has it's own package but requires zlib-devel for pkg-config to find it.
    then
      if ! pkg-config --exists zlib;
      then
        printf " ${byel}*${rs} Installing zlib and zlib-devel\n" && sudo dnf install zlib zlib-devel || printf " ${bgrun}*${rs} Failed to install zlib and/or zlib-devel\n"
      fi
    else
	  printf " ${byel}*${rs} Installing $have_we\n"  && sudo dnf install $have_we || printf " ${bgrun}*${rs} Failed to install $have_we\n"
    ((cnt++))
    fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

# OK. This works in Manjaro, a Arch derivative.
function pacman_install()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = "as" ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo pacman -S binutils || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = "makeinfo" ] # 'makeinfo' is in package texinfo
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo pacman -S texinfo || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = zlib ]
    then
      if ! pkg-config --exists zlib;
      then
        printf " ${byel}*${rs} Installing $have_we\n" && sudo pacman -S $have_we || printf "${bgrun}*${rs}Failed to install $have_we\n"
      fi
    else
	  printf " ${byel}*${rs} Installing $have_we\n"  && sudo pacman -S $have_we || printf " ${bred}*${rs} Failed to install $have_we\n"
    ((cnt++))
	fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

# This is OK.
function slapt-get_install()
{
helper_apps="as bison curl flex gcc g++ git make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = "as" ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo slapt-get --install binutils || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = "makeinfo" ] # 'makeinfo' is in package texinfo
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo slapt-get --install texinfo || printf " ${bred}*${rs} Failed to install $have_we\n"
    elif [ $have_we = g++ ] # 'g++' is in package gcc-g++.
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo slapt-get --install gcc-g++ || printf "${bgrun}*${rs}Failed to install $have_we\n"
    elif [ $have_we = zlib ]
    then
      if ! pkg-config --exists zlib;
      then
        printf " ${byel}*${rs} Installing $have_we\n" && sudo slapt-get --install zlib || printf "${bgrun}*${rs}Failed to install $have_we\n"
      fi
    else
	  printf " ${byel}*${rs} Installing $have_we\n" && sudo slapt-get --install $have_we || printf " ${bred}*${rs} Failed to install $have_we\n"
    ((cnt++))
    fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

# OK. This works in SME server, a CentOS derivative.
function yum_install()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = as ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo yum install binutils || printf "${bgrun}*${rs}Failed to install $have_we\n"
    elif [ $have_we = makeinfo ] # 'makeinfo' is in package texinfo
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo yum install texinfo || printf "${bgrun}*${rs}Failed to install $have_we\n"
    elif [ $have_we = g++ ] # 'g++' is in package gcc-c++ possibly for all rpm packages.
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo yum install gcc-c++ || printf "${bgrun}*${rs}Failed to install $have_we\n"
    elif [ $have_we = zlib ]  # zlib has it's own package but requires zlib-devel for pkg-config to find it.
    then
      if ! pkg-config --exists zlib;
      then
        printf " ${byel}*${rs} Installing zlib and zlib-devel\n" && sudo yum install zlib zlib-devel || printf "${bgrun}*${rs}Failed to install zlib and/or zlib-devel\n"
      fi
    else
	  printf " ${byel}*${rs} Installing $have_we\n"  && sudo yum install $have_we || printf "${bgrun}*${rs}Failed to install $have_we\n"
    ((cnt++))
    fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

# OK. This works in gecko, a opensuse derivative.
function zypper_install()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python zlib";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    if [ $have_we = as ] # 'as' is in package binutils
    then
      printf " ${byel}*${rs} Installing $have_we\n" && sudo zypper install binutils || printf "${bgrun}*${rs}Failed to install $have_we\n"
    elif [ $have_we = g++ ] # 'g++' is in package gcc-c++ possibly for all rpm packages.
    then
      printf " ${byel}*${rs} Installing $have_we\n"  && sudo zypper install gcc-c++ || printf "${bgrun}*${rs}Failed to install $have_we\n"
     elif [ $have_we = zlib ] # 'zlib' is in package libz1 possibly for all rpm packages.  zlib-devel is also needed.
     then
       if ! pkg-config --exists zlib;
       then
         printf " ${byel}*${rs} Installing $have_we\n" && sudo zypper install libz1 && sudo zypper in zlib-devel || printf "${bgrun}*${rs}Failed to install $have_we\n"
       fi
     else
	   printf " ${byel}*${rs} Installing $have_we\n" && sudo zypper install $have_we || printf "${bgrun}*${rs}Failed to install $have_we\n"
     ((cnt++))
     fi
  else
    printf " ${bgrun}*${rs} Searched and found $have_we.\n"
  fi
done
check_for_apps
}

function find_pm()
{
printf "\n * * * * * * * * * ${pblue}Searching for a package management tool${rs} * * * * * * * * * * \n\n"
package_apps="apt apt-get dnf pacman slapt-get pkg yum zypper"; # Total PMs is 8.
cnt_pm=0
for have_got in $package_apps;
do
  if [ -x "$(command -v $have_got)" ]
  then
      printf " ${bgrun}*${rs} Found $have_got\n"
      $have_got"_install"
      break
  else
      ((cnt_pm++))
      printf " ${bred}*${rs} No $have_got\n"
  fi
done

if [ $cnt_pm -ge 8 ]
then
  printf "\n ${bred}*${rs} Sorry, your package Manager is not in the list.\n"
  printf "\n                           These are the required app(s)\n\n"
  check_for_apps
fi 
}

function check_for_apps()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    printf "${dyel}%-.71s${rs} ${bred}%s${rs}\n" " * Searched for $have_we ..................................................... " "$mis"
    ((cnt++))
  else
    printf "%-.73s ${bgrun}%s${rs}\n" " * Searched for $have_we ..................................................... " "$got"
  fi
done
  if pkg-config --exists zlib;
  then
    printf "%-.73s ${bgrun}%s${rs}\n" " * Searched for zlib ..................................................... " "$got"
  else
    printf "${dyel}%-.71s${rs} ${bred}%s${rs}\n" " * Searched for zlib ..................................................... " "$mis"
    ((cnt++))
  fi
echo " " # space
  if ((cnt > 0));
  then
    printf " ${bred}*${rs} The script was unable to install %d ${bred}MISSING${rs} app(s).\n" "$cnt"
    printf " ${byel}*${rs} You will have to try and install what is missing yourself.\n"
  else
    printf " ${bgrun}OK${rs} Everything looks good to proceed.\n\n"
  fi
}
# After checking for sudo, the execution comes here.
needed_apps="as bison curl flex gcc git g++ make makeinfo pkg-config python";
for is_in in $needed_apps;
do
  if ! [ -x "$(command -v $is_in)" ]
  then
    printf " ${bred}*${rs} You have one or more missing apps that need to be installed.\n"
    find_pm
    break
  else
    printf " ${bgrun}*${rs} Found $is_in\n"
    if ! pkg-config --exists zlib;
    then
      printf " ${bred}*${rs} zlib is missing\n"
      find_pm
    break
    fi
  fi
done
printf "\n  * * * * * * * * * * * * * * * * * * ${pblue}Finished${rs} * * * * * * * * * * * * * * * \n"

To use the script, just copy from here and paste it into a text editor, then save it with the file extension of sh. You will need to make this script executable by typing chmod +x (path) script name at the command prompt in a terminal window. Example: chmod +x /home/oldman/app-checker.sh


Create the Tutorial working environment

This script is intended to be used, to automate (but needs user input) the setting up of a working environment (all the directories, software and ReactOS source code) as described in the Layman's guides.

The directory structure.

/home/oldman/RosBuild
+-- Compiled
+-- Debug
+-- ISO-images
+-- Required-Software
+-- RosBE
+-- Source

The script starts by searching for the required software, including software used by the RosBE installer script. If it finds anything missing that is required, it will terminate, having first listed the FOUND and the MISSING software.

When you have installed all the missing software, you can safely run the script again. It will again list all the required software, but this time they should all be found, else it terminates again for you to install any missing items of software.

When all the required software is found it will then prompt you for a path to the directory where you wish to install the testing environment. It will check to see if it is a valid path and the user has the correct privileges. Note: there is an option for a default path for a none root user (see the directory structure above), the default is /home/user; the user in the example shown above in the directory structure, is oldman.

Next it looks for an installed version of RosBE, in two locations; if it fails to find RosBE installed, it will then look for the downloaded RosBE tar file, if that is not found, it will download and unpack it, then run the RosBE installer. Once the installer start to compile RosBE, there will be no more user input required for the duration of the script. If any errors occur, then the script will terminate with an error message

After RosBE is installed, the next step is the cloning of the ReactOS source from github into the newly created Source directory. When the cloning is complete, it writes the version number to Revision.txt.

After cloning the source, it creates the update.sh script for the user to use, whenever they want to update the local source. It updates the source and will write info into two different text files; update.txt, which saves the commit messages from the updated source and Revision.txt, which stores the revision number, the same Revision.txt file that was created and written to earlier, when the source was first cloned.


The script.

#!/bin/bash
#######################################################################################################
#      This script automates the setting up of a working environment, as per the Layman's guides.     #
# I hate EULAs.  ©Nobody.  Use at your own risk! It worked for me and did what it was intended to do. #
#######################################################################################################
clear
printf "\033[0;32m\n"
printf  "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n"
printf  "::   This script will setup a working environment similar to that described   ::\n"
printf  "::     in the Layman's guides at https://reactos.org/wiki (Unix sections)     ::\n"
printf  "::        Should only need to be run once, but can be safley run again.       ::\n"
printf  "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n"
printf "\033[0m\n"
# ############################### Define the variables in this section ################################

# Text colour
bwhit='\033[1;37m' # Bright White
pblue='\033[1;4m'  # Pale Blue
bred='\033[1;31m'  # Bright Red
bgrun='\033[1;32m' # Bright Green
byel='\033[1;33m'  # Bright Yellow
dyel='\033[0;33m'  # Dark Yellow
rs='\033[0m'       # Reset the text back to the default

# Messages
mis="MISSING"
got="FOUND"

# Directories to be created
RB="/RosBuild"
RBcpl="/RosBuild/Compiled"
RBdbg="/RosBuild/Debug"
RBiso="/RosBuild/ISO-images"
RBreq="/RosBuild/Required-Software"
RBrbe="/RosBuild/RosBE"
RBsrc="/RosBuild/Source"

# Links to external software (you only need to update here)
Rbe="https://sourceforge.net/projects/reactos/files/RosBE-Unix/2.1.2/RosBE-Unix-2.1.2.tar.bz2/download"
Ros_BE="RosBE-Unix-2.1.2.tar.bz2"

Rsrc="https://github.com/reactos/reactos.git"

# #########################################  Function section ######################################### 

function check_for_apps()
{
helper_apps="as bison curl flex gcc git g++ make makeinfo python sudo";
cnt=0
for have_we in $helper_apps;
do
  if ! [ -x "$(command -v $have_we)" ]
  then
    printf "${dyel}%-71s${rs} ${bred}%s${rs}\n" " * Searched for $have_we ..................................................... " "$mis"
    ((cnt++))
  else
    printf "%-.73s ${bgrun}%s${rs}\n" " * Searched for $have_we ..................................................... " "$got"
  fi
done
  if [ -e "/usr/bin/pkg-config" ]
    printf "%-.73s ${bgrun}%s${rs}\n" " * Searched for pkg-config ..................................................... " "$got"
  then
    if pkg-config --exists zlib;
    then
      printf "%-.73s ${bgrun}%s${rs}\n" " * Searched for zlib ..................................................... " "$got"
    else
      printf "${dyel}%-.71s${rs} ${bred}%s${rs}\n" " * Searched for zlib ..................................................... " "$mis"
  else
    printf "${dyel}%-.71s${rs} ${bred}%s${rs}\n" " * Searched for pkg-config ..................................................... " "$mis" 
	  ((cnt++))
  fi
echo " " # space
  if ((cnt > 0));
  then
    printf " Please install the above %d ${bred}MISSING${rs} app(s), then run the script again!\n" "$cnt"
    exit 1
  else
    printf " ${bgrun}OK${rs} Everything looks good to proceed.\n\n"
  fi
}

function get_path()
 {
    printf " ${byel}*${rs} Please enter a valid path for user $USER: \n"
    if ! [ "$(id -u)" = '0' ]; # Hide from root user
    then
      printf "   or press the ${byel}Enter${rs} key for the default path of ${byel}/home/$USER${rs}.\n\n"
    fi
    read PTD
    if test -z "$PTD" # empty
    then
      PTD=/home/$USER
    fi
    if test ! -d "$PTD"
    then
      printf "\n ${bred}ERROR${rs}: The path ${bwhit}$PTD${rs} does exist!\n\n" && get_path
    fi
    if test ! -w "$PTD"
    then
      printf "\n ${bred}ERROR${rs}: You do not have write permission for this path!\n\n" && get_path
    fi
 }

function make_dirs()
 {
     get_path
   if test ! -z "$PTD" && test -d "$PTD" && test -w "$PTD";
   then
     test ! -d "$PTD$RB" && mkdir $PTD$RB && printf " ${byel}*${rs} Created directory RosBuild.\n"
     test ! -d "$PTD$RBcpl" && mkdir $PTD$RBcpl && printf " ${byel}*${rs} Created directory Compiled.\n"
     test ! -d "$PTD$RBdbg" && mkdir $PTD$RBdbg && printf " ${byel}*${rs} Created directory Debug.\n"
     test ! -d "$PTD$RBiso" && mkdir $PTD$RBiso && printf " ${byel}*${rs} Created directory ISO-images.\n"
     test ! -d "$PTD$RBreq" && mkdir $PTD$RBreq && printf " ${byel}*${rs} Created directory Required-Software.\n"
     test ! -d "$PTD$RBrbe" && mkdir $PTD$RBrbe && printf " ${byel}*${rs} Created directory RosBE.\n"
     test ! -d "$PTD$RBsrc" && mkdir $PTD$RBsrc && printf " ${byel}*${rs} Created directory Source.\n"
     printf "\n ${bgrun}*${rs} The directories were created in ${bwhit}%s${rs}\n\n" "$PTD"
   fi
 }

function get_rosbe()
 {
   cd $PTD/RosBuild/Required-Software
   rbe_found=""
   if [[ -d "/usr/local/RosBE" ]] || [[ -e "$PTD/RosBuild/RosBE/RosBE.sh" ]]
# returns 'true' if /usr/local/RosBE/RosBE.sh or $PTD/RosBuild/RosBE/RosBE.sh exists
   then
     rbe_found="ok"
     printf " ${dyel}*${rs} No need to download RosBE, it was found to be installed.\n\n"
   else
     if [ ! -e "$Ros_BE" ]
# returns 'true' if RosBE-Unix-2.1.2.tar.bz2 does not exist 
     then
       printf " ${byel}*${rs} Down-loading RosBE.\n\n"
       curl --cookie nada --location $Rbe > RosBE-Unix-2.1.2.tar.bz2 || return $?
       printf "\n ${byel}*${rs} RosBE download completed.\n\n"
     else
       printf " ${dyel}*${rs} The RosBE download package was found.\n\n"
     fi
   fi 
 }

function install_rosbe()
 { 
   if [ -e "$Ros_BE" ] && [ -z ${rbe_found} ] # rbe_found = RosBE is installed
   then # 'true' if RosBE-Unix-2.1.2.tar.bz2 exists and r_found is empty (RosBE not installed)
     while true
     do
       printf " ${byel}*${rs} Extracting RosBE "
       tar -xjf $Ros_BE --checkpoint=200 --checkpoint-action=. && printf " ${bgrun}Success${rs}\n\n" || return $?
     break # the above produces 'Extracting RosBE ................................ Success'
     done
     if [ -d "$PTD$RBreq/RosBE-Unix-2.1.2" ] && [ -z ${rbe_found} ] # RosBE download file is extracted but not installed
     then # 'true' if RosBe-Unix-2.1.2 dir exists and RosBE-Unix-2.1.2.tar.bz2 does not exist ($rbe_found is unset or empty)
       if ! [ "$(id -u)" = '0' ]; # Hides this from root user
       then
         printf "                ${byel}* * * * * * * *${rs} PLEASE READ THIS ${byel}* * * * * * * *${rs}\n"
         printf "  ${byel}*${rs} The RosBE script will inform you that  ${dyel}User is not \"root\"${rs} and ask you\n"
         printf "   ${dyel} Do you really want to continue? (yes/no)${rs}; type ${bwhit}yes${rs}. This will allow\n"
         printf "    you to install to your chosen path of ${bwhit}$PTD$RBrbe${rs}.\n\n"
         sleep 5
         printf "                       ${bred}* * * * * * *${rs} ${bwhit}WARNING${rs} ${bred}* * * * * *${rs}\n"
         printf " ${dyel}*${rs} If after choosing to continue, you select to have RosBE installed to the\n"
         printf "   default path of ${bwhit}/usr/local/RosBE${rs}, then you may get this error:\n"
         printf "   ${dyel}Installation directory \"/usr/local/RosBE\" is not writable, aborted!${rs} This\n"
         printf "   is due to ${bwhit}$USER${rs}'s lack of permissions! Both scripts will then terminate!\n\n"
         printf " ${byel}*${rs} Do you want to run the RosBE installer as root to give you a choice?\n\n"
         read -p "   Please answer yes or just press the Enter key for no: " ans
           case "$ans" in
             y|yes|Y|YES|Yes)
             printf "\n ${byel}*${rs} Starting the RosBE install script.\n\n"
             cd "$PTD/RosBuild/Required-Software/RosBE-Unix-2.1.2"
             sudo ./RosBE-Builder.sh || return $?
             printf "\n ${bgrun}*${rs} RosBE is now installed.\n\n"
           ;;
           esac
         fi
       printf "\n ${byel}*${rs} Starting the RosBE install script.\n\n"
       cd "$PTD/RosBuild/Required-Software/RosBE-Unix-2.1.2"
       ./RosBE-Builder.sh || return $?
       printf "\n ${bgrun}*${rs} RosBE is now installed.\n\n"
     else
       printf " ${dyel}*${rs} No need to install RosBE, it was found to be installed.\n\n"
     fi
   else
     printf " ${dyel}*${rs} No need to install RosBE, it was found to be installed.\n\n"
   fi
 }

function clone_source()
{
  if [ ! -d "$PTD$RBsrc/reactos" ]
  then # (true if not exists) Test for the existence 'Source/reactos' directory before cloning the source.
    cd $PTD/RosBuild/Source
    printf " ${byel}*${rs} Cloning the ReactOS source tree from Github into the Source directory.\n\n"
    git clone https://github.com/reactos/reactos.git || return $?
    printf "\n ${bgrun}*${rs} The ReactOS source was successfully cloned to $PTD$RBsrc\n\n"
    if [ -d "$PTD/RosBuild/Source/reactos" ] && [ ! -e "$PTD$RB/Revision.txt" ]
      # Test for the directory folder reactos and the existance of the Revision.txt.
    then # true if 'reactos' dir exists and Revision.txt does not exist
      cd $PTD/RosBuild/Source/reactos
      day_name=`date "+%A"`
      hr_min=`date "+%H:%M"`  
      day_date=`date "+%Y-%m-%d"`
      echo "   ------- $day_name at $hr_min - $day_date -------"   1>  $PTD/RosBuild/Source/Revision.txt
      # Find the revision number and write it to revision.txt.
      git describe 1>> $PTD/RosBuild/Revision.txt # The actual source files are in Source/reactos.
      printf " ${byel}*${rs} The day, time, date and revision number have been written to ${bwhit}$PTD$RB${rs}\n\n"
    fi
  else
    printf " ${bred}*${rs} $PTD$RBsrc/${dyel}reactos${rs} exists already!\n\n"
    printf " ${dyel}*${rs} If the clone process terminated before it finished,\n"
    printf "   then delete the ${dyel}reactos${rs} directory and run the script again.\n\n"
  fi
}

function make_script()
{
# Make a script for the user to updated the source code required.
# Check here to see if the script 'update-source.sh' has already been created.
  if [ ! -e  "$PTD/RosBuild/update-source.sh" ]
  then
    echo "printf \"::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n\"" 1> $PTD/RosBuild/update-source.sh
    echo "printf \":           Automates the updating of your local source tree as per the tutorial.                :\n\"" 1>> $PTD/RosBuild/update-source.sh
    echo "printf \": I hate EULAs.  ©Nobody. Use at your own risk! It worked for me and did what I wanted it to do. :\n\"" 1>> $PTD/RosBuild/update-source.sh
    echo "printf \"::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n\n\"" 1>> $PTD/RosBuild/update-source.sh
    echo "day_name=\`date \"+%A\"\`" 1>> $PTD/RosBuild/update-source.sh
    echo "hr_min=\`date \"+%H:%M\"\`" 1>> $PTD/RosBuild/update-source.sh
    echo "day_date=\`date \"+%Y-%m-%d\"\`" 1>> $PTD/RosBuild/update-source.sh
    echo "printf \" * Checking for source code changes and additions! Please give it time to complete.\n\n\"" 1>> $PTD/RosBuild/update-source.sh
    echo "cd $PTD/RosBuild/Source/reactos" 1>> $PTD/RosBuild/update-source.sh
    echo "git  pull origin 1>> $PTD/RosBuild/update.txt" 1>> $PTD/RosBuild/update-source.sh
    echo "echo \" ------- \$day_name at \$hr_min - \$day_date ------- \" 1>> $PTD/RosBuild/Revision.txt" 1>> $PTD/RosBuild/update-source.sh
    echo "echo \" ------- \$day_name at \$hr_min - \$day_date ------- \" 1>> $PTD/RosBuild/update.txt" 1>> $PTD/RosBuild/update-source.sh
    echo "# Find the revision number and write it to Revision.txt." 1>> $PTD/RosBuild/update-source.sh
    echo "git describe 1>> $PTD/RosBuild/Revision.txt" 1>> $PTD/RosBuild/update-source.sh
    echo "printf \" * Update completed. Please see /home/oldman/RosBuild/Revision.txt and update.txt\n\n\"" 1>> $PTD/RosBuild/update-source.sh
    if [ -e "$PTD/RosBuild/update-source.sh" ]
    then
      printf " ${byel}*${rs} A bash script '${byel}update-source.sh${rs}' has been created in ${bwhit}$PTD$RB${rs}.\n"
      printf "   You can use this script when you want to update the source tree.\n\n"
      chmod +x $PTD/RosBuild/update-source.sh # make the script executable.
    else
      printf " ${bred}*${rs} The creation of the 'update-source.sh' script ${bred}FAILED${rs}.\n" # failure
    fi
  else
    printf " ${dyel}*${rs} The script was found, so no need to create it!\n\n"
  fi
}

################################################## control section ##################################################

printf " * * * * * * * * * * * * ${pblue}Searching for needed helper apps${rs} * * * * * * * * * * *\n\n"
check_for_apps
printf " * * * * * * * * * * * * * * ${pblue}Create the directories${rs} * * * * * * * * * * * * * *\n\n"
make_dirs
printf " * * * * * * * * * * * * * * * * ${pblue}Download RosBE${rs} * * * * * * * * * * * * * * * *\n\n"
get_rosbe
if ! [ $? -eq 0 ] # 0 = success, so not equal to 0 = failure
then
  printf "\n ${bred}*${rs} The down-loading of the RosBE ${bred}FAILED${rs}!\n\n" && exit 1
fi
printf " * * * * * * * * * * * * * * * * ${pblue}Install RosBE${rs} * * * * * * * * * * * * * * * *\n\n"
install_rosbe
if ! [ $? -eq 0 ]
then
  printf "\n ${bred}*${rs} The installation of RosBE ${bred}FAILED${rs}!\n\n" && exit 1
fi
printf " * * * * * * * * * * * *  ${pblue}Clone the ReactOS source tree${rs} * * * * * * * * * * * *\n\n"
clone_source
if ! [ $? -eq 0 ]
then
  printf "\n ${bred}*${rs} The cloning of the ReactOS source ${bred}FAILED${rs}!\n\n" && exit 1
fi
printf " * * * * * * * * * * *  ${pblue}Create the update-source.sh script${rs} * * * * * * * * * * *\n\n"
make_script
printf " ${byel}* * *${rs} The working environment should now be all setup and ready to use. ${byel}* * *${rs}\n\n"
printf "\n * * * * * * * * * * * * ${pblue}This script has now terminated!${rs} * * * * * * * * * * * *\n\n"

To get the script, just copy from here and paste it into a text editor, then save it with the file extension of sh and run it at your leisure. It will save you a lot of typing (if you are happy with the directory names) and only needs to be run once to create a working environment, but can safely be run again if something did fail. You will need to make this script executable by typing chmod +x (path) script name at the command prompt in a terminal window. Example: chmod +x /home/oldman/setup.sh


Update the local source

This script is similar to the update script which was created by the last script above. It automates the updating of your local source tree using the directory structure shown in the tutorial. When the update is complete, it will create a file /home/RosBuild/revision.txt with the date and revision number. To use it, copy and paste it into a text editor, change the paths to suit your own directory tree and the file names to your own choice, then save as a .sh file with a name of your choice. You will need to make this script executable by typing chmod +x (path) script name at the command prompt in a terminal window.

#!/bin/bash
# Automates the updating of your local source tree as per the tutorial.
RevDate=$(date)
# Run git from the reactos folder.
cd /home/RosBuild/source/reactos/
# Do an update and write the output info to update.txt.
git pull origin 1>> /home/RosBuild/update.txt
# Write the current date to the update.txt.
echo "Update completed ------------ $RevDate" 1>> /home/RosBuild/update.txt
echo "update completed"
# Write the current date to the revision.txt.
echo "$RevDate" 1>> /home/RosBuild/revision.txt
# Get the current revision info and write it to revision.txt.
# The info will be in this format 0.4.8-dev-51-gbe1155f294
git describe 1>> /home/RosBuild/revision.txt
# Draw a line underneath to separate the revision updates.
echo "~~~~~~~~~~~~~~~~~~~~~~~~~" 1>> /home/RosBuild/revision.txt
echo 'done'


Software Links

These are the last declared revisions to support Windows XP (2003).

TortoiseGit:

TortoiseGit-1.8.16.0-32bit.msi (15.7 MiB)

https://download.tortoisegit.org/tgit/1.8.16.0/TortoiseGit-1.8.16.0-32bit.msi

TortoiseGit-1.8.16.0-64bit.msi (18.4 MiB)

https://download.tortoisegit.org/tgit/1.8.16.0/TortoiseGit-1.8.16.0-64bit.msi

Git for Windows:

Git-2.10.0-32-bit.exe (31.5 MB)

https://github.com/git-for-windows/git/releases/download/v2.10.0.windows.1/Git-2.10.0-32-bit.exe

Git-2.10.0-64-bit.exe (31.5 MB)

https://github.com/git-for-windows/git/releases/download/v2.10.0.windows.1/Git-2.10.0-64-bit.exe

7zip: 32-bit x86 (1 MB)

http://www.7-zip.org/a/7z1604.exe

64-bit x64 (1 MB)

http://www.7-zip.org/a/7z1604-x64.exe

wget

http://windows-get.sourceforge.net/wget.exe (v1.10)

http://eternallybored.org/misc/wget/current/wget.exe (curently v1.19)

curl:

https://winampplugins.co.uk/curl/curl_7_53_1_openssl_nghttp2_x86.7z


Layman's guides