| @@ -1,355 +1,355 @@ | | | @@ -1,355 +1,355 @@ |
1 | #!/usr/bin/env perl | | 1 | #!/usr/bin/env perl |
2 | # | | 2 | # |
3 | # $NetBSD: port2pkg.pl,v 1.22 2014/02/17 10:32:02 wiz Exp $ | | 3 | # $NetBSD: port2pkg.pl,v 1.23 2018/05/18 09:42:33 hauke Exp $ |
4 | # | | 4 | # |
5 | | | 5 | |
6 | use Getopt::Std; | | 6 | use Getopt::Std; |
7 | | | 7 | |
8 | $^W=1; | | 8 | $^W=1; |
9 | use strict; | | 9 | use strict; |
10 | use vars qw($opt_m); | | 10 | use vars qw($opt_m); |
11 | my($maintainer) = "pkgsrc-users\@NetBSD.org"; | | 11 | my($maintainer) = "pkgsrc-users\@NetBSD.org"; |
12 | my($makefile, $master_site_subdir, $extract_cmd); | | 12 | my($makefile, $master_site_subdir, $extract_cmd); |
13 | my($portsdir, $pkgdir); | | 13 | my($portsdir, $pkgdir); |
14 | my($namespace, $portname, $portversion, $distname, | | 14 | my($namespace, $portname, $portversion, $distname, |
15 | $pkgname, $pkgnameprefix, $pkgnamesuffix); | | 15 | $pkgname, $pkgnameprefix, $pkgnamesuffix); |
16 | my(@man, @cat); | | 16 | my(@man, @cat); |
17 | | | 17 | |
18 | &usage_and_exit() if (! &getopts('m:')); | | 18 | &usage_and_exit() if (! &getopts('m:')); |
19 | $|=1; | | 19 | $|=1; |
20 | | | 20 | |
21 | $portsdir = shift; | | 21 | $portsdir = shift; |
22 | $pkgdir = shift; | | 22 | $pkgdir = shift; |
23 | &usage_and_exit() if (! $portsdir || ! $pkgdir); | | 23 | &usage_and_exit() if (! $portsdir || ! $pkgdir); |
24 | | | 24 | |
25 | $maintainer = $opt_m if ($opt_m); | | 25 | $maintainer = $opt_m if ($opt_m); |
26 | die "$portsdir: $!\n" if (! -d "$portsdir"); | | 26 | die "$portsdir: $!\n" if (! -d "$portsdir"); |
27 | if (! -d "$pkgdir") { | | 27 | if (! -d "$pkgdir") { |
28 | if (mkdir($pkgdir, 0755) == 0) { | | 28 | if (mkdir($pkgdir, 0755) == 0) { |
29 | die "$pkgdir: $!\n"; | | 29 | die "$pkgdir: $!\n"; |
30 | } | | 30 | } |
31 | } | | 31 | } |
32 | | | 32 | |
33 | system("${GTAR} cCf $portsdir - .|${GTAR} xCf $pkgdir -"); | | 33 | system("${GTAR} cCf $portsdir - .|${GTAR} xCf $pkgdir -"); |
34 | | | 34 | |
35 | &fix_new_ports(); | | 35 | &fix_new_ports(); |
36 | &read_Makefile(); | | 36 | &read_Makefile(); |
37 | &conv_Makefile(); | | 37 | &conv_Makefile(); |
38 | &conv_PLIST(); | | 38 | &conv_PLIST(); |
39 | &add_NetBSD_ID(); | | 39 | &add_NetBSD_ID(); |
40 | | | 40 | |
41 | system("(cd $pkgdir; pkglint)"); | | 41 | system("(cd $pkgdir; pkglint)"); |
42 | 0; | | 42 | 0; |
43 | | | 43 | |
44 | sub usage_and_exit { | | 44 | sub usage_and_exit { |
45 | print "port2pkg [-m maintainer] portsdir pkgdir\n"; | | 45 | print "port2pkg [-m maintainer] portsdir pkgdir\n"; |
46 | exit; | | 46 | exit; |
47 | } | | 47 | } |
48 | | | 48 | |
49 | sub fix_new_ports { | | 49 | sub fix_new_ports { |
50 | my (@allfiles); | | 50 | my (@allfiles); |
51 | my ($fn, $dn); | | 51 | my ($fn, $dn); |
52 | if (-f "$pkgdir/pkg-comment") { | | 52 | if (-f "$pkgdir/pkg-comment") { |
53 | rename("$pkgdir/pkg-comment", "$pkgdir/COMMENT") || | | 53 | rename("$pkgdir/pkg-comment", "$pkgdir/COMMENT") || |
54 | warn("can't copy $pkgdir/pkg-comment to $pkgdir/COMMENT"); | | 54 | warn("can't copy $pkgdir/pkg-comment to $pkgdir/COMMENT"); |
55 | } | | 55 | } |
56 | rename("$pkgdir/pkg-descr", "$pkgdir/DESCR") || | | 56 | rename("$pkgdir/pkg-descr", "$pkgdir/DESCR") || |
57 | warn("can't copy $pkgdir/pkg-descr to $pkgdir/DESCR"); | | 57 | warn("can't copy $pkgdir/pkg-descr to $pkgdir/DESCR"); |
58 | if (-f "$pkgdir/pkg-message") { | | 58 | if (-f "$pkgdir/pkg-message") { |
59 | rename("$pkgdir/pkg-message", "$pkgdir/MESSAGE") || | | 59 | rename("$pkgdir/pkg-message", "$pkgdir/MESSAGE") || |
60 | warn("can't copy $pkgdir/pkg-message to $pkgdir/MESSAGE"); | | 60 | warn("can't copy $pkgdir/pkg-message to $pkgdir/MESSAGE"); |
61 | } | | 61 | } |
62 | foreach $fn (<$pkgdir/pkg-plist*>) { | | 62 | foreach $fn (<$pkgdir/pkg-plist*>) { |
63 | $dn = $fn; | | 63 | $dn = $fn; |
64 | $dn =~ s|.*pkg-plist|PLIST|; | | 64 | $dn =~ s|.*pkg-plist|PLIST|; |
65 | rename("$fn", "$pkgdir/$dn") || | | 65 | rename("$fn", "$pkgdir/$dn") || |
66 | warn("can't copy $fn to $pkgdir/$dn"); | | 66 | warn("can't copy $fn to $pkgdir/$dn"); |
67 | } | | 67 | } |
68 | unlink <$pkgdir/files/patch*>; | | 68 | unlink <$pkgdir/files/patch*>; |
69 | unlink("$pkgdir/distinfo"); | | 69 | unlink("$pkgdir/distinfo"); |
70 | mkdir("$pkgdir/patches",0777); | | 70 | mkdir("$pkgdir/patches",0777); |
71 | } | | 71 | } |
72 | | | 72 | |
73 | sub read_Makefile { | | 73 | sub read_Makefile { |
74 | open(PORTS, "$portsdir/Makefile") | | 74 | open(PORTS, "$portsdir/Makefile") |
75 | || die "$portsdir/Makefile: $!\n"; | | 75 | || die "$portsdir/Makefile: $!\n"; |
76 | while (<PORTS>) { | | 76 | while (<PORTS>) { |
77 | if (/\\$/) { | | 77 | if (/\\$/) { |
78 | chop; | | 78 | chop; |
79 | chop; | | 79 | chop; |
80 | } | | 80 | } |
81 | $makefile .= $_; | | 81 | $makefile .= $_; |
82 | } | | 82 | } |
83 | close(PORTS); | | 83 | close(PORTS); |
84 | | | 84 | |
85 | my ($extract_before_args, $extract_after_args); | | 85 | my ($extract_before_args, $extract_after_args); |
86 | foreach my $line (split(/\n/, $makefile)) { | | 86 | foreach my $line (split(/\n/, $makefile)) { |
87 | $_ = $line; | | 87 | $_ = $line; |
88 | if (/^PORTNAME\?*=(\s*)(.*)/) { | | 88 | if (/^PORTNAME\?*=(\s*)(.*)/) { |
89 | $namespace = $1; | | 89 | $namespace = $1; |
90 | $portname = $2; | | 90 | $portname = $2; |
91 | } elsif (/^PORTVERSION\?*=\s*(.*)/) { | | 91 | } elsif (/^PORTVERSION\?*=\s*(.*)/) { |
92 | $portversion = $1; | | 92 | $portversion = $1; |
93 | } elsif (/^PKGNAMEPREFIX\?*=\s*(.*)/) { | | 93 | } elsif (/^PKGNAMEPREFIX\?*=\s*(.*)/) { |
94 | $pkgnameprefix = $1; | | 94 | $pkgnameprefix = $1; |
95 | } elsif (/^PKGNAMESUFFIX\?*=\s*(.*)/) { | | 95 | } elsif (/^PKGNAMESUFFIX\?*=\s*(.*)/) { |
96 | $pkgnamesuffix = $1; | | 96 | $pkgnamesuffix = $1; |
97 | } elsif (/^DISTNAME\?*=\s*(.*)/) { | | 97 | } elsif (/^DISTNAME\?*=\s*(.*)/) { |
98 | $distname = $1; | | 98 | $distname = $1; |
99 | } elsif (/^MASTER_SITE_SUBDIR\?*=\s*(.*)/) { | | 99 | } elsif (/^MASTER_SITE_SUBDIR\?*=\s*(.*)/) { |
100 | $master_site_subdir = $1; | | 100 | $master_site_subdir = $1; |
101 | if (!($master_site_subdir =~ /\/$/)) { | | 101 | if (!($master_site_subdir =~ /\/$/)) { |
102 | $master_site_subdir .= "/"; | | 102 | $master_site_subdir .= "/"; |
103 | } | | 103 | } |
104 | } elsif (/^MAN(.)\?*=\s*(.*)/) { | | 104 | } elsif (/^MAN(.)\?*=\s*(.*)/) { |
105 | $man[$1] .= $2; | | 105 | $man[$1] .= $2; |
106 | } elsif (/^CAT(.)\?*=\s*(.*)/) { | | 106 | } elsif (/^CAT(.)\?*=\s*(.*)/) { |
107 | $cat[$1] .= $2; | | 107 | $cat[$1] .= $2; |
108 | } elsif (/^EXTRACT_CMD\?*=\s*(.*)/) { | | 108 | } elsif (/^EXTRACT_CMD\?*=\s*(.*)/) { |
109 | $extract_cmd = $1; | | 109 | $extract_cmd = $1; |
110 | } elsif (/^EXTRACT_BEFORE_ARGS\?*=\s*(.*)/) { | | 110 | } elsif (/^EXTRACT_BEFORE_ARGS\?*=\s*(.*)/) { |
111 | $extract_before_args = $1; | | 111 | $extract_before_args = $1; |
112 | } elsif (/^EXTRACT_AFTER_ARGS\?*=\s*(.*)/) { | | 112 | } elsif (/^EXTRACT_AFTER_ARGS\?*=\s*(.*)/) { |
113 | $extract_after_args = $1; | | 113 | $extract_after_args = $1; |
114 | } | | 114 | } |
115 | } | | 115 | } |
116 | | | 116 | |
117 | if (defined($extract_cmd) && $extract_cmd ne "") { | | 117 | if (defined($extract_cmd) && $extract_cmd ne "") { |
118 | if ($extract_before_args ne "") { | | 118 | if ($extract_before_args ne "") { |
119 | $extract_before_args = " $extract_before_args"; | | 119 | $extract_before_args = " $extract_before_args"; |
120 | } | | 120 | } |
121 | if ($extract_after_args ne "") { | | 121 | if ($extract_after_args ne "") { |
122 | $extract_after_args = " $extract_after_args"; | | 122 | $extract_after_args = " $extract_after_args"; |
123 | } | | 123 | } |
124 | $extract_cmd = "$extract_cmd$extract_before_args" . | | 124 | $extract_cmd = "$extract_cmd$extract_before_args" . |
125 | " \${DOWNLOADED_DISTFILE}$extract_after_args"; | | 125 | " \${DOWNLOADED_DISTFILE}$extract_after_args"; |
126 | } | | 126 | } |
127 | | | 127 | |
128 | if (defined($distname)) { | | 128 | if (defined($distname)) { |
129 | $distname =~ s/\${PORTNAME}/$portname/; | | 129 | $distname =~ s/\$\{PORTNAME}/$portname/; |
130 | $distname =~ s/\${PORTVERSION}/$portversion/; | | 130 | $distname =~ s/\$\{PORTVERSION}/$portversion/; |
131 | | | 131 | |
132 | if ($distname ne "$portname-$portversion") { | | 132 | if ($distname ne "$portname-$portversion") { |
133 | $pkgname = "$portname-$portversion"; | | 133 | $pkgname = "$portname-$portversion"; |
134 | } | | 134 | } |
135 | } else { | | 135 | } else { |
136 | $distname = "$portname-$portversion"; | | 136 | $distname = "$portname-$portversion"; |
137 | } | | 137 | } |
138 | if (defined($pkgnameprefix)) { | | 138 | if (defined($pkgnameprefix)) { |
139 | $pkgname = $distname unless (defined($pkgname)); | | 139 | $pkgname = $distname unless (defined($pkgname)); |
140 | $pkgname = $pkgnameprefix . $pkgname; | | 140 | $pkgname = $pkgnameprefix . $pkgname; |
141 | } | | 141 | } |
142 | if (defined($pkgnamesuffix)) { | | 142 | if (defined($pkgnamesuffix)) { |
143 | $pkgname = $distname unless (defined($pkgname)); | | 143 | $pkgname = $distname unless (defined($pkgname)); |
144 | $pkgname .= $pkgnamesuffix; | | 144 | $pkgname .= $pkgnamesuffix; |
145 | } | | 145 | } |
146 | } | | 146 | } |
147 | | | 147 | |
148 | sub conv_Makefile { | | 148 | sub conv_Makefile { |
149 | open(PORTS, "$portsdir/Makefile") | | 149 | open(PORTS, "$portsdir/Makefile") |
150 | || die "$portsdir/Makefile: $!\n"; | | 150 | || die "$portsdir/Makefile: $!\n"; |
151 | open(PKG, ">$pkgdir/Makefile") | | 151 | open(PKG, ">$pkgdir/Makefile") |
152 | || die "$pkgdir/Makefile: $!\n"; | | 152 | || die "$pkgdir/Makefile: $!\n"; |
153 | | | 153 | |
154 | print PKG "# \$Net" . "BSD\$\n"; | | 154 | print PKG "# \$Net" . "BSD\$\n"; |
155 | | | 155 | |
156 | # header | | 156 | # header |
157 | while (<PORTS>) { | | 157 | while (<PORTS>) { |
158 | last if (! /^\#/); | | 158 | last if (! /^\#/); |
159 | | | 159 | |
160 | print; | | 160 | print; |
161 | } | | 161 | } |
162 | print PKG; | | 162 | print PKG; |
163 | | | 163 | |
164 | # body | | 164 | # body |
165 | my ($nextline, $remove, $master_sites, $noportdocs); | | 165 | my ($nextline, $remove, $master_sites, $noportdocs); |
166 | while (<PORTS>) { | | 166 | while (<PORTS>) { |
167 | if (/\\$/) { | | 167 | if (/\\$/) { |
168 | $nextline++; | | 168 | $nextline++; |
169 | next if ($remove); | | 169 | next if ($remove); |
170 | } else { | | 170 | } else { |
171 | $nextline = 0; | | 171 | $nextline = 0; |
172 | if ($remove) { | | 172 | if ($remove) { |
173 | $remove = 0; | | 173 | $remove = 0; |
174 | next; | | 174 | next; |
175 | } | | 175 | } |
176 | } | | 176 | } |
177 | | | 177 | |
178 | s|^\.include <bsd.port.pre.mk>|.include \"../../mk/bsd.prefs.mk\"|; | | 178 | s|^\.include <bsd.port.pre.mk>|.include \"../../mk/bsd.prefs.mk\"|; |
179 | s|^\.include <bsd.port.mk>|.include \"../../mk/bsd.pkg.mk\"|; | | 179 | s|^\.include <bsd.port.mk>|.include \"../../mk/bsd.pkg.mk\"|; |
180 | s|^FETCH_(DEPENDS)|BUILD_$1|; | | 180 | s|^FETCH_(DEPENDS)|BUILD_$1|; |
181 | s|^LIB_(DEPENDS)|$1|; | | 181 | s|^LIB_(DEPENDS)|$1|; |
182 | s|\$\{PORTNAME\}|\${PKGBASE}|g; | | 182 | s|\$\{PORTNAME\}|\${PKGBASE}|g; |
183 | s|\$\{PORTSDIR\}|../..|g; | | 183 | s|\$\{PORTSDIR\}|../..|g; |
184 | s|PLIST_SUB|PLIST_SUBST|; | | 184 | s|PLIST_SUB|PLIST_SUBST|; |
185 | s|^USE_GMAKE\?*=\s*yes|USE_TOOLS+=\tgmake|; | | 185 | s|^USE_GMAKE\?*=\s*yes|USE_TOOLS+=\tgmake|; |
186 | | | 186 | |
187 | if (defined($master_site_subdir) && | | 187 | if (defined($master_site_subdir) && |
188 | $master_site_subdir ne "" && | | 188 | $master_site_subdir ne "" && |
189 | ($master_sites || /^MASTER_SITES\?*=/)) { | | 189 | ($master_sites || /^MASTER_SITES\?*=/)) { |
190 | s|([^L][^O][^C][^A][^L])\}|$1:=$master_site_subdir}|g; | | 190 | s|([^L][^O][^C][^A][^L])\}|$1:=$master_site_subdir}|g; |
191 | | | 191 | |
192 | if ($nextline) { | | 192 | if ($nextline) { |
193 | $master_sites = 1; | | 193 | $master_sites = 1; |
194 | } else { | | 194 | } else { |
195 | $master_sites = 0; | | 195 | $master_sites = 0; |
196 | } | | 196 | } |
197 | } | | 197 | } |
198 | | | 198 | |
199 | if (/(\/usr\/local)/ || | | 199 | if (/(\/usr\/local)/ || |
200 | /(\/usr\/X11R6)/ || | | 200 | /(\/usr\/X11R6)/ || |
201 | /(ldconfig)/i || | | 201 | /(ldconfig)/i || |
202 | /(MASTERDIR)/ || | | 202 | /(MASTERDIR)/ || |
203 | /(.*cat.*MESSAGE.*)/i) { | | 203 | /(.*cat.*MESSAGE.*)/i) { |
204 | print "WARN: found \"$1\"\n"; | | 204 | print "WARN: found \"$1\"\n"; |
205 | } | | 205 | } |
206 | | | 206 | |
207 | if (/^PORTVERSION/ || | | 207 | if (/^PORTVERSION/ || |
208 | /^PKGNAMEPREFIX/ || | | 208 | /^PKGNAMEPREFIX/ || |
209 | /^PKGNAMESUFFIX/ || | | 209 | /^PKGNAMESUFFIX/ || |
210 | /^DISTNAME/ || | | 210 | /^DISTNAME/ || |
211 | /^MAN(.)\?*=/ || | | 211 | /^MAN(.)\?*=/ || |
212 | /^CAT(.)\?*=/ || | | 212 | /^CAT(.)\?*=/ || |
213 | /^MASTER_SITE_SUBDIR/ || | | 213 | /^MASTER_SITE_SUBDIR/ || |
214 | /^EXTRACT_BEFORE_ARGS/ || | | 214 | /^EXTRACT_BEFORE_ARGS/ || |
215 | /^EXTRACT_AFTER_ARGS/) { | | 215 | /^EXTRACT_AFTER_ARGS/) { |
216 | $remove = 1 if ($nextline); | | 216 | $remove = 1 if ($nextline); |
217 | } elsif (/^PORTNAME/) { | | 217 | } elsif (/^PORTNAME/) { |
218 | print PKG "DISTNAME=$namespace$distname\n"; | | 218 | print PKG "DISTNAME=$namespace$distname\n"; |
219 | print PKG "PKGNAME=$namespace$pkgname\n" if defined($pkgname); | | 219 | print PKG "PKGNAME=$namespace$pkgname\n" if defined($pkgname); |
220 | $remove = 1 if ($nextline); | | 220 | $remove = 1 if ($nextline); |
221 | } elsif (/^(EXTRACT_CMD\?*=)/) { | | 221 | } elsif (/^(EXTRACT_CMD\?*=)/) { |
222 | print PKG "$1\t$extract_cmd\n"; | | 222 | print PKG "$1\t$extract_cmd\n"; |
223 | $remove = 1 if ($nextline); | | 223 | $remove = 1 if ($nextline); |
224 | } elsif (/^(MAINTAINER\?*=)/) { | | 224 | } elsif (/^(MAINTAINER\?*=)/) { |
225 | print PKG "$1\t$maintainer\n"; | | 225 | print PKG "$1\t$maintainer\n"; |
226 | $remove = 1 if ($nextline); | | 226 | $remove = 1 if ($nextline); |
227 | | | 227 | |
228 | open(DESCR, "$pkgdir/DESCR") | | 228 | open(DESCR, "$pkgdir/DESCR") |
229 | || die "$pkgdir/DESCR: $!\n"; | | 229 | || die "$pkgdir/DESCR: $!\n"; |
230 | while (<DESCR>) { | | 230 | while (<DESCR>) { |
231 | chop; | | 231 | chop; |
232 | if (/^WWW:[\s]*(.*)/) { | | 232 | if (/^WWW:[\s]*(.*)/) { |
233 | print PKG "HOMEPAGE=\t$1\n"; | | 233 | print PKG "HOMEPAGE=\t$1\n"; |
234 | } | | 234 | } |
235 | } | | 235 | } |
236 | close(DESCR); | | 236 | close(DESCR); |
237 | if ( -f "$pkgdir/COMMENT") { | | 237 | if ( -f "$pkgdir/COMMENT") { |
238 | open(COMMENT, "$pkgdir/COMMENT") | | 238 | open(COMMENT, "$pkgdir/COMMENT") |
239 | || die "$pkgdir/COMMENT: $!\n"; | | 239 | || die "$pkgdir/COMMENT: $!\n"; |
240 | while (<COMMENT>) { | | 240 | while (<COMMENT>) { |
241 | chomp; | | 241 | chomp; |
242 | print PKG "COMMENT=\t$_\n"; | | 242 | print PKG "COMMENT=\t$_\n"; |
243 | } | | 243 | } |
244 | close(COMMENT); | | 244 | close(COMMENT); |
245 | unlink("$pkgdir/COMMENT"); | | 245 | unlink("$pkgdir/COMMENT"); |
246 | } | | 246 | } |
247 | } elsif ($noportdocs || /^\.if.*NOPORTDOCS/) { | | 247 | } elsif ($noportdocs || /^\.if.*NOPORTDOCS/) { |
248 | if (/^\.if/) { | | 248 | if (/^\.if/) { |
249 | $noportdocs++; | | 249 | $noportdocs++; |
250 | print PKG $_ if ($noportdocs > 2); | | 250 | print PKG $_ if ($noportdocs > 2); |
251 | } elsif (/^\.endif/) { | | 251 | } elsif (/^\.endif/) { |
252 | $noportdocs--; | | 252 | $noportdocs--; |
253 | print PKG $_ if ($noportdocs > 2); | | 253 | print PKG $_ if ($noportdocs > 2); |
254 | } else { | | 254 | } else { |
255 | print PKG $_; | | 255 | print PKG $_; |
256 | } | | 256 | } |
257 | } else { | | 257 | } else { |
258 | print PKG $_; | | 258 | print PKG $_; |
259 | } | | 259 | } |
260 | } | | 260 | } |
261 | | | 261 | |
262 | close(PORTS); | | 262 | close(PORTS); |
263 | close(PKG); | | 263 | close(PKG); |
264 | } | | 264 | } |
265 | | | 265 | |
266 | sub add_manual { | | 266 | sub add_manual { |
267 | my ($FILE, $category) = @_; | | 267 | my ($FILE, $category) = @_; |
268 | | | 268 | |
269 | for (my $i = 1; $i <= 8; $i++) { | | 269 | for (my $i = 1; $i <= 8; $i++) { |
270 | next if (!defined(eval "\$$category\[\$i\]")); | | 270 | next if (!defined(eval "\$$category\[\$i\]")); |
271 | foreach my $item (sort(split(/[ \t\n]+/, | | 271 | foreach my $item (sort(split(/[ \t\n]+/, |
272 | eval "\$$category\[\$i\]"))) { | | 272 | eval "\$$category\[\$i\]"))) { |
273 | print $FILE "$category/$category$i/$item\n"; | | 273 | print $FILE "$category/$category$i/$item\n"; |
274 | } | | 274 | } |
275 | } | | 275 | } |
276 | } | | 276 | } |
277 | | | 277 | |
278 | sub conv_PLIST { | | 278 | sub conv_PLIST { |
279 | my ($file, $plist); | | 279 | my ($file, $plist); |
280 | return 0 if (!opendir(PKGDIR, "$pkgdir")); | | 280 | return 0 if (!opendir(PKGDIR, "$pkgdir")); |
281 | while ($plist = readdir(PKGDIR)) { | | 281 | while ($plist = readdir(PKGDIR)) { |
282 | next if (!($plist =~ /^PLIST/)); | | 282 | next if (!($plist =~ /^PLIST/)); |
283 | | | 283 | |
284 | open(OLDPLIST, "$pkgdir/$plist") | | 284 | open(OLDPLIST, "$pkgdir/$plist") |
285 | || die "$pkgdir/$plist: $!\n"; | | 285 | || die "$pkgdir/$plist: $!\n"; |
286 | open(NEWPLIST, ">$pkgdir/new.$plist") | | 286 | open(NEWPLIST, ">$pkgdir/new.$plist") |
287 | || die "$pkgdir/new.$plist: $!\n"; | | 287 | || die "$pkgdir/new.$plist: $!\n"; |
288 | | | 288 | |
289 | print NEWPLIST "\@comment \$"."NetBSD\$\n"; | | 289 | print NEWPLIST "\@comment \$"."NetBSD\$\n"; |
290 | my ($cat_added, $man_added); | | 290 | my ($cat_added, $man_added); |
291 | while (<OLDPLIST>) { | | 291 | while (<OLDPLIST>) { |
292 | s|\%\%([^\%]+)\%\%|\${$1}|g; | | 292 | s|\%\%([^\%]+)\%\%|\${$1}|g; |
293 | next if (/^\@.*ldconfig/); | | 293 | next if (/^\@.*ldconfig/); |
294 | if (defined($cat_added) && $cat_added == 0 && /^[d-z]/){ | | 294 | if (defined($cat_added) && $cat_added == 0 && /^[d-z]/){ |
295 | &add_manual(*NEWPLIST, "cat"); | | 295 | &add_manual(*NEWPLIST, "cat"); |
296 | $cat_added++; | | 296 | $cat_added++; |
297 | } | | 297 | } |
298 | if (defined($man_added) && $man_added == 0 && /^[n-z]/){ | | 298 | if (defined($man_added) && $man_added == 0 && /^[n-z]/){ |
299 | &add_manual(*NEWPLIST, "man"); | | 299 | &add_manual(*NEWPLIST, "man"); |
300 | $man_added++; | | 300 | $man_added++; |
301 | } | | 301 | } |
302 | | | 302 | |
303 | print NEWPLIST $_; | | 303 | print NEWPLIST $_; |
304 | } | | 304 | } |
305 | if (defined($cat_added) && $cat_added == 0) | | 305 | if (defined($cat_added) && $cat_added == 0) |
306 | {&add_manual(*NEWPLIST, "cat");} | | 306 | {&add_manual(*NEWPLIST, "cat");} |
307 | if (defined($man_added) && $man_added == 0) | | 307 | if (defined($man_added) && $man_added == 0) |
308 | {&add_manual(*NEWPLIST, "man");} | | 308 | {&add_manual(*NEWPLIST, "man");} |
309 | | | 309 | |
310 | close(NEWPLIST); | | 310 | close(NEWPLIST); |
311 | close(OLDPLIST); | | 311 | close(OLDPLIST); |
312 | rename("$pkgdir/new.$plist", "$pkgdir/$plist"); | | 312 | rename("$pkgdir/new.$plist", "$pkgdir/$plist"); |
313 | } | | 313 | } |
314 | closedir(PKGDIR); | | 314 | closedir(PKGDIR); |
315 | } | | 315 | } |
316 | | | 316 | |
317 | sub add_NetBSD_ID { | | 317 | sub add_NetBSD_ID { |
318 | my ($patch); | | 318 | my ($patch); |
319 | if (open(MD5, "$portsdir/files/md5") | | 319 | if (open(MD5, "$portsdir/files/md5") |
320 | || open(MD5, "$portsdir/distinfo")) { | | 320 | || open(MD5, "$portsdir/distinfo")) { |
321 | open(NMD5, ">$pkgdir/distinfo") | | 321 | open(NMD5, ">$pkgdir/distinfo") |
322 | || die "$pkgdir/distinfo: $!\n"; | | 322 | || die "$pkgdir/distinfo: $!\n"; |
323 | print NMD5 "\$"."NetBSD\$\n\n"; | | 323 | print NMD5 "\$"."NetBSD\$\n\n"; |
324 | while (<MD5>) { | | 324 | while (<MD5>) { |
325 | print NMD5 $_; | | 325 | print NMD5 $_; |
326 | } | | 326 | } |
327 | close(NMD5); | | 327 | close(NMD5); |
328 | close(MD5); | | 328 | close(MD5); |
329 | } | | 329 | } |
330 | | | 330 | |
331 | opendir(PATCHDIR, "$portsdir/patches") || | | 331 | opendir(PATCHDIR, "$portsdir/patches") || |
332 | opendir(PATCHDIR, "$portsdir/files") || | | 332 | opendir(PATCHDIR, "$portsdir/files") || |
333 | return 0; | | 333 | return 0; |
334 | while ($patch = readdir(PATCHDIR)) { | | 334 | while ($patch = readdir(PATCHDIR)) { |
335 | if ($patch eq "\." || $patch eq "\.." | | 335 | if ($patch eq "\." || $patch eq "\.." |
336 | || $patch eq "CVS") {next;} | | 336 | || $patch eq "CVS") {next;} |
337 | if (open(PATCH, "$portsdir/patches/$patch") | | 337 | if (open(PATCH, "$portsdir/patches/$patch") |
338 | || open(PATCH, "$portsdir/files/$patch")) { | | 338 | || open(PATCH, "$portsdir/files/$patch")) { |
339 | open(NPATCH, ">$pkgdir/patches/$patch") | | 339 | open(NPATCH, ">$pkgdir/patches/$patch") |
340 | || die "$pkgdir/patches/$patch: $!\n"; | | 340 | || die "$pkgdir/patches/$patch: $!\n"; |
341 | print NPATCH "\$"."NetBSD\$\n\n"; | | 341 | print NPATCH "\$"."NetBSD\$\n\n"; |
342 | while (<PATCH>) { | | 342 | while (<PATCH>) { |
343 | if (/(FreeBSD)/i || | | 343 | if (/(FreeBSD)/i || |
344 | /(#!.*perl)/) { | | 344 | /(#!.*perl)/) { |
345 | print "WARN: $pkgdir/patches/" . | | 345 | print "WARN: $pkgdir/patches/" . |
346 | "$patch includes \"$1\".\n"; | | 346 | "$patch includes \"$1\".\n"; |
347 | } | | 347 | } |
348 | print NPATCH $_; | | 348 | print NPATCH $_; |
349 | } | | 349 | } |
350 | close(NPATCH); | | 350 | close(NPATCH); |
351 | close(PATCH); | | 351 | close(PATCH); |
352 | } | | 352 | } |
353 | } | | 353 | } |
354 | closedir(PATCHDIR); | | 354 | closedir(PATCHDIR); |
355 | } | | 355 | } |