Released Monday, January 25, 2016
Due Friday, Friday, 29, 2016, 7:00 PM
This lab will walk you through the process of setting up our development environments. It will also walk you through the process of integrating with the class's "organization" on github; this is crucial, since we will be using github for lab distribution (us to you) and submission (you to us).
Most of the work you will do will be on remote machines or machines you can interact with only via the command line. As a result, you will have to use a command line based editor. Two popular editors are vim and emacs. To edit a file, you would type:
$ vi myfile.txt # or $ emacs myfile.txt
Each has its benefits; ideally you should try both and figure out which editor best suits you. To get started, work through either this vim tutorial or the emacs tutorial that is built into the editor. (From within emacs, you can pull up the tutorial by typing C-h t. This is read as "press [ctrl]-h, then let go, then press t".)
If you're unfamiliar, spend at least an hour just navigating and editing sample text. You'll find that within a day or so, you'll have the required keystrokes internalized, and within a few days, you'll probably be faster at common editing tasks.
There will be two separate working platforms this semester: machines provided by CIMS (short for Courant Institute of Mathematical Sciences, which is the home of the CS department) and a virtual Ubuntu server that we have set up. We will indicate at the beginning of each lab which platform the lab will be using. Below, you will set up both of them.
Exercise Go here and follow the instructions for setting up your CIMS account.
Question 1. On any CIMS machine, run the command lscpu. Write down both the hostname (server name) of the cims machine on which you ran this, along with the entry for CPU family. You will have to submit this information to us in the last part of this lab.
Exercise Go here and follow the instructions for setting up the virtual machine.
For the next question, the hostname can be read from the command line. It follows the username of the logged in user and precedes the current directory's name.httpd@[hostname]:~$ _
Question 2. Write down the hostname of the virtual machine we provided. You'll need to submit this information later too.
We'll be using the Git version control system and github to distribute all of the files you'll need for this course. This requires that you be part of the cs480 organization on github, which in turn requires that all of you have a github account.
Exercise Go here and follow the instructions for setting up an account on github if you don't already have one.
Question 3. What is your github username? If we go to https://github.com/[username] we should not see the number '404' in a banner (as you do here, for example). We'll learn the significance of the number '404' soon.
Perform the following steps on the virtual machine you set up in the second part of this lab. Login as httpd.
# On the virtual machine, logged in as httpd $ mkdir ~/lab0 $ cd ~/lab0 $ git clone https://github.com/nyu-cs480-16sp/lab0.git . Cloning into '.'... remote: Counting objects: 13, done. remote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13 Unpacking objects: 100% (13/13), done. Checking connectivity... done. $
Life with git will be far easier at first if you use a graphical browser. Gitk is a good one that is installed on the lab platforms. Just type gitk while you are in a git repo (if you haven't heard the term "repo" before, it's short for "repository"; we and many others sometimes use this abbreviation).
Below are some exercises on git.
$ cd ~/lab0 $ make setup + cp /home/httpd/resources/submit.py /home/httpd/lab0 $
Now run git status to view the current state of the repository.
$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: answers.txt Untracked files: (use "git add <file>..." to include in what will be committed) submit.py no changes added to commit (use "git add" and/or "git commit -a")
Add the untracked file to the repository by typing:
$ git add submit.py
This lets git know you want to track the submit.py file. Add the modified file as well:
$ git add answers.txt
This lets git know you want it to keep track of the changes you've made to the answers.txt file. Check the status again:
$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: answers.txt new file: submit.py
You can commit this change by doing the following. The text within the quotation marks is a message that is stored along with the commit for future reference.
$ git commit -m "Added the submit.py file to the repository and updated answers.txt."
On your first commit, you may see the following message:
$ git commit -m "Added the submit.py file to the repository and updated answers.txt." *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. ....
This is expected. Follow the instructions to run the two commands and re-commit.
$ git config --global user.email "<your email>" $ git config --global user.name "<your name>" $ git commit -m "Added the submit.py file to the repository and updated answers.txt." [master abdd69f] Added the submit.py file to the repository and updated answers.txt. 2 files changed, 49 insertions(+), 3 deletion(-) create mode 100755 submit.py $ _
The string following "master" may be different as may the number of insertions and deletions. This is okay.
In the ~/lab0/ directory on your virtual machine, type:
$ git checkout -b git/a origin/git/a Branch git/a set up to track remote branch git/a from origin. Switched to a new branch 'git/a' $ ls merge.c
This creates a branch named git/a from the remote branch origin/git/a which is hosted on github.com. It should contain a single file, merge.c. You can compile and run this file by typing:
$ make merge # To compile $ ./merge # To run
Now, we will create another branch called git/b with its own copy of merge.c. Type:
$ git checkout -b git/b origin/git/b # compile and run the new version $ make merge $ ./merge
One of the strengths of git is that it allows multiple users to work from the same repository independently from each other. Eventually, though, all of the work must be merged together into a final product. Usually, git will do this automatically for you; however, there are times when multiple users modify the same place in a file, in which case git cannot know whose work should be used (only a human can manually resolve a "conflict" of this kind). The two branches that you have just created have been set up so that they will cause exactly such a conflict when merging. Both here and throughout the semester, you must be careful: a botched merge is a reliable source of headaches. Type the following into a console:
$ git branch # This will list all local branches git/a * git/b master $ git merge git/a # Merge the current branch with the branch called 'git/a' Auto-merging merge.c CONFLICT (content): Merge conflict in merge.c Automatic merge failed; fix conflicts and then commit the result.
Exercise Find out what the parent version of merge.c does, then resolve the merge conflict so that the merged file behaves the same as the parent version. By 'parent version', we mean the original version of the merge.c file before either developer A or developer B edited it and pushed code to their respective branches. Don't forget to add the modified file and commit the merge when you are done.
Make sure your merged merge.c compiles and runs correctly.
To access the answers.txt file, you'll need to checkout the master branch again.
$ git checkout master
You'll see a notice message that you are ahead of origin/master. Ignore it.
Question 4. What does your merged program print?
$ cat ~/.ssh/id_rsa.pub ssh-rsa ABCAB3N .... ... ... # or if you specified a specific path name $ cat /your/path/here/<keyname>.pub ssh-rsa ABCAB3N .... ... ...Make sure to copy the entire contents of your call to cat.
Question 6. How long did this lab take you (including all of the setup)?
$ cd ~/lab0 $ python submit.py Success! $
Last updated: 2016-04-15 16:24:03 -0400 [validate xhtml]