View previous topic :: View next topic |
Author |
Message |
danielino n00b

Joined: 13 Feb 2006 Posts: 11
|
Posted: Thu Feb 16, 2006 8:28 pm Post subject: [Tip&tricks] Script per aggiornamento world |
|
|
Salve, ^^
non avevo niente da fare ed ho automatizzato un pò il lavoro dell'emerge -uDp world e emerge -uD world con uno script in BASH e uno script in C
Code: |
[b] emerge.sh [/b]
#!/bin/bash
# Verifica se è necessario un emerge update
UID_ROOT=0
E_UTENTE_ERRATO=65
DIR=`pwd`
LINEE_NEC=5
if [ "$UID" -ne "$UID_ROOT" ]
then
echo; echo "Non 6 root"; echo
exit;
else
echo; echo "procediamo"; echo
fi
cat /dev/null > `$DIR`/linee.emerge.world
cd $DIR
emerge -uDp world > linee.emerge.world
cd $DIR
cat /dev/null > num
./linee linee.emerge.world > num
LINEE_FILE=`cat num`
echo $LINEE_FILE
if [ "$LINEE_FILE" -ne "$LINEE_NEC" ]
then
emerge -uD world
else
echo "non e' necessario fare un emerge update"
fi
exit 0
|
e lo script in C è
Code: |
[b] Linee.c [/b]
/* per compilarlo:
gcc -o linee linee.c
*/
#include <stdio.h>
main(int argc, char **argv)
{
char buf[100];
int linee;
FILE *fp;
if( argc < 2 )
printf("errato numero di parametri\n");
else {
fp = fopen(argv[1], "r");
if(fp!= NULL) {
linee = 0;
for(;;) {
if( fgets(buf,100,fp) == NULL )
break;
linee++;
}
fclose(fp);
printf("%d\n", linee);
}
else
printf("il file %s non esiste\n",argv[1]);
}
}
|
praticamente lo script fa un emerge -uDp world e scrive su un file di testo poi se le linee del file di testo sono + di 5 quindi ci sono pakketti da aggiornare esegue un emerge -uD world se le linee sono inferiori a 5 non esegue l'emerge
(dopo aver eseguito emerge -uD world rifate un emerge -uDp world e vedrete ke non ci sono pakketti da emergiare)
Per fare prima gli scriptini sono su http://r0xr0x.altervista.org/update.tgz
Mi raccomando se non sapete quello che fate non cambiate i parametri degli script (per gli utenti non esperti)
Ciau ^^
Last edited by danielino on Fri Feb 17, 2006 12:19 am; edited 1 time in total |
|
Back to top |
|
 |
Luca89 Advocate


Joined: 27 Apr 2005 Posts: 2107 Location: Agrigento (Italy)
|
Posted: Thu Feb 16, 2006 9:46 pm Post subject: |
|
|
Non ho capito bene a cosa servano questi script, potresti spiegarlo meglio? Inoltre ti consiglio di usare il tag [code] per scrivere una parte di testo che deve essere tratta come codice.
EDIT: ortografia _________________ Running Fast!
Last edited by Luca89 on Fri Feb 17, 2006 5:45 pm; edited 1 time in total |
|
Back to top |
|
 |
makoomba Bodhisattva


Joined: 03 Jun 2004 Posts: 1856
|
Posted: Fri Feb 17, 2006 9:13 am Post subject: |
|
|
Code: | [ $(emerge -uDp world | wc -l) -gt 5 ] && emerge -uD world |
mi sfugge l'utilità della cosa.... _________________ When all else fails, read the instructions. |
|
Back to top |
|
 |
randomaze Bodhisattva


Joined: 21 Oct 2003 Posts: 9985
|
Posted: Fri Feb 17, 2006 10:45 am Post subject: |
|
|
makoomba wrote: | Code: | [ $(emerge -uDp world | wc -l) -gt 5 ] && emerge -uD world |
mi sfugge l'utilità della cosa.... |
Lo ha spiegato:
danielino wrote: | praticamente lo script fa un emerge -uDp world e scrive su un file di testo poi se le linee del file di testo sono + di 5 quindi ci sono pakketti da aggiornare esegue un emerge -uD world se le linee sono inferiori a 5 non esegue l'emerge |
_________________ Ciao da me! |
|
Back to top |
|
 |
makoomba Bodhisattva


Joined: 03 Jun 2004 Posts: 1856
|
Posted: Fri Feb 17, 2006 11:45 am Post subject: |
|
|
....
e non basta un semplice emerge -uD world ?
se ci sono pacchetti da emergere lo fa, altrimenti no.
/me che non capisce _________________ When all else fails, read the instructions. |
|
Back to top |
|
 |
Ic3M4n Advocate


Joined: 02 Nov 2004 Posts: 3489 Location: Bergamo.
|
Posted: Fri Feb 17, 2006 12:35 pm Post subject: |
|
|
si, infatti. tendo comunque a sottolineare che mi sembra uno script abbastanza inutile. nel senso:
volgio vedere cosa vuole emergere portage:
volgio emergere:
voglio unificare i due comandi:
quindi: che cosa mi permetterebbe di automatizzare questo script?
/me che si associa a makoomba ma continua a non capire. |
|
Back to top |
|
 |
RexRocker Apprentice


Joined: 20 Jan 2005 Posts: 227 Location: Conegliano, Treviso
|
Posted: Fri Feb 17, 2006 1:30 pm Post subject: |
|
|
beh la risposta è molto molto semplice:
why not? _________________ Gentoo on AMD64
.::Gentoo Rulez::.
registered Linux user number 390877 |
|
Back to top |
|
 |
Kernel78 Moderator

Joined: 24 Jun 2005 Posts: 3654
|
Posted: Fri Feb 17, 2006 2:42 pm Post subject: |
|
|
RexRocker wrote: | beh la risposta è molto molto semplice:
why not? |
Se volessi complicarmi la vita potrei usare win, se uso gentoo è per la semplicità e per il controllo che ho sul sitema, se devo usare uno script bash e un programmino in c per avere lo stesso risultato di emerge -uD mi pare che ci sia qualcosa di strano ...
@danielino
Non volermene ma temo di associarmi agli altri che continuano a non capire  _________________ Le tre grandi virtù di un programmatore: pigrizia, impazienza e arroganza. (Larry Wall).
Prima di postare un file togli i commenti con Code: | grep -vE '(^[[:space:]]*($|(#|!|;|//)))' |
|
|
Back to top |
|
 |
|