Package Managers What are they and why we use them

Preview:

Citation preview

Package ManagersWhat 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

舉例 - LOL天賦、符文道具

Before PackagesInstall from sourceTime consumingVarying configuration

Improvement 1Copy the binariesSetup scripts?Version?Dependencies?

Package - BasicArchiveBinariesSupporting filesSetup script

Package – ImprovementVersioning

◦1.0.x◦1.1.x◦…

Upgrades!

Package - DependenciesProgram A requires library B to

workIf library C is available, program

A will work better/faster!

Example – Call of DutyRequires: DirectXWorks better with: PhysX

Package ManagersLow Level

Unpacking packagesRun configuration scriptsDependency checks…

Package ManagersHigh Level

Fetch from remote repositoriesSearchInstall additional packages to

meet dependenciesHandle complex upgrades

Package RepositoryCollection of packagesMaintained by distributionMultiple versionsIndex

Package ManagersRPM Based DEB Based

Low level RPM Dpkg

High level YUM, up2date, … APT

DEBIAN DPKG & APTFocus on

Types of PackagesBinary PackageMeta PackageVirtual Package

Binary PackageNormal packageSource is availableArchitecture

◦Dependent Compiled binary files

◦Independent Scripts Documents Data files

Meta PackageDepends on other packages onlyRename

◦git-core -> gitDefault version

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

Can be creative!

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

a virtual packagec-compiler is provided by

◦gcc◦gcc-4.6◦clang

Commonly Used Commands

apt-getapt-cacheaptitude

◦Frontend to the first 2 commands

Search for a packageapt-cache search ^vim$

Search pattern

State flags

Search PatternsPatterns are regular expressionsAptitude supports complex

patterns◦See reference

Search requires guessing◦Just like Googling

DifferencesAptitude and apt-cache have

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

well

State Flags

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

Try it!You want to install a web server.

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

Looking at a packageWeb interface

◦http://packages.debian.orgCLI

◦apt-cache show XXX◦aptitude show XXX

Debian Control FileTry it now!

Package InfoNameStateVersionPrioritySectionMaintainerArchitectureDependenciesDescription

Package Info - Stateinstallednot installedremoved…

Package Info - VersionVim: 2:7.3.547-6

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

Package Info - PriorityRequiredImportantStandardOptionalExtra

Package Info - Dependencies

DependsRecommendsSuggestsConflictsReplacesBreaksProvidesSyntax:

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

Installing / Removingapt-get install XXXaptitude install XXX

remove/purgehold/unholdupgradedist-upgrade

remove vs. purgeRemove keeps config files in

systemPurge = Remove + delete config

files

hold/unholdKeep a package at a specific

state/version unless explicitly request otherwise

upgrade vs. dist-upgradeupgrade only updates currently

installed packagesdist-upgrade will do anything to

satisfy all new dependencies

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

MAKING A PACKAGE

Why?CustomizeSoftware not packaged yet

◦Become a maintainer?Build your own

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

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

Too simple?Debian related source code

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

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

Packages for packagingbuild-essentialdpkg-devdebhelperCDBSdh_makelintian

build-essentialMeta package that depends on

essential tools for packagingYou need to install additional

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

dpkg-devBasic tools for package

developmentdpkg-buildpackage

DebhelperCollection of commands to assist

packagingWraps complex steps

◦Splitting files between different packages

◦Generating shared library dependencies

◦Generate and sign binary packages◦…

CDBSCommon Debian Build SystemClass based systemSupports different build systems

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

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

dh_makePrepare source code for

packagingAlways uses debhelperSupports CDBS

lintianCheck packages for errors

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

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

TipsPackages you can look at

◦libevent◦screen◦tmux◦make

HOMEWORK RECAP

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.