summaryrefslogtreecommitdiffstats
path: root/base/pkg-get/pkg-get-0.4.5-NuTyX-02.patch
blob: 465dafd245447d751db09700fc6ac7056bedbab1 (plain)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
--- pkg-get-0.4.5/scripts/pkg-get.pl	2009-10-17 20:20:51.000000000 +0000
+++ /usr/ports/base/pkg-get/pkg-get	2009-10-17 16:42:23.000000000 +0000
@@ -1,7 +1,9 @@
 #!/usr/bin/env perl
+# -*- coding: utf-8 -*-
 #
 # pkg-get - A binary package management utility for CRUX Linux
 # Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+# Modified by Arnaud Fernandés <ferarduansednan@laposte.net> 2009-10
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -48,6 +50,8 @@
 }
 readconfig();
 
+my $exitcode = 0;		# 2009-10
+
 SWITCH: {
 	if ($command eq "version") { version(); last SWITCH; }
 	if ($command eq "sync") { sync(); last SWITCH; }
@@ -74,10 +78,11 @@
 	if ($command eq "update") { update(@ARGV); last SWITCH; }
 	if ($command eq "sysup") { sysup(); last SWITCH; }
 	if ($command eq "dependent") { dependent(); last SWITCH; }
-	if ($command eq "depinst") { depinst(); last SWITCH; }
+	if ($command eq "depinst") { $exitcode = depinst(); last SWITCH; }	# 2009-10
 	if ($command eq "current") { current(); last SWITCH; }
 }
 
+exit($exitcode);	# 2009-10
 
 ############################################################################
 # Support functions
@@ -104,7 +109,7 @@
 	if (not $givencmd){$givencmd = ""};
 	my @allowed = ("depinst:", "install:", "sysup", "diff", "update:", "depends:", "info:", "sync",
 					"version", "help", "quickdep:", "dependent:", "list", "listinst", "isinst:",
-					"search:", "dsearch:", "lock:", "unlock:", "listlocked", "quickdiff", "printf:", 
+					"search:", "dsearch:", "lock:", "unlock:", "listlocked", "quickdiff", "printf:",
 					"remove:", "readme:", "dup", "path:", "current:");
 
 	foreach my $valid(@allowed) {
@@ -126,7 +131,7 @@
 
 # Parses the configuration file
 sub readconfig {
-	open(CFG, $CFGFILE) 
+	open(CFG, $CFGFILE)
 		or exiterr("could not open $CFGFILE");
 	while (<CFG>) {
 		chomp;
@@ -160,7 +165,7 @@
 	my $release = $p[0];
 	$release =~ s/^.*-//;
 	$release =~ s/\.pkg\.tar\.gz//;
-	if (not $_[2]) {$_[2] = $_[1]}; 
+	if (not $_[2]) {$_[2] = $_[1]};
 	$pkg{'name'} = $name;
 	$pkg{'version'} = $version;
 	$pkg{'release'} = $release;
@@ -214,7 +219,7 @@
 sub getdirectdeps {
 	my $pkgname = $_[0];
 	my $dir = $_[1];
-	open(DEPS, "$dir/PKGDEPS") 
+	open(DEPS, "$dir/PKGDEPS")
 		or exiterr("could not open $dir/PKGDEPS");
 	while (<DEPS>) {
 		chomp;
@@ -236,7 +241,7 @@
 	my $pkgname = $pkg{'name'};
 	my $found = 0;
 	my $finished = 0;
-	open(READ, "$dir/PKGREAD") 
+	open(READ, "$dir/PKGREAD")
 		or exiterr("could not open $dir/PKGREAD");
 	while (<READ>) {
 		if ($finished eq 1) {return;};
@@ -312,12 +317,12 @@
 # Get the list of installed packages
 sub getinstalled {
 	if (%installed) {
-		return; 
+		return;
 	}
 	my $name;
 	my $version;
 	my $sec = 0;
-	open(DB, $PKGDB) 
+	open(DB, $PKGDB)
 		or exiterr("could not open ".$PKGDB);
 	while (<DB>) {
 		chomp;
@@ -447,7 +452,7 @@
 	return %res;
 }
 
-# Get short status for package, ie [i] 
+# Get short status for package, ie [i]
 sub getshortstatus {
 	my %pkg = @_;
 	if ($pkg{'instversion'}) {
@@ -503,9 +508,9 @@
 		$md5 =~ s/\s+.*$//;
 		$md5 =~ chop($md5);
 		if ($md5 ne $pkg{'md5sum'} and not $ignore_md5sum) {
-			print STDERR "=======> ERROR: md5sum mismatch for $pkg{'name'}:\n"; 
-			print STDERR "required : $pkg{'md5sum'}\n"; 
-			print STDERR "found	: $md5\n"; 
+			print STDERR "=======> ERROR: md5sum mismatch for $pkg{'name'}:\n";
+			print STDERR "required : $pkg{'md5sum'}\n";
+			print STDERR "found	: $md5\n";
 			return 0;
 		}
 		return 1;
@@ -518,9 +523,9 @@
 		$md5 =~ s/\s+.*$//;
 		$md5 =~ chop($md5);
 		if ($md5 ne $pkg{'md5sum'} and not $ignore_md5sum) {
-			print STDERR "=======> ERROR: md5sum mismatch for $pkg{'name'}:\n"; 
-			print STDERR "required : $pkg{'md5sum'}\n"; 
-			print STDERR "found	: $md5\n"; 
+			print STDERR "=======> ERROR: md5sum mismatch for $pkg{'name'}:\n";
+			print STDERR "required : $pkg{'md5sum'}\n";
+			print STDERR "found	: $md5\n";
 			return 0;
 		}
 	}
@@ -537,11 +542,11 @@
 	if ($download_only) {return 1};
 	if ($force){$aa = $aa."-f "};
 	if ($root) {$aa = $aa."-r ".$root." "};
-	if ($pkg{'pre_install'} eq "yes" and ($install_scripts or $pre_install)) {dopre(%pkg)};	
+	if ($pkg{'pre_install'} eq "yes" and ($install_scripts or $pre_install)) {dopre(%pkg)};
 	my $fullpath = $pkg{'path'}."/".$pkg{'name'}."#".$pkg{'version'}."-".$pkg{'release'}.".pkg.tar.gz";
 	print "pkg-get: /usr/bin/pkgadd $upgrade$aa$fullpath\n";
 	system ("/usr/bin/pkgadd $upgrade$aa$fullpath") == 0 or return 0;
-	if ($pkg{'post_install'} eq "yes" and ($install_scripts or $post_install)) {dopost(%pkg)};	
+	if ($pkg{'post_install'} eq "yes" and ($install_scripts or $post_install)) {dopost(%pkg)};
 	return 1;
 }
 
@@ -675,7 +680,7 @@
 	}
 	foreach my $key (sort keys %found) {
 		print "$key\n";
-	} 
+	}
 	if (not %found) {print "No matching packages found\n"};
 }
 
@@ -691,7 +696,7 @@
 		while (<REPO>) {
 			chomp;
 			my %pkg = parsepackage($_, $dir, $url, 0);
-			if ((index($pkg{'name'}, $arg) > -1 or index($pkg{'description'}, $arg) > -1) 
+			if ((index($pkg{'name'}, $arg) > -1 or index($pkg{'description'}, $arg) > -1)
 					and not $found{$pkg{'name'}}) {
 				$found{$pkg{'name'}} = 1;
 			}
@@ -700,7 +705,7 @@
 	}
 	foreach my $key (sort keys %found) {
 		print "$key\n";
-	} 
+	}
 	if (not %found) {print "No matching packages found\n";};
 }
 
@@ -722,7 +727,7 @@
 	}
 	foreach my $key (sort keys %found) {
 		print "$key\n";
-	} 
+	}
 }
 
 # Show path for a package ##################################################
@@ -800,7 +805,7 @@
 	getinstalled();
 	foreach my $key (sort keys %installed) {
 		print "$key\n";
-	} 
+	}
 }
 
 # Print if package is installed  ###########################################
