Ik heb een scriptje gemaakt dat kijkt wat er geupgrade kan worden en daarna jouw de keus geeft of de packages te selecteren en het upgrade process te starten
mischien kunnen jullie het ook gebruiken.
laat me weten als er iets aan verbeterd kan worden of als je er nog toevoegingen voor weet.
mischien kunnen jullie het ook gebruiken.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
| #!/usr/bin/perl
# Created by FearLess
# Tnx Tomato for the help
$|=1 ;
use strict ;
my $search ;
my $replace ;
my $tmpfl = "/tmp/upgrade.tmp" ;
#Defining Subroutines
#
sub get_info();
sub show_info();
sub selection();
sub clear();
sub filereplace();
sub start();
clear ;
# Let's emerge sync te portage tree
#
print "Synchronize the Portage tree \n" ;
my $updrsync = `emerge rsync` ;
get_info ;
show_info ;
#Here we wil get the info of which packages are ready to be upgraded
#
sub get_info() {
open(TMP,">$tmpfl");
print "Making pretend update of world\n" ;
my @getupdates = `emerge -p -u world` ; ## This is the commando that i will use to see what the upgrades are
my $i = 0 ;
foreach (@getupdates) {
if (/\\[ebuild\s+\\\[32/) {
chomp ;
my @spl = split /]/ ;
my @final = split /\// ;
my @last = split (/\s/,$final[1]) ;
print TMP " $i\t$last[0] (NEW)\n" ;
$i++ ;
}
if (/\\[ebuild\s+\\\[36/) {
chomp ;
my @spl = split /]/ ;
my @final = split /\// ;
my @last = split (/\s/,$final[1]) ;
print TMP " $i\t$last[0] (UPDATE)\n" ;
$i++ ;
}
}
close(TMP);
}
#Here we will print the packges that can be upgraded on the screen
#
sub show_info() {
clear ;
open (TMP2,"<$tmpfl");
foreach(<TMP2>) {
print $_ ;
}
close(TMP2) ;
selection ;
}
#Here you can make you choice of what you want to upgrade
#
sub selection() {
print "Which Packages do you want to Upgrade or type quit to exit or type go to start upgrading the selected programs.\n" ;
my $antwoord = <STDIN> ;
chomp($antwoord);
if ($antwoord eq "go") {
&start ;
exit 1 ;
}
if ($antwoord eq "quit") {
exit 0 ;
}
open(OUT, "$tmpfl");
my @data2 = <OUT>;
my $ster = "x $antwoord" ;
my $gster = " $antwoord" ;
foreach (@data2) {
if (/^$gster/) {
&filereplace("$gster","$ster") ;
}
elsif (/^$ster/) {
&filereplace("$ster","$gster") ;
}
}
close(OUT);
show_info ;
}
#In this part we wil add or remove a X to the tmp file
#
sub filereplace() {
($search,$replace) = @_ ;
open(OUT, "$tmpfl");
my @data = <OUT>;
close(OUT) ;
open(OUT, ">$tmpfl") ;
foreach my $dataline (@data) {
$dataline =~ s/$search/$replace/gi ;
print OUT $dataline ;
}
close(OUT) ;
show_info;
}
#And here we wil start the upgrade :P
#
sub start() {
open(OUT, "$tmpfl") ;
my @data3 = <OUT> ;
close(OUT) ;
my @ARRAY ;
print "Upgrading the folowing packages\n" ;
foreach (@data3) {
if (/^x/) {
my @spl = split(/\s/) ;
print "\t$spl[2]\n" ;
my @spl2 = split(/\./,$spl[2]);
chop($spl2[0]) ;
chop($spl2[0]) ;
my $value = "$spl2[0] ";
$ARRAY[++$#ARRAY] = $value ;
}
}
my $emerge = `emerge -u @ARRAY` ;
print $emerge ;
}
#Here we will clean the screan.
#
sub clear() {
my $clear = `clear` ;
print $clear ;
} |
laat me weten als er iets aan verbeterd kan worden of als je er nog toevoegingen voor weet.
specs : http://specs.tweak.to/7435