Introduction to Building Open Source Software

(Difference between revisions)
Jump to: navigation, search
Line 27: Line 27:
 
[[File:Sample-terminal.png||GNOME terminal, user in home directory]]
 
[[File:Sample-terminal.png||GNOME terminal, user in home directory]]
  
Now, we need to make sure we have the tools installed that will let us download, build, and install software from source code. These tools are:
+
Now, we need to make sure we have the software installed that will let us download, build, and install new software from source code. These tools are:
  
 
* wget - a command-line tool to download files from the internet
 
* wget - a command-line tool to download files from the internet
* autoconf - a utility that generates "configure" script files
 
* automake - a utility that generates "Makefile" build files
 
 
* libtool - a utility that helps to generate shared library files
 
* libtool - a utility that helps to generate shared library files
 +
* make - a utility that parses Makefiles and starts the build
 
* gcc - the GNU compiler collection
 
* gcc - the GNU compiler collection
 
* tar - a program used to make and unpack archive files
 
* tar - a program used to make and unpack archive files
 +
* sed - a stream text editor utility that curl uses to configure
 +
* grep - a pattern matching utility that curl uses to configure
 +
* zlib - a compression library that curl detects and uses if present
  
 +
Most (if not all) of these items should already be installed on your Linux system, but we'll make sure. In order to install software packages on Linux, you will need to use root privileges. You can either use "su" or "sudo" for this. Sudo is easier, but it requires that your user be configured in /etc/sudoers first. Ask your instructor if this is the case. Su works as long as you know the root password (it will ask you for it).
  
 +
su method:
 +
<nowiki>
 +
      su -c "yum install wget libtool gcc-c++ tar sed grep zlib-devel make -y"
 +
</nowiki>
  
Now that we have these tools installed, we will download the source code (curl) that we're going to be using today. At the command-line of your terminal, run:
+
sudo method:
 +
<nowiki>
 +
        sudo yum install wget libtool gcc-c++ tar sed grep zlib-devel make -y
 +
</nowiki>
 +
 
 +
Now that we have these software tools installed, we will download the source code (curl) that we're going to be using today. At the command-line of your terminal, run:
  
 
  <nowiki>
 
  <nowiki>

Revision as of 20:26, 31 July 2015

Title Introduction to building open source software
Overview In the modern UNIX/Linux/BSD era, the most common way to build and install open source software is with the use of "configure" and "make" tools. This exercise provides an introduction to building

open-source software with those tools.

Prerequisite Knowledge Students should be comfortable with: uncompressing source "tarballs", using the Linux commandline, using "su" (or "sudo") to gain root privileges, installing software packages with the native package manager
Learning Objectives Student should be able to configure, build, and install software using the "configure" and "make" tools.

Background:

https://www.gnu.org/software/make/manual/html_node/Introduction.html
http://airs.com/ian/configure/configure_1.html

Directions:

First, let's get started by opening a terminal window. You should be logged in as your normal (non-root) user. If you are not in your home directory, go there by typing:

        cd ~

On Fedora, in GNOME, it will look something like this:

GNOME terminal, user in home directory

Now, we need to make sure we have the software installed that will let us download, build, and install new software from source code. These tools are:

  • wget - a command-line tool to download files from the internet
  • libtool - a utility that helps to generate shared library files
  • make - a utility that parses Makefiles and starts the build
  • gcc - the GNU compiler collection
  • tar - a program used to make and unpack archive files
  • sed - a stream text editor utility that curl uses to configure
  • grep - a pattern matching utility that curl uses to configure
  • zlib - a compression library that curl detects and uses if present

Most (if not all) of these items should already be installed on your Linux system, but we'll make sure. In order to install software packages on Linux, you will need to use root privileges. You can either use "su" or "sudo" for this. Sudo is easier, but it requires that your user be configured in /etc/sudoers first. Ask your instructor if this is the case. Su works as long as you know the root password (it will ask you for it).

su method:

       su -c "yum install wget libtool gcc-c++ tar sed grep zlib-devel make -y"
 