@@ -877,7 +882,7 @@
 
 # List locked packages #####################################################
 sub listlocked {
-	open(LCK, $LOCKFILE) 
+	open(LCK, $LOCKFILE)
 		or exit;
 	while (<LCK>) {
 		chomp;
@@ -1021,7 +1026,7 @@
 				print "  $dup\n";
 			}
 		}
-	} 
+	}
 }
 
 # Show list of dependencies for package ####################################
@@ -1057,7 +1062,7 @@
 		my @r = split(/\|/, $repo);
 		my $dir = $r[0];
 		my $url = $r[1];
-		open(DEPS, "$dir/PKGDEPS") 
+		open(DEPS, "$dir/PKGDEPS")
 			or exiterr("could not open $dir/PKGDEPS");
 		while (<DEPS>) {
 			chomp;
@@ -1089,7 +1094,7 @@
 	getinstalled();
 	foreach my $pkgname(@args) {
 		my %pkg = getpackage($pkgname, 1);
-		if (not %pkg) {
+		if (not %pkg ) {
 			push(@failtasks, "not found,$pkgname");
 		} elsif (getshortstatus(%pkg) ne "[ ]") {
 			push(@prevtasks, "$pkgname");
@@ -1152,25 +1157,50 @@
 	}
 }
 
+# 2009-10
 sub depinst {
 	my @toinst; my %seen;
 	$curraction = "installed";
 	my @args = @ARGV; shift(@args);
 	getinstalled();
+
+	#~ Pour chaque paquet dans les arguments
 	foreach my $pkgname(@args) {
+
+		#~ Si déjà installé retourne la valeur 55
+		if($installed{$pkgname}){
+			print "pkg-get : Le paquet $pkgname est déjà installé.\n";
+			return 55;
+		}
+		#~ Si n'est pas dans les dépots, retourne la valeur 56
+		if(not getpackage($pkgname, 1)){
+			print "pkg-get : Le paquet $pkgname n'est pas disponible en binaire.\n";
+			return 56;
+		}
+
+		#~ Recherche des dépendances (tableau associatif @dependencies)
 		getdependencies($pkgname, 0, "");
-	  	foreach my $dep(@dependencies) {
+
+		#~ Pour chaque dépendances
+	  foreach my $dep(@dependencies) {
+
+			#~ Si on ne l'a pas déjà traitée
 			if (not $seen{$dep}) {
+
+				#~ Prends le paquet des dépots
 				my %pkg = getpackage($dep, 1);
 				if (%pkg) {
+					#~ L'ajoute à la liste des paquets à installer
 					if (getshortstatus(%pkg) eq "[ ]"){
 						push(@toinst, $pkg{'name'});
 					}
 				}
+				#~ Marque la dépendance comme déjà traitée
 				$seen{$dep} = 1;
 			}
 		}
 	}
+	#~ Si des paquets sont marqués comme étant à installer, on lance l'installation
 	if (@toinst) {
 		unshift(@toinst, "dummy"); # is shifted later in install sub;
 		install(@toinst);
--- pkg-get-0.4.5/scripts/pkg-get.pl.orig    2009-10-17 20:20:51.000000000 +0000
+++ pkg-get-0.4.5/scripts/pkg-get.pl     2009-10-17 16:42:23.000000000 +0000
@@ -948,7 +948,7 @@
 						printf("%-19s %-19s %-19s\n\n","Package","Installed","Available in the repositories");
 						$gotdiff = 1;
 					}
-					printf("%-19s %-19s %-19s %-19s\n", $pkg{'name'},  $pkg{'instversion'}, $pkg{'version'}."-".$pkg{'release'});
+					printf("%-19s %-19s %-19s\n", $pkg{'name'},  $pkg{'instversion'}, $pkg{'version'}."-".$pkg{'release'});
 				} elsif ($all) { # yeah, it blows, at least avoid to read the locked state twice.
 					if ($gotdiff == 0){
 						print "Differences between installed packages and packages repo:\n\n";