Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Last active January 6, 2016 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/1d0913845966b28b6656 to your computer and use it in GitHub Desktop.
Save tuxmartin/1d0913845966b28b6656 to your computer and use it in GitHub Desktop.
Vytvoreni DEB balicku, APT zdroje a jejich zprava

Vytvoreni a prace s APT zdrojem

Typ zdroje

Typ trivial archive ve tvaru deb http://example.org/debian ./ je deprecated, ale nicemu to nevadi.

Dnes se maji spravne pouzivat official archive ve tvaru deb http://example.org/debian unstable main.

Vytvoreni vlastniho zdroje DEB balicku pro APT

Je na to potreba:

sudo -s
apt-get install dpkg-dev
mkdir -p /var/www/deb

je potreba skript na aktualizaci zdroje pri zmene/pridani/smazani deb balicku:

/usr/local/bin/generuj_apt_zdroj :

#!/bin/bash
cd /var/www/deb
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

pridat prava: chmod a+x /usr/local/bin/generuj_apt_zdroj

Pridani zdroje na dalsich PC:

Pokud pristupujeme lokalne, nebo pres web: (doporucuji web)

sudo -s
echo "deb file:/var/www/deb ./" > /etc/apt/sources.list.d/muj-zdroj.list
echo "deb http://janstepan.eu/deb/ ./" > /etc/apt/sources.list.d/muj-zdroj.list

apt-get update

Pridani noveho balicku do zdroje

Nakopirovat ho do /var/www/deb a spustit /usr/local/bin/generuj_apt_zdroj.

Aktualizace pouze jednoho zdroje

Aby to neaktualizovalo jadro a hromadu dalsich veci...

sudo -s
apt-get update -o Dir::Etc::sourcelist="sources.list.d/muj-zdroj.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
apt-get upgrade

Vytvoreni DEB balicku

Pro deb balicek je potreba mit nasledujici strukturu:

tmp
|-- DEBIAN
|   |-- control
|   `-- md5sums
`-- usr
    `-- share
        |-- applications
        |   `-- MujProgram.desktop
        |-- MujProgram
        `-- pixmaps
            `-- MujProgram.png

Pricemz ikonu a zastupce lze samozrejme vynechat.

My pouzijeme jenom /opt, takze struktura bude:

tmp
|-- DEBIAN
|   |-- control
|   `-- md5sums
`-- opt
    `-- angee

V adresari DEBIAN mohou byt shellove skripty, ktere neco vyonaji pri instalci/odnistalaci/... balicku. Viz popis z webu Debianu:

7.6 What is a Debian preinst, postinst, prerm, and postrm script?

These files are executable scripts which are automatically run before or after
a package is installed. Along with a file named control, all of these files are 
part of the "control" section of a Debian archive file.

The individual files are:

   preinst
This script executes before that package will be unpacked from its Debian archive (".deb") file.
Many 'preinst' scripts stop services for packages which are being upgraded until 
their installation or upgrade is completed (following the successful execution of the 'postinst' script).

   postinst
This script typically completes any required configuration of the package foo once foo has 
been unpacked from its Debian archive (".deb") file. Often, 'postinst' scripts ask the user 
for input, and/or warn the user that if he accepts default values, he should remember to go
back and re-configure that package as the situation warrants. Many 'postinst' scripts then 
execute any commands necessary to start or restart a service once a new package has been 
installed or upgraded.

  prerm
This script typically stops any daemons which are associated with a package. It is 
executed before the removal of files associated with the package.

   postrm
This script typically modifies links or other files associated with foo, and/or removes 
files created by the package. (Also see What is a Virtual Package?, Section 7.8.)

je to idealni moznost, jak napriklad zmenit neco v systemu, poslat nejake info na server atd...

Takze samotne generovani balicku

mkdir tmp
cd tmp
mkdir DEBIAN
mkdir -p opt/angee

Pote pridame samotne soubory a upravime, co je treba a spustime generovani kontrolnich souctu. Generovani se musi spustit ve slozce tmp viz vyse:

find * -type f ! -regex '^DEBIAN/.*' -exec md5sum {} \; > DEBIAN/md5sums

V adresari DEBIAN musi byt soubor control. Zde je ukazkovy obsah:

Package: muj_program
Version: 0.01
Section: main
Priority: optional
Recommends: vlc | firefox     (doporucene balicky, roura je oddelovac)
Depends: libc6 (>= 2.2.4-4)   (zavislosti, lze specifikovat verzi)
Architecture: i386    (architektura procesoru, mozno dat "all" (treba pro javu))
Installed-Size: 2717        (velikost složky /opt v kB)
Maintainer: Jmeno Prijmeni <wtf@example.net>
Description: Kratky popis
 Podrobnejsi popis
 .
 Dalsi odstavce podrobneho popisu...

Pote staci balicek sestavit. Vlezeme do slozky tmp a spustime:

sudo -s
chown -hR root:root tmp
dpkg-deb -b tmp muj-program_0.1_i386.deb

balicek potom muzeme nakopirovat do apt zdroje a aktualizovat ho.

Pri instalaci se nehledi na jmeno souboru .deb, ale na nazev balicku v souboru config!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment