Package Managers What are they and why we use them.

54
Package Managers What are they and why we use them

Transcript of Package Managers What are they and why we use them.

Page 1: Package Managers What are they and why we use them.

Package ManagersWhat are they and why we use them

Page 2: Package Managers What are they and why we use them.

Thoughts of an adminInstalling software is painfulInstalling a lot of software is

extremely painfulInstalling a lot of software on a

lot of machines is HELL

Page 3: Package Managers What are they and why we use them.

舉例 - LOL天賦、符文道具

Page 4: Package Managers What are they and why we use them.

Before PackagesInstall from sourceTime consumingVarying configuration

Page 5: Package Managers What are they and why we use them.

Improvement 1Copy the binariesSetup scripts?Version?Dependencies?

Page 6: Package Managers What are they and why we use them.

Package - BasicArchiveBinariesSupporting filesSetup script

Page 7: Package Managers What are they and why we use them.

Package – ImprovementVersioning

◦1.0.x◦1.1.x◦…

Upgrades!

Page 8: Package Managers What are they and why we use them.

Package - DependenciesProgram A requires library B to

workIf library C is available, program

A will work better/faster!

Page 9: Package Managers What are they and why we use them.

Example – Call of DutyRequires: DirectXWorks better with: PhysX

Page 10: Package Managers What are they and why we use them.

Package ManagersLow Level

Unpacking packagesRun configuration scriptsDependency checks…

Page 11: Package Managers What are they and why we use them.

Package ManagersHigh Level

Fetch from remote repositoriesSearchInstall additional packages to

meet dependenciesHandle complex upgrades

Page 12: Package Managers What are they and why we use them.

Package RepositoryCollection of packagesMaintained by distributionMultiple versionsIndex

Page 13: Package Managers What are they and why we use them.

Package ManagersRPM Based DEB Based

Low level RPM Dpkg

High level YUM, up2date, … APT

Page 14: Package Managers What are they and why we use them.

DEBIAN DPKG & APTFocus on

Page 15: Package Managers What are they and why we use them.

Types of PackagesBinary PackageMeta PackageVirtual Package

Page 16: Package Managers What are they and why we use them.

Binary PackageNormal packageSource is availableArchitecture

◦Dependent Compiled binary files

◦Independent Scripts Documents Data files

Page 17: Package Managers What are they and why we use them.

Meta PackageDepends on other packages onlyRename

◦git-core -> gitDefault version

◦gcc -> gcc-4.6◦Python -> python2.7

Can be creative!

Page 18: Package Managers What are they and why we use them.

Virtual PackageDoes not really existNames common functionalityOther binary packages “provide”

a virtual packagec-compiler is provided by

◦gcc◦gcc-4.6◦clang

Page 19: Package Managers What are they and why we use them.

Commonly Used Commands

apt-getapt-cacheaptitude

◦Frontend to the first 2 commands

Page 20: Package Managers What are they and why we use them.

Search for a packageapt-cache search ^vim$

Search pattern

State flags

Page 21: Package Managers What are they and why we use them.

Search PatternsPatterns are regular expressionsAptitude supports complex

patterns◦See reference

Search requires guessing◦Just like Googling

Page 22: Package Managers What are they and why we use them.

DifferencesAptitude and apt-cache have

slighty different behavior◦Aptitude looks at package name only◦Apt-cache looks at description as

well

Page 23: Package Managers What are they and why we use them.

State Flags

i Installedc Removedp Purgedv Virtual packageB Broken dependenciesu UnpackedC Half-configuredH Half-installed

Page 24: Package Managers What are they and why we use them.

Try it!You want to install a web server.

What do you look for?What should you actually install?

Page 25: Package Managers What are they and why we use them.

Looking at a packageWeb interface

◦http://packages.debian.orgCLI

◦apt-cache show XXX◦aptitude show XXX

Debian Control FileTry it now!

Page 26: Package Managers What are they and why we use them.
Page 27: Package Managers What are they and why we use them.

Package InfoNameStateVersionPrioritySectionMaintainerArchitectureDependenciesDescription

Page 28: Package Managers What are they and why we use them.

Package Info - Stateinstallednot installedremoved…

Page 29: Package Managers What are they and why we use them.

Package Info - VersionVim: 2:7.3.547-6

2: -> Epoch7.3.547 -> Upstream version-6 -> Debian package revision

Page 30: Package Managers What are they and why we use them.

