1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 | use ProjectBuilder::Base;
|
---|
5 | use ProjectBuilder::Distribution;
|
---|
6 | use File::Copy;
|
---|
7 |
|
---|
8 | # This script help transforming a pre-0.9.11 repository into the new format
|
---|
9 | # where the arch subdirectory is now required to host the packages
|
---|
10 | # for rpm based packages
|
---|
11 |
|
---|
12 | # Needs to be launch at the root of the ftp server
|
---|
13 | # Script is idempotent: can be relaunched on itself
|
---|
14 |
|
---|
15 | for my $odir (<*>) {
|
---|
16 | next if (! -d $odir);
|
---|
17 | chdir($odir);
|
---|
18 | for my $over (<*>) {
|
---|
19 | next if (! -d $over);
|
---|
20 | my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init($odir,$over);
|
---|
21 | # Repo only change for rpm packages in 0.9.11
|
---|
22 | next if ($dtype ne "rpm");
|
---|
23 | chdir($over);
|
---|
24 | pb_mkdir_p("i386");
|
---|
25 | pb_mkdir_p("x86_64");
|
---|
26 | for my $p (<*>) {
|
---|
27 | system("rm -rf $p") if (($p eq "headers") || ($p eq "media_info") || ($p eq "repodata"));
|
---|
28 | unlink($p) if (($p eq "hdlist.cz") || ($p eq "synthesis.hdlist.cz"));
|
---|
29 | next if (($p eq "i386") || ($p eq "x86_64"));
|
---|
30 | if ($p =~ /\.i[3456]86\.rpm$/) {
|
---|
31 | print("Move $p to i386\n");
|
---|
32 | move("$p","i386");
|
---|
33 | }
|
---|
34 | if ($p =~ /\.x86_64\.rpm$/) {
|
---|
35 | print("Move $p to x86_64\n");
|
---|
36 | move("$p","x86_64");
|
---|
37 | }
|
---|
38 | if ($p =~ /\.ia64\.rpm$/) {
|
---|
39 | print("Move $p to ia64\n");
|
---|
40 | pb_mkdir_p("ia64");
|
---|
41 | move("$p","ia64");
|
---|
42 | }
|
---|
43 | if (($p =~ /\.src\.rpm$/) || ($p =~ /\.noarch\.rpm$/) || ($p =~ /\.spec$/)) {
|
---|
44 | print("move $p to i386 and x86_64\n");
|
---|
45 | copy("$p","x86_64");
|
---|
46 | move("$p","i386");
|
---|
47 | }
|
---|
48 | if ($p =~ /\.repo$/) {
|
---|
49 | open(SRC,$p);
|
---|
50 | open(I386, "> i386/$p");
|
---|
51 | open(X86_64, "> x86_64/$p");
|
---|
52 | while (<SRC>) {
|
---|
53 | if (/^baseurl=/) {
|
---|
54 | my $ti = $_;
|
---|
55 | my $tx = $_;
|
---|
56 | $ti =~s/$over$/$over\/i386/;
|
---|
57 | print I386 "$ti";
|
---|
58 | $tx =~s/$over$/$over\/x86_64/;
|
---|
59 | print X86_64 "$tx";
|
---|
60 | } else {
|
---|
61 | print I386 "$_";
|
---|
62 | print X86_64 "$_";
|
---|
63 | }
|
---|
64 | }
|
---|
65 | close(I386);
|
---|
66 | close(X86_64);
|
---|
67 | close(SRC);
|
---|
68 | print("adapt $p into i386 and x86_64\n");
|
---|
69 | unlink($p);
|
---|
70 | }
|
---|
71 | if ($p =~ /\.addmedia$/) {
|
---|
72 | open(SRC,$p);
|
---|
73 | open(I386, "> i386/$p");
|
---|
74 | open(X86_64, "> x86_64/$p");
|
---|
75 | while (<SRC>) {
|
---|
76 | my $ti = $_;
|
---|
77 | my $tx = $_;
|
---|
78 | $ti =~s/$over with/$over\/i386 with/;
|
---|
79 | print I386 "$ti";
|
---|
80 | $tx =~s/$over with/$over\/x86_64 with/;
|
---|
81 | print X86_64 "$tx";
|
---|
82 | }
|
---|
83 | close(I386);
|
---|
84 | close(X86_64);
|
---|
85 | close(SRC);
|
---|
86 | print("adapt $p into i386 and x86_64\n");
|
---|
87 | unlink($p);
|
---|
88 | }
|
---|
89 | }
|
---|
90 | system("cd i386 ; yum-arch . ; createrepo .");
|
---|
91 | system("cd ia64 ; yum-arch . ; createrepo .") if (-d "ia64");
|
---|
92 | system("cd x86_64 ; yum-arch . ; createrepo .");
|
---|
93 | system("cd i386 ; genhdlist2 --clean .") if ($dfam eq "md");
|
---|
94 | system("cd x86_64 ; genhdlist2 --clean .") if ($dfam eq "md");
|
---|
95 | chdir("..");
|
---|
96 | }
|
---|
97 | chdir("..");
|
---|
98 | }
|
---|