+ All Categories
Home > Documents > 1 ITEC 400 Software Installation George Vaughan Franklin University.

1 ITEC 400 Software Installation George Vaughan Franklin University.

Date post: 12-Jan-2016
Category:
Upload: lorena-holmes
View: 222 times
Download: 3 times
Share this document with a friend
Popular Tags:
41
1 ITEC 400 Software Installation George Vaughan Franklin University
Transcript
Page 1: 1 ITEC 400 Software Installation George Vaughan Franklin University.

1

ITEC 400Software Installation

George VaughanFranklin University

Page 2: 1 ITEC 400 Software Installation George Vaughan Franklin University.

2

Topics

• Finding an ‘open source’ project

• Installing from a package

• Installing form source code

Page 3: 1 ITEC 400 Software Installation George Vaughan Franklin University.

3

Finding a Project

• Assume you are a manager in a software company.

• You need a method for identifying number of lines of code written by your developers.

• Why not just use ‘wc –l’ to count the lines in each source file?

Page 4: 1 ITEC 400 Software Installation George Vaughan Franklin University.

4

Finding a Project

• If your developers discover that you are using ‘wc –l’ to count lines of code to measure employee performance…

• You will suddenly see programs with the most elaborate comments ever written

• What you need is a tool that can analyze the number of ‘non-commented’ source lines in a file.

Page 5: 1 ITEC 400 Software Installation George Vaughan Franklin University.

5

Finding a Project

• How do you determine the number of ‘non-commented’ source lines (NCSL)?

• Actually NCSL is important for quality control.

• How many NCSL reviewed per hour is acceptable in a code inspection, 100? 200?

• Also, estimated project cost is often correlated with estimated NCSL

Page 6: 1 ITEC 400 Software Installation George Vaughan Franklin University.

6

Finding a Project

• Other metrics of interest are bug density, i.e. bugs per 100 NCSL.

• Notice that we need a way of discerning comments from non-commented lines of source.

• We could write a parser in Perl to parse and ignore comments in say, a Perl script – this is not too hard…

Page 7: 1 ITEC 400 Software Installation George Vaughan Franklin University.

7

Finding a Project

• But a typical project involving a group of developers will also include source code from more than one language…

• A J2EE application may contain source in Java, JSP, Javascript, HTML, XML, possibly some glue code in Perl, C++, AWK, and Shell…

• Now, it would be quite hard to write a Perl script that can parse all these languages…

Page 8: 1 ITEC 400 Software Installation George Vaughan Franklin University.

8

Finding a Project

• As much as we like to write code, we should first see if there is an “open source” project that can meet our needs…

• Google is good but sometimes provides a lot of noise (i.e. pages unrelated to our interests).

• A good source for information on “open source” projects is: http://sourceforge.net/ and http://freshmeat.net

Page 9: 1 ITEC 400 Software Installation George Vaughan Franklin University.

9

Finding a Project

• After researching http://freshmeat.net we find an interesting project: SLOCCount - Default branch

 by David A. Wheeler - Wednesday, January 3rd 2001 22:02 PST Section: Software

About:SLOCCount is a suite of programs for counting physical source lines of code (SLOC) in possibly large software systems. It can count physical SLOC for a wide number of languages. It can take a large set of files and automatically categorize their types using a number of different heuristics, and also comes with analysis tools.

Page 10: 1 ITEC 400 Software Installation George Vaughan Franklin University.

10

Finding a Project• The web page has additional information:

• Homepage:http://www.dwheeler.com/sloccount/Tar/GZ:http://www.dwheeler.com/sloccount/sloccount-2.23.tar.gzChangelog:http://www.dwheeler.com/sloccount/ChangeLogRPM package:http://www.dwheeler.com/sloccount/sloccount-2.23-1.i386.rpm

• Trove categories: [change] [Development Status] 5 - Production/Stable[Environment] Console (Text Based)[Intended Audience] Developers[License] OSI Approved :: GNU General Public License (GPL)[Programming Language] Ada, Assembly, C, C++, Fortran, Java, Lisp, Objective C, Other, Pascal, Perl, PHP, Python, SQL, Tcl, Unix Shell[Topic] Software Development, Software Development :: Quality AssuranceDependencies: [change]No dependencies filed