sudo method:

        sudo yum install wget libtool gcc-c++ tar sed grep zlib-devel make -y
 

Now that we have these software tools installed, we will download the source code (curl) that we're going to be using today. At the command-line of your terminal, run:

        wget http://curl.haxx.se/download/curl-7.43.0.tar.bz2
 

This will download "curl-7.43.0.tar.bz2" into your home directory. Next, unpack this source archive (also called a "tarball") using the tar command:

        tar xvf curl-7.43.0.tar.bz2
 

The options to the tar command are:

  • x - eXtract
  • v - Verbose (show us what is happening)
  • f - File (we're working with a file. tar started life a long time ago writing to tape drives for backups, so we have to tell it we're working on modern files instead)

You should see a lot of files scroll by, and end up with a "curl-7.43.0" directory. Go into that directory:

        cd curl-7.43.0
 

OLD EXAMPLE CODE, NEED TO REMOVE

Run each statement below in a bash terminal. Then answer the questions below (or as you go).

	ls
	touch f1
	ls
	mv f1 f2
	ls
	cp f2 f1
	ls
	rm f2
	ls
	mkdir d1
	mv f1 d1
	ls
	ls d1
	pwd
	cd d1
	pwd
	ls
	cd ..
	pwd
	ls
	rm d1	# fails
	rm -r d1

  1. What does `ls` display?
  2. What does `mv A B` do if `B` ___is not___ a directory?
  3. What does `mv A B` do if `B` is a directory?
  4. What does `cp A B` do if `B` ___is not___ a directory?
  5. What does `rm A` do if `A` is a file?
  6. What does `mkdir A` do?
  7. What does `pwd` display?
  8. What does `ls A` display if `A` is a directory?
  9. What does `cd A` do?
  10. What does `cd ..` do?
  11. What does `..` mean in `cd ..`?
  12. When do you use `rm -r A` instead of `rm A`?


Getting Help

Run each statement below in a bash terminal. Then answer the questions below (or as you go).

	man
	man man		# Press `space` to page down, `b` to go back, `q` to quit.
	man ls
	man cd		# Unexpected result.
	help cd

  1. What does `man` do?
  2. What does `help` do?
  3. Use `man` to confirm answers in previous section.

Deliverables:

  1. Answers and explanations for the license scenarios
  2. A short lightning talk presentation that clearly illustrates a correct and attributed use of CC materials.

Assessment:

Students can be graded on choosing a correct license, understanding how a license affects what can be done with a creative work, and on their ability to put that knowledge into practice.

Criteria Level 1 (fail) Level 2 (pass) Level 3 (good) Level 4 (exceptional)
Choosing a correct CC license 0-2 correct answers 2-4 answers correct, with valid reasoning (or more answers correct, but without valid reasoning) 4-5 answers correct, with valid reasoning All answers correct, with valid reasoning.
Understanding how a license affects what can be done with a creative work 0-1 correct answers 1-2 correct answers 2-3 correct answers All answers correct
Presentation Does not attribute sources at all Lists license but not full attribution Contains proper attributions, but only a few sources. Multiple sources, properly attributed. Talk itself is properly CC licensed

Comments:

What should the instructor know before using this activity?

A basic familiarity with autotools generated configure and Makefiles is very helpful, though, not necessarily required.

Additional Information:

Knowledge Area/Knowledge Unit Software Engineering (SE) / Tools and Environments
Topic Software configuration management and version control
Level of Difficulty Easy
Estimated Time to Completion 30 minutes to 1 hour
Materials/Environment Internet access, computer (or VM) with Linux installed, student has account and root access (sudo is fine). Some commands reference Fedora, but can be converted to other Linux flavors.
Author Tom Callaway
Source
License This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License


Suggestions for the Open Source Project:

What documentation do you provide on how to build your code? Is it current and accurate? Do you discuss the various configuration options and what effect they have on the final build?



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

CC license.png

Personal tools
Namespaces
Variants
Actions
Events
Learning Resources
HFOSS Projects
Evaluation
Navigation
Toolbox