The command line interface and bootstrapping

Introduction to the iwant cli and bootstrapping

Since a build system is so integral a part of a reproducible build, each project that uses iwant defines the exact version of iwant to use. To achieve this, the command line interface of iwant is a very shallow bootstrapper that only knows how to download and build the actual iwant engine and delegates the actual work to it.

The bootstrapper contains two command line interfaces: a bash script and an ant script. They both do the same thing: they compile and run the third part of the bootstrapper, a java class. This java class is the entry to iwant.

The entry class fetches (if necessary, of course) the requested version of iwant code and compiles and runs the next phase of bootstrapping, Iwant2.java.

The entry2 phase compiles the full iwant system it itself is part of and runs the actual entry to the system, Iwant3.java.

If in any of the bootstrapping phases some configuration is missing, the bootstrapper acts as a wizard that helps the user in creating the configuration.

In this tutorial we'll be mostly using the bash interface. The Ant cli chapter gives a short introduction to the ant command line interface.

Bootstrapping iwant

Let's see how all this works in practice.

First we'll create a directory for our project workspace and for the iwant bash cli.

~ $ mkdir -p iwant-tutorial/as-iwant-tutorial-developer/with/bash/iwant
~ $ cd iwant-tutorial

Then we download our first wish script: the script that downloads us the iwant bootstrapper.

~/iwant-tutorial $ cd as-iwant-tutorial-developer/with/bash/iwant
~/iwant-tutorial/as-iwant-tutorial-developer/with/bash/iwant $ wget https://raw.githubusercontent.com/wipu/iwant/feature/package-rename-to-org.fluentjava/essential/iwant-entry/as-some-developer/with/bash/iwant/iwant.sh
--2018-04-03 19:14:21-- https://raw.githubusercontent.com/wipu/iwant/feature/package-rename-to-org.fluentjava/essential/iwant-entry/as-some-developer/with/bash/iwant/iwant.sh
Resolving raw.githubusercontent.com... 151.101.84.133
Connecting to raw.githubusercontent.com|151.101.84.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 677 [text/plain]
Saving to: ‘iwant.sh’

0K 100% 54.9M=0s

2018-04-03 19:14:21 (54.9 MB/s) - ‘iwant.sh’ saved [677/677]

~/iwant-tutorial/as-iwant-tutorial-developer/with/bash/iwant $ chmod u+x iwant.sh

In this tutorial we use commit a184d3c3dde3436ae1015d38a5da57498ce14dca of iwant, but if you want to use the latest tested version, you can skip the following command:

~/iwant-tutorial/as-iwant-tutorial-developer/with/bash/iwant $ sed -i "s/COMMIT=.*/COMMIT=a184d3c3dde3436ae1015d38a5da57498ce14dca/" iwant.sh

Now we cd back to the workspace root; that's where we normally make our wishes.

~/iwant-tutorial/as-iwant-tutorial-developer/with/bash/iwant $ cd -
/home/hacker/iwant-tutorial

Now we are ready to make our first wish. By using the code completion feature (tab) of bash, we see that the only wish available is 'iwant.sh' that grants us iwant itself:

~/iwant-tutorial $ as-iwant-tutorial-developer/with/bash/iwant/iwant.sh
--2018-04-03 19:14:22-- https://raw.githubusercontent.com/wipu/iwant/a184d3c3dde3436ae1015d38a5da57498ce14dca/essential/iwant-entry/as-some-developer/with/ant/iw/build.xml
Resolving raw.githubusercontent.com... 151.101.84.133
Connecting to raw.githubusercontent.com|151.101.84.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1153 (1.1K) [text/plain]
Saving to: ‘build.xml’

0K . 100% 89.1M=0s

2018-04-03 19:14:22 (89.1 MB/s) - ‘build.xml’ saved [1153/1153]

/home/hacker/iwant-tutorial/as-iwant-tutorial-developer
--2018-04-03 19:14:22-- https://raw.githubusercontent.com/wipu/iwant/a184d3c3dde3436ae1015d38a5da57498ce14dca/essential/iwant-entry/as-some-developer/with/bash/iwant/help.sh
Resolving raw.githubusercontent.com... 151.101.84.133
Connecting to raw.githubusercontent.com|151.101.84.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 642 [text/plain]
Saving to: ‘help.sh’

0K 100% 42.9M=0s

2018-04-03 19:14:22 (42.9 MB/s) - ‘help.sh’ saved [642/642]

/home/hacker/iwant-tutorial/as-iwant-tutorial-developer
--2018-04-03 19:14:22-- https://raw.githubusercontent.com/wipu/iwant/a184d3c3dde3436ae1015d38a5da57498ce14dca/essential/iwant-entry/as-some-developer/with/java/org/fluentjava/iwant/entry/Iwant.java
Resolving raw.githubusercontent.com... 151.101.84.133
Connecting to raw.githubusercontent.com|151.101.84.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24469 (24K) [text/plain]
Saving to: ‘Iwant.java’

0K .......... .......... ... 100% 799K=0.03s

2018-04-03 19:14:23 (799 KB/s) - ‘Iwant.java’ saved [24469/24469]

/home/hacker/iwant-tutorial/as-iwant-tutorial-developer

Now we have the iwant bash cli available:

~/iwant-tutorial $ find as-iwant-tutorial-developer/with -type f | sort
as-iwant-tutorial-developer/with/ant/iw/build.xml
as-iwant-tutorial-developer/with/bash/iwant/help.sh
as-iwant-tutorial-developer/with/bash/iwant/iwant.sh
as-iwant-tutorial-developer/with/java/org/fluentjava/iwant/entry/Iwant.java
Output asserted

Starting using iwant

Now we are ready to make our first wish for iwant itself. By using the code completion feature (tab) of bash, we see that we now have another wish available: 'help':

~/iwant-tutorial $ as-iwant-tutorial-developer/with/bash/iwant/help.sh
I created /home/hacker/iwant-tutorial/as-iwant-tutorial-developer/i-have/conf/ws-info
Please edit it and rerun me.
Output asserted

We will continue defining the workspace in a separate chapter. The next chapter shows an alternative way of acquiring the bootstrapper using svn:externals, a handy mechanism for projects that use svn for version control.