Page 11: 1 ITEC 400 Software Installation George Vaughan Franklin University.

11

Finding a Project

• If we go to the home page for this tool we see that:– It is protected by GNU Public License (GPL)– Can analyze source in the following languages:

– Ada (.ada, .ads, .adb) Assembly (.s, .S, .asm) awk (.awk) Bourne shell and variants (.sh) C (.c) C++ (.C, .cpp, .cxx, .cc) C shell (.csh)COBOL (.cob, .cbl) as of version 2.10 C# (.cs) as of version 2.11 Expect (.exp) Fortran (.f) Haskell (.hs) as of version 2.11 Java (.java) lex/flex (.l) LISP/Scheme (.el, .scm, .lsp, .jl) Makefile (makefile) - not normally shown. Modula-3 (.m3, .i3) as of version 2.07 Objective-C (.m) Pascal (.p, .pas) Perl (.pl, .pm, .perl) PHP (.php, .php[3456], .inc) as of version 2.05 Python (.py) Ruby (.rb) as of version 2.09 sed (.sed) SQL (.sql) - not normally shown. TCL (.tcl, .tk, .itk) Yacc/Bison (.y)

Page 12: 1 ITEC 400 Software Installation George Vaughan Franklin University.

12

Installing A Project

• We have 2 choices– Install binaries from a package

• easy method• called RPMs in RedHat• checks for dependencies and conflicts with other installed

packages

– Install from source• allows for custom installations• allows for code modifications• optimum compilation for target platform (i.e. not compiled for

lowest common denominator such as a 386)

Page 13: 1 ITEC 400 Software Installation George Vaughan Franklin University.

13

Installing from RPM

• According to the web page on freshmeat, the RPM file for this tool is at:

http://www.dwheeler.com/sloccount/sloccount-2.23-1.i386.rpm

• We will use the ‘rpm’ tool (see man page) to first see if this tool (perhaps an older version) is already installed:

[root@localhost sloccount]# rpm -q sloccount

package sloccount is not installed

Page 14: 1 ITEC 400 Software Installation George Vaughan Franklin University.

14

Installing from RPM

• Before downloading, it is good to create a dedicated directory to hold the RPM file.

• We can create a directory named: sloccount

• We can select this link from our browser to download the RPM file.

• After downloading, we see that file is named: sloccount-2.23-1.i386.rpm

Page 15: 1 ITEC 400 Software Installation George Vaughan Franklin University.

15

Installing from RPM

• Next, we use the ‘rpm’ command to install the tool:

[root@localhost sloccount]# rpm -vUh sloccount-2.23-1.i386.rpmPreparing...

########################################### [100%] 1:sloccount

########################################### [100%]

• Test the installation[root@localhost sloccount]# rpm -q sloccountsloccount-2.23-1

• The correct version is reported…• We will see more thorough testing when

installing from source…

Page 16: 1 ITEC 400 Software Installation George Vaughan Franklin University.

16

Installing From Source

• Let us assume that we may want to customize this tool (with respect to GPL…)

• Therefore, we are interested in the following:– Downloading the source files (as an a compressed tar

file)– Unpack the source files– Building the tool– Testing the tool as root– Installing the tool– Testing as a regular user

Page 17: 1 ITEC 400 Software Installation George Vaughan Franklin University.

17

Downloading the source files

• Usually, the source files are packaged in a a compressed archive file (compressed tar file).

• According to the web page on freshmeat, the package for this tool is at:

http://www.dwheeler.com/sloccount/sloccount-2.23.tar.gz

• Before downloading, it is good to create a dedicated directory to hold the source files.

• We can create a directory named: sloccount• We can select this link from our browser to

download the tar file.

Page 18: 1 ITEC 400 Software Installation George Vaughan Franklin University.

18

Unpacking The Source Files

• After downloading, we see that file is named: sloccount-2.23.tar.gz

• We use the ‘tar’ tool to uncompress and unpack the source files from this tar file:

tar zxvf sloccount-2.23.tar.gz

• See man page for ‘tar’ command

• Un-tarring the file will result in many files and directories being created.

Page 19: 1 ITEC 400 Software Installation George Vaughan Franklin University.

19

Building The Tool

• After unpacking, it is good to:– Read the README file– Take a look at the makefile

• The complete makefile for this tool is at the end of these slides. This lecture will reference the makefile…

Page 20: 1 ITEC 400 Software Installation George Vaughan Franklin University.

20

Building The Tool

• After we study the makefile, we see several targets of interest:– all

• this is the default target• it compiles everything.

– install_programs • this target will install executables in standard

system directory (/usr/local/bin)

– uninstall_programs• remove executables

Page 21: 1 ITEC 400 Software Installation George Vaughan Franklin University.

21

Building The Tool

– install_man• install the man pages

– test• test scripts to test the built product

– clean• remove build by-products

– There are other targets…

Page 22: 1 ITEC 400 Software Installation George Vaughan Franklin University.

22

Building The Tool

• We will use the default target (all) to build the product:

[root@localhost sloccount-2.23]# make

gcc -Wall c_count.c -o c_count

cp -p c_count java_count

gcc -Wall lexcount1.c -o lexcount1

gcc -Wall pascal_count.c -o pascal_count

gcc -Wall php_count.c -o php_count

gcc -Wall jsp_count.c -o jsp_count

gcc -Wall ml_count.c -o ml_count

Page 23: 1 ITEC 400 Software Installation George Vaughan Franklin University.

23

Testing Tool as Root• Test the product using the make target ‘test’

[root@localhost sloccount-2.23]# make testPATH=.:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/

sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin; sloccount testcode

Creating filelist for testcodeCategorizing files.Computing results.

SLOC Directory SLOC-by-Language (Sorted)221 testcode ruby=110,haskell=32,cobol=27, php=22, pascal=10,f90=6, fortran=6,cs=5,ansic=3

Page 24: 1 ITEC 400 Software Installation George Vaughan Franklin University.

24

Testing Tool as Root

• Test output (continued)

Totals grouped by language (dominant language first):ruby: 110 (49.77%)haskell: 32 (14.48%)cobol: 27 (12.22%)php: 22 (9.95%)pascal: 10 (4.52%)f90: 6 (2.71%)fortran: 6 (2.71%)cs: 5 (2.26%)ansic: 3 (1.36%)

Page 25: 1 ITEC 400 Software Installation George Vaughan Franklin University.

25

Testing Tool as Root

• Test output (continued)

Total Physical Source Lines of Code (SLOC) = 221Development Effort Estimate, Person-Years (Person-Months) = 0.04 (0.49) (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))Schedule Estimate, Years (Months) = 0.16 (1.91) (Basic COCOMO model, Months = 2.5 * (person-months**0.38))Estimated Average Number of Developers (Effort/Schedule) = 0.26Total Estimated Cost to Develop = $ 5,537 (average salary = $56,286/year, overhead = 2.40).SLOCCount is Open Source Software/Free Software, licensed under the FSF GPL.Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."[root@localhost sloccount-2.23]#

Page 26: 1 ITEC 400 Software Installation George Vaughan Franklin University.

26

Installing The Tool

• Install product using make target ‘install’[root@localhost sloccount-2.23]# make installinstall ada_count asm_count awk_count break_filelist cobol_count

compute_all compute_sloc_lang count_extensions count_unknown_ext csh_count exp_count fortran_count f90_count generic_count get_sloc get_sloc_details haskell_count lex_count lisp_count make_filelists makefile_count modula3_count objc_count perl_count print_sum python_count ruby_count sed_count sh_count show_filecount sloccount sql_count tcl_count c_count java_count lexcount1 pascal_count php_count jsp_count ml_count /usr/local/bin

install -d /usr/local/share/man/man1install sloccount.1.gz /usr/local/share/man/man1install -d /usr/local/share/doc/sloccount-2.23-1install sloccount.html README TODO ChangeLog

/usr/local/share/doc/sloccount-2.23-1[root@localhost sloccount-2.23]#

Page 27: 1 ITEC 400 Software Installation George Vaughan Franklin University.

27

Testing The Tool As Typical User

• Test as user gvaughan

[gvaughan@localhost itec400]$ lsex0010_4.pl ex0010_4.pl.num ex0020_4.pl ex0020_4.pl.num[gvaughan@localhost itec400]$ sloccountError: You must provide a directory or directories of source code.[gvaughan@localhost itec400]$ cd ..[gvaughan@localhost gvaughan]$ sloccount itec400Creating filelist for itec400Categorizing files.Computing results.

SLOC Directory SLOC-by-Language (Sorted)102 itec400 perl=102

Totals grouped by language (dominant language first):perl: 102 (100.00%)

Page 28: 1 ITEC 400 Software Installation George Vaughan Franklin University.

28

Testing The Tool As Typical User

• Test ‘man’ page:

Page 29: 1 ITEC 400 Software Installation George Vaughan Franklin University.

29

Using Sloc to Measure Gnu/Linux Value

• See article at:http://www.dwheeler.com/sloc/redhat71-v1/

redhat71sloc.html

Page 30: 1 ITEC 400 Software Installation George Vaughan Franklin University.

30

References

• Programming Perl, Larry Wall, et al, 2000• Essential System Administration, Aeleen Frisch, 2002• Linux Administration Handbook, Evi Nemeth, et. al., 2002

Page 31: 1 ITEC 400 Software Installation George Vaughan Franklin University.

31

Appendix: sloccount Makefile0001: # Makefile for SLOCCount.0002: # (C) Copyright David A. Wheeler 2000-2002.0003: # Licensed under the GPL; see sloccount.html for license information.0004: # My thanks to John Clezy, who provided the modifications to this makefile0005: # to make sloccount work on Windows using Cygwin.0006:0007:0008: # You may need to change the following options to install on your machine:0009:0010: # Set this for where to store the man pages and executables.0011: # If you want to store this as part of an official distribution,0012: # change this to "/usr":0013: PREFIX=/usr/local0014:0015: # Set "EXE_SUFFIX" to ".exe" if you're running on Windows, like this:0016: # EXE_SUFFIX=.exe0017: EXE_SUFFIX=0018:0019: # Set this to your C compiler, if it's not "gcc"; a likely alternative is "cc".0020: # The "-Wall" option turns on warnings in gcc. gcc users might also want

Page 32: 1 ITEC 400 Software Installation George Vaughan Franklin University.

32

Appendix: sloccount Makefile0021: # to consider using "-Werror", which turns warnings into errors.0022: CC=gcc -Wall0023:0024: # Set this to the name of your "install" program. On some systems,0025: # "install -C" would be useful (so unchanged files won't be modified),0026: # but not all systems support this install option. "Install" should work0027: # for any Unix-like system as well as for Cygwin.0028: # "INSTALL_A_DIR" is the command to create a directory in the first place.0029: INSTALL=install0030: INSTALL_A_DIR=$(INSTALL) -d0031:0032: # Set this to the name of the program to create RPMs.0033: # This works for Red Hat Linux 8.0:0034: RPMBUILD=rpmbuild -ba0035: # This works for Red Hat Linux 7.X and below:0036: # RPMBUILD=rpm -ba0037:0038:0039: # From here on, nothing should need changing unless you're0040: # changing the code itself.

Page 33: 1 ITEC 400 Software Installation George Vaughan Franklin University.

33

Appendix: sloccount Makefile0041:0042: # To change the version #, change VERSION here, sloccount.spec,0043: # sloccount, and sloccount.html.0044: # Note to self: to redistribute, do this:0045: # make distribute; su; make rpm; (test as desired);0046: # rpm -e sloccount; ^D; make my_install; send to web site.0047:0048:0049: NAME=sloccount0050: VERSION=2.230051: RPM_VERSION=10052: ARCH=i3860053: VERSIONEDNAME=$(NAME)-$(VERSION)0054: INSTALL_DIR=$(PREFIX)/bin0055: MAN_DIR=$(PREFIX)/share/man0056: MAN_DIR_MAN1=$(MAN_DIR)/man10057: DOC_DIR=$(PREFIX)/share/doc/$(VERSIONEDNAME)-$(RPM_VERSION)0058: POSTED_DIR=/home/dwheeler/dwheeler.com/sloccount0059:0060: COMPILED_EXECUTABLES= \

