aboutsummaryrefslogtreecommitdiff
path: root/ares/maketgz
blob: 670109b3516ab75eecd70d5781404a4d6005ffbb (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
#!/usr/bin/env perl

$version = $ARGV[0];

$name="c-ares";

if($version eq "") {
    print "Enter version number!\n";
    exit;
}

if(!-f "ares.h") {
    print "run this script in the ares source root dir\n";
    exit;
}

if(!-f "configure") {
    `autoconf`;
}

@files=`find . -name FILES`;

my @entries;

sub dirpart {
    my ($file)=@_;
    my @p=split("/", $file);
    $p[$#p]=""; # blank the last one
    my $dir=join("/", @p);

    $dir =~ s/^\.\///; # cut off ./ beginnings

    $dir =~ s/\/$//;  # off / trailers

    if(!$dir) {
        $dir = ".";
    }

    return $dir;
}

sub add {
    my ($file)=@_;

    my $dir=dirpart($file);

    open(FILE, "<$file");
    while(<FILE>) {
        if($_ =~ /^ *\#/) {
            next;
        }
        chomp;
        push @entries, "$dir/$_";
    }
    close(FILE);
}

for(@files) {
    chomp;
    add($_);
}

sub mkalldir {
    my ($dir) = @_;

    my @parts = split("/", $dir);

    #print "IN: $dir\n";

    my $sub="";
    for(@parts) {
        #print "PART: $_\n";

        $sub .= "$_";
        if($_ eq "") {
            next;
        }
        mkdir($sub, 0777);
        #print "make $sub\n";
        $sub .= "/";
    }
    
}

for(@entries) {
    my $dir = dirpart("$name-$version/$_");
 #   print "Create $dir\n";
    mkalldir($dir);
 #   print "Copy $_ to $dir\n";
    `cp -p $_ $dir`;
}

# make a tarball
`tar -cf $name-$version.tar $name-$version`;
# gzip the tarball
`gzip -9 $name-$version.tar`;
# remove the dir
`rm -rf $name-$version`;