Linux Package Management ======================== 1. Prerquisite -------------- user / application / hardware source / compiler / binary library ldd ld.so.conf / ld.so.cache ldconfig 2. tarball ---------- make dir: mkdir hw-1.0 cd hw-1.0 write c code: main.c int main() { printit(); } printit.c #include void printit() { printf("Hello, world!\n"); } compile: gcc -c main.c gcc -c printit.c gcc -o hw main.o printit.o run: ./hw write Makefile: CC = gcc hw: main.o printit.o $(CC) -o hw main.o printit.o main.o: main.c $(CC) -c main.c printit.o: printit.c $(CC) -c printit.c run: make ./hw write configure: #!/bin/bash for COMD in gcc make; do which $COMD || { echo ERROR: $COMD found! exit 1 } done for FILE in main.c printit.c; do echo checking $FILE... test -f $FILE || { echo ERROR: $FILE not found! exit 2 } done cat > Makefile <.tgz $ cd hw- $ less README $ ./configure $ make $ su # make install # exit $ hw 3. Redhat Package Management ---------------------------- rpm-build: /usr/src/redhat/ SOURCES (tarball) SPECS (xxxx.spec) RPMS (i386/xxxx.xxxx.i386.rpm) SRPMS (xxxx.xxxx.src.rpm) tarball: hw-1.0-2.tgz hw.spec: Summary: Hello World demo Name: hw Version: 1.0 Release: 2 Copyright: GPL Group: Demo Source: http://www.study-area.org/linux/src/hw-1.0-2.tgz Url: http://www.study-area.org Packager: Netman Vendor: study-area %description hw is a 'hello world' demon program. have fun! %changelog * Wed May 08 2003 netman - first build %prep %setup ./configure %build make %install make install %clean %files %doc README /usr/local/bin/hw build rpm: $ su - # cp hw-1.0-2.tgz /usr/src/redhat/SOURCES # cp hw.spec /usr/src/redhat/SPECS # rpmbuild -ba /usr/src/redhat/SPECS/hw.spec rebuild rpm: # rpmbuild --rebuild hw-1.0-2.src.rpm or: # rpm -ivh hw-1.0-2.src.rpm # rpmbuild -ba /usr/src/redhat/SPECS/hw.spec install rpm: # rpm -ivh /usr/src/redhat/RPMS/i386/hw-1.0-2.i386.rpm -- dependency question -- * why depends? * how dependso? * conflicts * solution - manual - advanced package management - version - --nodeps rpm command: mode / option install (-i) -v, -h, --test, --nodeps, --force upgrade (-U) -v, -h, --test, --nodeps, --force uninstall (-e) --test, --nodeps query (-q) -i, -l, -d, -c, -R, -a -p xxxx.xxxx.i386.rpm -f /path/to/file verify (-V) rpm site: http://rpmfind.net 4. APT ------ build apt server: install apt package: # rpm -ivh apt-0.5.5cnc4.1-fr1.20030325a.0.rh80.4.i386.rpm create directory tree (web based): # mkdir /var/www/html/apt # cd /var/www/html/apt # mkdir -p redhat/8.0/en/os/RPMS # mkdir -p redhat/8.0/en/os/SRPMS # mkdir -p updates/8.0/en/os/RPMS # mkdir -p updates/8.0/en/os/SRPMS # ln -s redhat/8.0/en/os/SRPMS SRPMS.80 # ln -s updates/8.0/en/os/SRPMS SRPMS.updates # cd redhat # ln -s 8.0/en/os/RPMS RPMS.80 # ln -s ../updates/8.0/en/os/RPMS RPMS.updates # cd ../update # ln -s 8.0/en/os/RPMS RPMS.updates copy rpms / srpms: # cd /var/www/html/apt # cp /usr/src/redhat/RPMS/i386/hw-1.0-1.i386.rpm redhat/RPMS.80 # cp /usr/src/redhat/SRPMS/hw-1.0-1.src.rpm SRPMS.80 update basedir: # sh /usr/bin/genbasedir /var/www/html/apt # sh /usr/bin/genbasedir /var/www/html/apt/redhat # sh /usr/bin/genbasedir /var/www/html/apt/updates install apt client install apt package: # rpm -ivh apt-0.5.5cnc4.1-fr1.20030325a.0.rh80.4.i386.rpm modify sources.list: # vi /etc/apt/sources.list # Red Hat Linux 8.0 # rpm http://ayo.freshrpms.net redhat/8.0/i386 os updates freshrpms # rpm-src http://ayo.freshrpms.net redhat/8.0/i386 os updates freshrpms rpm http://192.168.100.50 apt/redhat 80 updates rpm-src http://192.168.100.50 apt/redhat 80 updates run apt: # apt-get update # apt-get check # apt-get install hw # apt-get source hw # rpm -qi hw update server packages: copy rpms / srpms: # cd /var/www/html/apt # cp /usr/src/redhat/RPMS/i386/hw-1.0-2.i386.rpm redhat/RPMS.updates # cp cp /usr/src/redhat/SRPMS/hw-1.0-2.src.rpm SRPMS.updates update basedir: # sh /usr/bin/genbasedir /var/www/html/apt/ # sh /usr/bin/genbasedir /var/www/html/apt/redhat/ # sh /usr/bin/genbasedir /var/www/html/apt/updates upgrade client packages: run apt: # apt-get update # apt-get check # apt-get upgrade # apt-get source hw # rpm -qi hw no server? (source.list): rpm http://apt.au.freshrpms.net/redhat/8.0/en i386 os updates rpm http://redhat.usu.edu/mirrors/apt redhat/8.0/en/i386 os updates 5. Conclusion ------------- * know what, know how, know why * make your own decisions. * up to you! 6. Reference ------------ http://rando.study-area.org/apt_server.html http://www.study-area.org/tips/APT-HOWTO_CLE.txt http://cle.linux.org.tw/~candyz/index.htm http://apt.freshrpms.net