Page 34: 1 ITEC 400 Software Installation George Vaughan Franklin University.

34

Appendix: sloccount Makefile0061: c_count$(EXE_SUFFIX) \0062: java_count$(EXE_SUFFIX) \0063: lexcount1$(EXE_SUFFIX) \0064: pascal_count$(EXE_SUFFIX) \0065: php_count$(EXE_SUFFIX) \0066: jsp_count$(EXE_SUFFIX) \0067: ml_count$(EXE_SUFFIX)0068:0069: EXECUTABLES= \0070: ada_count \0071: asm_count \0072: awk_count \0073: break_filelist \0074: cobol_count \0075: compute_all \0076: compute_sloc_lang \0077: count_extensions \0078: count_unknown_ext \0079: csh_count \0080: exp_count \

0081: fortran_count \0082: f90_count \0083: generic_count \0084: get_sloc \0085: get_sloc_details \0086: haskell_count \0087: lex_count \0088: lisp_count \0089: make_filelists \0090: makefile_count \0091: modula3_count \0092: objc_count \0093: perl_count \0094: print_sum \0095: python_count \0096: ruby_count \0097: sed_count \0098: sh_count \0099: show_filecount \0100: sloccount \

Page 35: 1 ITEC 400 Software Installation George Vaughan Franklin University.

35

Appendix: sloccount Makefile0101: sql_count \0102: tcl_count \0103: $(COMPILED_EXECUTABLES)0104:0105: MANPAGES=sloccount.1.gz0106:0107: MYDOCS=sloccount.html README TODO ChangeLog0108:0109:0110: all: $(COMPILED_EXECUTABLES)0111:0112: lexcount1$(EXE_SUFFIX): lexcount1.c0113: $(CC) lexcount1.c -o lexcount1$(EXE_SUFFIX)0114:0115: c_count$(EXE_SUFFIX): c_count.c0116: $(CC) c_count.c -o c_count$(EXE_SUFFIX)0117:0118: php_count$(EXE_SUFFIX): php_count.c0119: $(CC) php_count.c -o php_count$(EXE_SUFFIX)0120:

Page 36: 1 ITEC 400 Software Installation George Vaughan Franklin University.

36

Appendix: sloccount Makefile0121: pascal_count.c: pascal_count.l driver.c driver.h0122: flex -Cfe -t pascal_count.l > pascal_count.c0123:0124: pascal_count$(EXE_SUFFIX): pascal_count.c0125: $(CC) pascal_count.c -o pascal_count$(EXE_SUFFIX)0126:0127: jsp_count.c: jsp_count.l driver.c driver.h0128: flex -Cfe -t jsp_count.l > jsp_count.c0129:0130: jsp_count$(EXE_SUFFIX): jsp_count.c0131: $(CC) jsp_count.c -o jsp_count$(EXE_SUFFIX)0132:0133: ml_count$(EXE_SUFFIX): ml_count.c0134: $(CC) ml_count.c -o ml_count$(EXE_SUFFIX)0135:0136: sloccount.1.gz: sloccount.10137: gzip -c sloccount.1 > sloccount.1.gz0138:0139: # Currently "java_count" is the same as "c_count":0140: java_count$(EXE_SUFFIX): c_count$(EXE_SUFFIX)

Page 37: 1 ITEC 400 Software Installation George Vaughan Franklin University.

37

Appendix: sloccount Makefile0141: cp -p c_count$(EXE_SUFFIX) java_count$(EXE_SUFFIX)0142:0143: # This is USC's code counter, not built by default:0144: c_lines: C_LINES.C0145: $(CC) C_LINES.C -o c_lines$(EXE_SUFFIX)0146:0147:0148: install_programs: all0149: $(INSTALL) $(EXECUTABLES) $(INSTALL_DIR)0150:0151: uninstall_programs:0152: cd $(INSTALL_DIR) && rm -f $(EXECUTABLES)0153:0154: install_man:0155: $(INSTALL_A_DIR) $(MAN_DIR_MAN1)0156: $(INSTALL) $(MANPAGES) $(MAN_DIR_MAN1)0157:0158: uninstall_man:0159: cd $(MAN_DIR_MAN1) && rm -f $(MANPAGES)0160:

