forked from endreszabo/kernels.archzfs.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedb.pl
84 lines (75 loc) · 1.92 KB
/
makedb.pl
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
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
#use Data::Dumper;
my %deps;
my %pkgs;
my %repofiles;
sub repofiles {
my ($base, $pkg, $l, $version) = @_;
$repofiles{$base}{"$pkg-$version-x86_64.pkg.tar"}++;
}
sub urls($$$) {
#and then Arch started to use .zst compression
$pkgs{"https://archive.archlinux.org/packages/$2/$1/$1-$3-x86_64.pkg.tar.zst"}++;
$pkgs{"https://archive.archlinux.org/packages/$2/$1/$1-$3-x86_64.pkg.tar.zst.sig"}++;
#but not for all pacakges, so .xz is still a thing
$pkgs{"https://archive.archlinux.org/packages/$2/$1/$1-$3-x86_64.pkg.tar.xz"}++;
$pkgs{"https://archive.archlinux.org/packages/$2/$1/$1-$3-x86_64.pkg.tar.xz.sig"}++;
}
while(<>) {
if (m/^%BASE%/) {
my $base=<>;
chomp $base;
pkg: while(<>) {
if (m/^%DEPENDS/) {
while(<>) {
chomp;
last if $_ eq "";
if (m/linux.*=/) {
$deps{$base}{$_}++;
}
if (m/((l)inux.*)=(.*)/) {
urls($1,$2,$3);
repofiles($base,$1,$2,$3);
}
}
}
if (m/^%MAKEDEPENDS/) {
while(<>) {
chomp;
last pkg if $_ eq "";
if (m/linux.*=/) {
$deps{$base}{$_}++;
}
if (m/((l)inux.*)=(.*)/) {
urls($1,$2,$3);
repofiles($base,$1,$2,$3);
}
}
}
# last;
}
}
}
open (URLS, '>urls');
foreach my $pkg (sort keys %pkgs) {
printf URLS "$pkg\n";
}
close URLS;
open (SH, '>repo-add.sh');
printf SH "#!/bin/sh\n";
foreach my $pkg (sort keys %repofiles) {
printf SH "mkdir -p -- 'out/$pkg' || true\n";
for my $file (sort keys %{$repofiles{$pkg}}) {
#these have to be put two different files and repo-add will fail if it can't find one
#of course '%s'.* will not work either as it can't process/ignore .sig files
printf SH "repo-add --nocolor 'out/$pkg/$pkg.db.tar.xz' '%s.xz' || true\n", $file;
printf SH "repo-add --nocolor 'out/$pkg/$pkg.db.tar.xz' '%s.zst' || true\n", $file;
}
}
close SH;
#print Dumper \%deps;
#print Dumper \%pkgs;
#print Dumper \%repofiles;