Next Previous Contents

5. Mpalwnontas (patching) ton pyrhna

5.1 Efarmozontas ena mpalwma (patch)

Oi kata tmhmata beltiwseis toy pyrhna dianemontai ws patches ( = mpalwmata). Px, an exete thn ekdosh 1.1.45, kai parei to mati sas oti kapoy yparxei patch46.gz gi' aythn, shmainei oti mporeite na thn anaba8misete se ekdosh 1.1.46, enwnontas to patch. Fysika, mporei prwta na xreiastei na kanete backup toy dentroy twn dirs toy source kwdika (to make clean, kai meta to cd /usr/src; tar zcvf old-tree.tar.gz linux, 8a sas ftajoyn ena sympiesmeno tar arxeio).

Etsi, synexizontas to parapanw paradeigma, as ypo8esoyme oti exete to patch46.gz sto /usr/src. Meta gyriste me cd sto dir /usr/src kai dwste zcat patch46.gz | patch -p0 (h patch -p0 < patch46, an to patch einai asympiesto). 8a deite diafora pragmata na feugoyn me taxuthta (h na argopetane, an o H/Y sas einai toso argos), pragma poy sas leei oti prospa8ei na tsontarei ta kommatia, kai an petyxe h oxi. Synh8ws ayth h drasthriothta ejelissetai toso grhgora, wste na mh mporeite na diabasete ta mhnumata ths, kai den eimaste panta sigoyroi an petyxainei h oxi. Epomenws, mporei na 8elete na balete thn parametro -s sth diadikasia proskollhshs toy patch, h opoia bgazei sthn o8onh mono ta mhnumata la8oys. (Den 8' apokthsete polu synais8hma toy tupoy "gia des, o H/Y moy kanei kati gia n' allajei!", alla mporei kai na sas aresei aytos o tropos.) Gia na breite poia merh ths diadikasias den doulecan swsta, pate sto dir /usr/src/linux kai cajte gia arxeia me katalhjh .rej . Merikes ekdoseis ths patch (palioteres ekdoseis, poy ginane compile me th boh8eia katwteroy filesystem), afhnoyn ta arxeia ayta me katalhjh # . Mporeite na balete thn entolh find na cajei gia xarh sas. Dinontas

    find .  -name '*.rej' -print

bgazei sthn o8onh osa arxeia me katalhjh .rej poy yparxoyn sto trexon dir kai sta subdirs toy.

An ola phgan kala, kante make clean, config, kai dep, opws ta perigracame stis enothtes 3 kai 4.

Yparxoyn kamposes parametroi ths entolhs patch. Opws proanaferame, h patch -s katapnigei ola ta mhnumata, ektos apo ta mhnumata la8wn. An balete ton source kwdika toy pyrhna se kapoio dir diaforetiko apo to /usr/src/linux, h patch -p1 (s' ayto to allo dir) 8a kanei to patch mia xara. Oi ypoloipes parametroi ths patch einai tekmhriwmenes kala sthn antistoixh selida man.

5.2 An kati den paei kala

(Shmeiwsh : Ayth h enothta anaferetai kyriws se palioteroys pyrhnes.)

To pio syxno problhma poy yphrxe, htan opote ena patch allaze ena arxeio me onoma config.in, pragma poy den htan apolyta swsto, epeidh o ka8e xrhsths allazei tis ry8miseis ston diko toy H/Y. Ayto exei pleon ejaleif8ei, alla mporei na to janabreite mprosta sas se palioteres ekdoseis. Gia na to dior8wsete, cajte sto arxeio config.in.rej, na deite ti afhse to patch. Oi allages typika shmeiwnontai me + kai - sthn arxh ka8e grammhs. Diabaste tis grammes poy peristoixizoyn tis grammes twn allagwn, kai 8ymh8eite an dwsate analoga y h n. Twra, dior8wste to config.in, kai allajte ta y se n kai ta n se y, opws xreiazetai. Dwste

    patch -p0 < config.in.rej

kai an leei oti petyxe (dhl. den exei mhnumata apotyxias), tote mporeite na synexisete me ry8miseis kai compilation. To arxeio config.in.rej 8a parameinei ws exei, alla mporeite na to sbhsete.

An synanthsete ki alla problhmata, mporei na exete egkatasthsei ena patch poy den doyleuei. Ean h entolh patch bgalei to mhnyma previously applied patch detected: Assume -R? (anixneuthke prohgoumeno patch, na to antikatasthsw;) pi8anotata pate na balete patch palioterhs ekdoshs apo ton pyrhna sas. An apanthsete y, 8a prospa8hsei na agnohsei ton source kwdika poy exete, kai pi8anotata 8' apotuxei. Synepws, 8a xreiasteite ena oloklhro neo dentro source kwdika (pragma poy, telika, mporei kai na mhn einai kakh idea).

Gia na afairesete ena patch, xrhsimopoieiste thn entolh patch -R epanw sto arxiko patch.

To kalutero poy exete na kanete, otan ta patches apodeiknuontai lan8asmena, einai na janarxisete m' ena ka8aro toy koytiou dentro source kwdika (px apo ena apo ta arxeia linux-x.y.z.tar.gz), kai na janakanete olh th diadikasia.

5.3 Sbhnontas ta .orig arxeia

Meta apo molis liga patches, 8' arxisoyn na sysswreuontai arxeia .orig . Px, ena dentro ekdoshs 1.1.51 poy eixa, teleytaia fora ka8aristhke sthn ekdosh 1.1.48 . Me to poy esbhsa ta .orig arxeia, ejoikonomhsa perissotero apo miso MB. H entolh

    find .  -name '*.orig' -exec rm -f {} ';'

8a frontisei ta pragmata gia sas. Oi ekdoseis ths patch poy bazoyn # anti gia .rej, xrhsimopoioun tilde (perispwmenh) anti gia .orig .

Yparxoyn kaluteroi tropoi gia na sbhsoyme ta arxeia .orig, oi opoioi ejartwntai apo ta GNU xargs. Px :

    find .  -name '*.orig' | xargs rm

h h "arketa asfalhs, alla ligo pio kyriolektikh" me8odos :

    find . -name '*.orig' -print0 | xargs --null rm --

5.4 Alla patches

Yparxoyn ki alla patches (ayta 8a ta apokalw "mh stantar"), ektos ap' osa dianemei o Linus. An dokimasete na ta pros8esete, ta patches toy Linus mporei kai na mh doylecoyn swsta, kai eite 8a prepei na ta janabgalete - na dior8wsete ton source kwdika toy patch - na egkatasthsete ena neo dentro source kwdika, eite na kanete enan syndyasmo olwn twn parapanw. Ayto mporei na einai polu enoxlhtiko, epomenws, an den 8elete n' allajete ton source kwdika (me pi8anothta gia polu apotyxhmeno apotelesma), afaireste ta mh stantar patches prin balete ta toy Linus, h apla egkatasthste ena neo dentro. Tote, mporeite na deite ean ta mh stantar patches doyleuoyn akomh. An oxi, eite exete kollhsei s' enan palio pyrhna, kai paizete me to patch h ton source kwdika prospa8wntas na ta kanete na doylecoyn, h pernate thn wra sas perimenontas (pi8anotata parakalwntas) na bgei mia nea ekdosh toy patch.

Poso syxna yparxoyn patches ektos ths stantar dianomhs; Pi8anotata kapoia stigmh na synanthsete kapoio. Proswpika xrhsimopoiousa to noblink patch stis virtual konsoles moy, epeidh misw toys kersores poy anabosbhnoyn. (To sygkekrimeno patch ananewnetai syxna - toylaxiston ananewnotan kata to parel8on - stis nees ekdoseis toy pyrhna.) Wstoso, me toys perissoteroys neoys drivers syskeywn na exoyn pleon th morfh modules poy fortwnontai, h syxnothta emfanishs twn "mh stantar" patches meiwnetai shmantika.


Next Previous Contents