cs2043 - unix tools & scripting lecture 17 vcs … · cs2043 - unix tools & scripting...

22
CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management Spring 2015 1 Instructor: Nicolas Savva March 2nd, 2015 1 based on slides by Hussam Abu-Libdeh, Bruno Abrahao and David Slater over the years (with additional material from software-carpentry) Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package

Upload: ngokhanh

Post on 14-Aug-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

CS2043 - Unix Tools & ScriptingLecture 17

VCS and Package ManagementSpring 2015 1

Instructor: Nicolas Savva

March 2nd, 2015

1based on slides by Hussam Abu-Libdeh, Bruno Abrahao and David Slater over the years

(with additional material from software-carpentry)

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 2: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Announcements

The final project is coming out later today

Up to 2 slip days for the final project

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 3: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

cal - a calendar (Assignment 3)

ascii calendar

cal [options] [[month] year]

-A 2: display two months after the current month-B 5: display five months after the current month-N : toggle layout-w : show week number-j : Julian days (from start of year)

Example: cal -A 2 -B 1 -Nw May 2015

calendar

Reminder service using a calendar file.man calendar for more info

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 4: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

GNU Make (recap)

http://software-carpentry.org/v4/make/index.html

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 5: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

GNU Make

manage compilation of programs written in languages like C

used to automatically update any set of files that depend onanother set of files

Makefile describes how files depend on each other, and how toupdate out-of-date files

makes use of patterns, rules, and variables to eliminateredundancy

uses macros to control operation

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 6: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems (VCS)

Version control is the lab notebook of the digital world: it’s whatprofessionals use to keep track of what they’ve done and tocollaborate with other people.Every large software development project relies on it, and mostprogrammers use it for their small jobs as well. And it isn’t just forsoftware: books, papers, small data sets, and anything thatchanges over time or needs to be shared can and should be storedin a version control system.

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 7: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Why version control?

Keep revision history

Easy way to share files between machines

More effective collaboration

(Remote) backup

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 8: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems (VCS)

hard (not impossible) to accidentally overlook or overwritesomeone’s changes to files (highlighted by VCS)

no disputes about which copy is the most up to date.It is the master copy

nothing that is committed to version control is lost (means wehave an ”infinite undo” for the committed states of the files)

version control system never overwrites the master copy in therepository

every time someone commits a new version it is saved as anaddition on top of the previous one

possible to go back in time to see exactly who wrote what ona particular day

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 9: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems: flavors

Distributed

GitMercurial (Hg)Bazaar...

client-server

Subversion (SVN)CVS...

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 10: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems: Subversion

Subversion svn : xlient-server VCS model

svn

svn checkout https://myrepo.org/myproj∼/placetoputworkcp/ makes a local working copysvn log : display history of the project (comments, changes anddetails)svn add mynewfile : add a new file to svn version controlsvn commit -m "comment goes here" : commit changesto repositorysvn update : retrieve latest changes from remote repositorysvn diff -r HEAD : compare working copy against HEADrevision from repositorysvn revert myfile.txt : undo uncommitted changes (rollback to HEAD)svn merge -r HEAD:num myfile.txt : where num is therevision we want to roll back to

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 11: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

SVN CMD Summary

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 12: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems: Git

git : distributed VCS model

git

git config --global user.name "Your Name" :configure usernamegit config --global user.email"[email protected]" : configure emailgit init : initialize working dir as repogit clone http://mygiturl.edu : clone a remoterepository

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 13: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems: More Git

git : distributed VCS model

git

git status : show state of working dirgit add myfile1 myfile2 : add files to staging areagit add -A . : add all modified files recursivelygit commit -m "Some message" : commit changes to localrepogit log : view repo commit historygit diff : show difference between current and last saved stategit diff --staged : difference between last saved andstaged thingsgit diff HEAD 42 myfile : compare file to an earlierversion

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 14: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Version Control Systems: Even More Git

git : distributed VCS model

git

git reset --hard HEAD : erase all local changes since lastcommitgit checkout 424242 path/to/file : restore file to astate from a prior revisiongit remote add nickname remotespecurl : add aremote repo to the git repo git remote -v : list associatedremote git reposgit push nickname master : commit local state to masterbranch of remote repogit push -u nickname master : push to remote repo ifmaster does not existgit pull nickname master : get changes from remoterepository

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 15: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Repositories Host projects online

Bitbucket (Mercurial or Git)

Github (Git)

Launchpad (Bazaar)

Google Code (SVN, Mercurial or Git)

Microsoft CodePlex (SVN, Mercurial or Git)

Sourceforge (CVS, SVN, Bazaar, Git or Mercurial)

Cornell Forge (SVN) - http://forge.cornell.edu

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 16: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Further resources (Git)

Git tutorialhttps://www.atlassian.com/git/tutorial

Pro Git bookhttp://git-scm.com/documentation

Git (Interactive) Cheat Sheethttp://ndpsoftware.com/git-cheatsheet.html

Another Cheatsheethttps://www.atlassian.com/dms/wac/images/landing/git/atlassian git cheatsheet.pdfhttps://training.github.com/kit/downloads/github-git-cheat-sheet.pdf

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 17: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Package Management System

Parts of a Linux distribution and most of the addon softwareare installed via the Package Management System

A package contains the files and other instructions to setup apiece of software

Many packages depend on each other

High-level managers download packages, figure outdependencies and deal with groups of packages

Low-level managers unpack individual packages, run scripts,and get the software installed correctly

Two main families exist: dpkg and rpm (low level)

apt-get (Debian), zypper (SUSE), yum (Fedora) at thehigh level

We briefly touch how to install, remove, or search for packagesusing the different families of package management tools.

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 18: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Command Line Interface: Debian/Ubuntu

apt aka Advanced Package Tool(apt-get and apt-cache commands)

Debian:

sudo dpkg -l: list installed packagessudo apt-cache search myprogname: search for apackagesudo apt-get install myprogname: install a packagesudo apt-get upgrade: update installed packagessudo apt-get remove myprogname: remove a packagesudo apt-cache policy myprogname: check packagestatus

Check https://wiki.debian.org/AptCLI for more info

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 19: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Command Line Interface: Fedora CentOS

yum aka Yellowdog Updater Modified (rpm compatible)

Debian:

sudo yum list installed: list installed packagessudo yum search myprogname: search for a packagesudo yum install myprogname: install a packagesudo yum update: update installed packagessudo yum remove myprogname: remove a packagesudo yum info myprogname: check package status

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 20: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Command Line Interface: openSUSE

zypper similar to yum (rpm based)

Debian:

sudo rmp -qa: list installed packagessudo zypper search myprogname: search for a packagesudo zypper install myprogname: install a packagesudo zypper update: update installed packagessudo zypper remove myprogname: remove a packagesudo zypper info myprogname: check package status

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 21: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Command Line Interface: OSX darwin

Check https://guide.macports.org/ and install Xcode andMacPorts

port command

Also check Homebrew (brew) : http://brew.sh/

Darwin:

sudo port installed: list installed packagessudo port search myprogname: search for a packagesudo port install myprogname: install a packagesudo port upgrade: update installed packagessudo port uninstall myprogname: remove a packagesudo port info myprogname: check package status

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management

Page 22: CS2043 - Unix Tools & Scripting Lecture 17 VCS … · CS2043 - Unix Tools & Scripting Lecture 17 ... (with additional material from software-carpentry) ... Unix Tools & Scripting

Next Time

Instructor: Nicolas Savva CS2043 - Unix Tools & Scripting Lecture 17 VCS and Package Management