Page 38: 1 ITEC 400 Software Installation George Vaughan Franklin University.

38

Appendix: sloccount Makefile0161: install_docs: install_man0162: $(INSTALL_A_DIR) $(DOC_DIR)0163: $(INSTALL) $(MYDOCS) $(DOC_DIR)0164:0165: uninstall_docs:0166: rm -fr $(DOC_DIR)0167:0168:0169: install: install_programs install_man install_docs0170:0171: uninstall: uninstall_programs uninstall_docs uninstall_man0172:0173:0174: clean:0175: -rm -f $(COMPILED_EXECUTABLES) core sloccount.1.gz0176:0177: phptest: php_count0178: ./php_count *.php0179: ./php_count /usr/share/php/*.php0180: ./php_count /usr/share/php/*/*.php

Page 39: 1 ITEC 400 Software Installation George Vaughan Franklin University.

39

Appendix: sloccount Makefile0181:0182: # "make distribute" creates the tarball.0183:0184:0185: distribute: clean $(MANPAGES)0186: rm -f sloccount-$(VERSION).tgz0187: rm -f sloccount-$(VERSION).tar.gz0188: mkdir 9temp0189: cp -pr [A-Za-z]* 9temp0190: mv 9temp $(VERSIONEDNAME)0191: rm -f $(VERSIONEDNAME)/*.tgz0192: rm -f $(VERSIONEDNAME)/*.tar.gz0193: rm -f $(VERSIONEDNAME)/*.rpm0194: # rm -f $(VERSIONEDNAME)/*.1.gz0195: rm -f $(VERSIONEDNAME)/C_LINES.C0196: rm -f $(VERSIONEDNAME)/java_lines.c0197: rm -f $(VERSIONEDNAME)/c_lines0198: tar -cvf - $(VERSIONEDNAME)/* | \0199: gzip --best > $(VERSIONEDNAME).tar.gz0200: chown --reference=README $(VERSIONEDNAME).tar.gz

Page 40: 1 ITEC 400 Software Installation George Vaughan Franklin University.

40

Appendix: sloccount Makefile0201: chmod a+rX *0202: rm -fr $(VERSIONEDNAME)0203:0204: my_install: distribute0205: chmod a+rX *0206: cp -p sloccount-$(VERSION).tar.gz $(POSTED_DIR)0207: cp -p sloccount.html $(POSTED_DIR)0208: cp -p ChangeLog $(POSTED_DIR)0209: cp -p TODO $(POSTED_DIR)0210: cp -p /usr/src/redhat/RPMS/$(ARCH)/$(VERSIONEDNAME)-$(RPM_VERSION)*.rpm $

(POSTED_DIR)0211: cp -p /usr/src/redhat/SRPMS/$(VERSIONEDNAME)-$(RPM_VERSION)*.src.rpm $

(POSTED_DIR)0212:0213: rpm: distribute0214: cp $(VERSIONEDNAME).tar.gz /usr/src/redhat/SOURCES0215: cp sloccount.spec /usr/src/redhat/SPECS0216: cd /usr/src/redhat/SPECS0217: # Uninstall current sloccount if any; ignore errors if not installed.0218: -rpm -e sloccount0219: $(RPMBUILD) sloccount.spec0220: chmod a+r /usr/src/redhat/RPMS/$(ARCH)/$(VERSIONEDNAME)-$(RPM_VERSION)*.rpm

Page 41: 1 ITEC 400 Software Installation George Vaughan Franklin University.

41

Appendix: sloccount Makefile0221: chmod a+r /usr/src/redhat/SRPMS/$(VERSIONEDNAME)-$(RPM_VERSION)*.src.rpm0222: rpm -ivh /usr/src/redhat/RPMS/$(ARCH)/$(VERSIONEDNAME)-$(RPM_VERSION)*.rpm0223: echo "Use rpm -e $(NAME) to remove the package"0224:0225: test: all0226: PATH=.:${PATH}; sloccount testcode0227:0228:


Recommended