Package Info - PriorityRequiredImportantStandardOptionalExtra

Page 31: Package Managers What are they and why we use them.

Package Info - Dependencies

DependsRecommendsSuggestsConflictsReplacesBreaksProvidesSyntax:

http://www.debian.org/doc/debian-policy/ch-relationships.html

Page 32: Package Managers What are they and why we use them.

Installing / Removingapt-get install XXXaptitude install XXX

remove/purgehold/unholdupgradedist-upgrade

Page 33: Package Managers What are they and why we use them.

remove vs. purgeRemove keeps config files in

systemPurge = Remove + delete config

files

Page 34: Package Managers What are they and why we use them.

hold/unholdKeep a package at a specific

state/version unless explicitly request otherwise

Page 35: Package Managers What are they and why we use them.

upgrade vs. dist-upgradeupgrade only updates currently

installed packagesdist-upgrade will do anything to

satisfy all new dependencies

Page 36: Package Managers What are they and why we use them.

Try it now!Install a web serverThen remove itSee that config files are still thereThen purge it

Page 37: Package Managers What are they and why we use them.

MAKING A PACKAGE

Page 38: Package Managers What are they and why we use them.

Why?CustomizeSoftware not packaged yet

◦Become a maintainer?Build your own

Page 39: Package Managers What are they and why we use them.

Making your first packageBasic structure

◦package/XXX Files you want to package

◦package/DEBIAN/control Debian control file

◦package/DEBIAN/xxx Package scripts, other control files

dpkg-deb –b package

Page 40: Package Managers What are they and why we use them.

Homework – Build a meta package

Name: nasa-hwShould always install

◦gcc no older than 4.7◦make newer than 3.80

Should not install when◦clang is installed

Maintainer: Your ID <your email>Use your judgment for other fields

◦Read the documents!Submit .deb file

Page 41: Package Managers What are they and why we use them.

Too simple?Debian related source code

◦source/debian/rules◦source/debian/control◦source/debian/changelog◦source/debian/…

Page 42: Package Managers What are they and why we use them.

Guidelines for packagingDebian 新維護人員手冊

◦http://www.debian.org/doc/manuals/maint-guide/

Get other package sources and see how other people do it◦apt-get source XXX

Page 43: Package Managers What are they and why we use them.

Packages for packagingbuild-essentialdpkg-devdebhelperCDBSdh_makelintian

Page 44: Package Managers What are they and why we use them.

build-essentialMeta package that depends on

essential tools for packagingYou need to install additional

tools/libraries◦debhelper, cdbs, …◦lib*-dev

Page 45: Package Managers What are they and why we use them.

dpkg-devBasic tools for package

developmentdpkg-buildpackage

Page 46: Package Managers What are they and why we use them.

DebhelperCollection of commands to assist

packagingWraps complex steps

◦Splitting files between different packages

◦Generating shared library dependencies

◦Generate and sign binary packages◦…

Page 47: Package Managers What are they and why we use them.

CDBSCommon Debian Build SystemClass based systemSupports different build systems

◦make, ant, cmake, …http://www.slideshare.net/peterei

sentraut/the-common-debian-build-system-cdbs

Page 48: Package Managers What are they and why we use them.

dh_makePrepare source code for

packagingAlways uses debhelperSupports CDBS

Page 49: Package Managers What are they and why we use them.

lintianCheck packages for errors

Page 50: Package Managers What are they and why we use them.

Steps to packaginghttp://www.debian.org/doc/manual

s/maint-guide/first.en.html1. Get source code2. Unpack3. dh_make4. Install build dependencies5. Check control file6. Check installation paths7. Build package

◦ dpkg-buildpackage -b

Page 51: Package Managers What are they and why we use them.

HomeworkBuild a package of “Omnitty”

◦http://omnitty.sourceforge.net/You will also need to build a

package for “ROTE”◦http://omnitty.sourceforge.net/

Build it, install it, and try it outSubmit .deb for omnitty

Page 52: Package Managers What are they and why we use them.

TipsPackages you can look at

◦libevent◦screen◦tmux◦make

Page 53: Package Managers What are they and why we use them.

HOMEWORK RECAP

Page 54: Package Managers What are they and why we use them.

nasa-hw meta packageomnitty binary packageLeave your packages on 217

workstation◦Mail the path of your package to

wens_at_csie.orgStart sooner! You need to do

research to finish this assignment.