Repository navigation
Expand file tree
/
Copy pathmakeport
More file actions
executable file
·72 lines (58 loc) · 1.4 KB
/
Copy pathmakeport
File metadata and controls
executable file
·72 lines (58 loc) · 1.4 KB
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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $url = shift;
die "Usage: makeport <url>" unless $url;
my $a = process_url( $url );
die Dumper $a;
# get url;
# get comment;
# get version ( if can't extract from url )
# get categories
# get pkgopts
# get wantlib
# get lib_depends
# get configure_style
# build Makefile
# build distinfo
# make build
# drop to patch prompt ( repl with simple cmds for patching files,
# dir changing and viewing of error messages from 'make build'
# cmds:
# patch ( cp file file.orig - open file in $EDITOR )
# exit ( quit )
sub get_input {
my $msg = shift;
print "$msg";
print "\n> ";
my $inp = <>;
return $inp;
}
sub process_url {
my $s = shift;
my @parts = split( '/', $s );
my $r = {};
my $c = 0;
my @homepage;
my @path;
for my $p ( @parts ) {
if( $p =~ m/((\d+\.){1,}\d+)/ ) {
$r->{version} = $1;
$r->{name} = $p;
$r->{name} =~ s/$r->{version}//;
$r->{name} =~ s/(\..*$)//;
$r->{ext} = $1;
$r->{name} =~ s/\.$//;
$r->{name} =~ s/\-$|\_$//;
}
push( @homepage, $p ) if $c < 3;
push( @path, $p ) if ( $c >= 3 && $c < @parts - 1 );
$c++;
}
$r->{version} = get_input( "Can't determine VERSION. Please enter it now:" ) unless $r->{version};
$r->{name} = get_input( "Can't determine NAME. Please enter it now:" ) unless $r->{name};
$r->{homepage} = join( '/', @homepage );
$r->{path} = join( '/', @path );
return $r;
}