wmacpi: Bump to version 1.99r3.
[dockapps.git] / update-dockapps.pl
blob53dde71b92dc990d248135e23af04dff6e6aa546
1 #!/usr/bin/perl
3 # Update http://windowmaker.org/dockapps from git
5 # Copyright 2014 Window Maker Developers Team
6 # <wmaker-dev@lists.windowmaker.org>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # DESCRIPTION
23 # After every commit to the dockapps git repository, run this script to
24 # update dockapps/dockapps.db, the plain text config file that stores all
25 # of the information for the dockapps section of windowmaker.org.
27 # The script uses git to determine the version numbers and tarball download
28 # urls. Everything else is pulled in from dockapps.db.in, which is
29 # manually updated.
31 # The format of each dockapp entry in dockapps.db.in is:
33 # [dockapp name]
34 # image = (file name of image; in double quotes and comma-separated if more
35 # than one image)
36 # description = (description, possibly taken from archive.org copy of
37 # dockapps.windowmaker.org; in double quotes)
38 # url = (use archive.org copy if original homepage no longer exists)
39 # dockapps = (currently unused; id number from dockapps.windowmaker.org)
40 # category = (category from dockapps.windowmaker.org)
42 # After generating a new dockapps.db, submit a patch for the whome git repo
43 # to wmaker-dev@lists.windowmaker.org.
45 use warnings;
46 use strict;
47 use Git::Repository;
48 use POSIX;
50 open DB, "dockapps.db.in" or die $!;
51 my $db = do { local $/; <DB> };
52 close DB;
54 my $r = Git::Repository->new();
55 my @tags = $r->run("tag");
56 my %dockapps;
58 foreach my $tag (@tags) {
59 $tag =~ /([\w\-+.]+)-([\w.]+)/;
60 my $dockapp = $1;
61 my $version = $2;
62 my $ls = $r->run("ls-tree", $tag, $dockapp);
63 #for older tags from before directory renaming
64 if (!$ls) {
65 $ls = $r->run("ls-tree", $tag, $tag);
67 #for wmfemon_1
68 if (!$ls) {
69 $ls = $r->run("ls-tree", $tag, "$dockapp" . "_$version");
71 my $sha1 = (split(/\s/, $ls))[2];
72 $dockapps{$dockapp}{$version} = $sha1;
75 foreach my $dockapp (keys %dockapps) {
76 my $latest_version = (sort keys $dockapps{$dockapp})[-1];
77 if ($r->run("diff", "$dockapp-$latest_version", "HEAD", $dockapp)) {
78 my $commit = $r->run("log", "-1",
79 "--pretty=format:%H", $dockapp);
80 my $date = strftime("%Y%m%d", localtime($r->run("log", "-1",
81 "--pretty=format:%ct", $dockapp)));
82 #throw out dockapps whose last commit was stripping version names from dirs
83 unless ($commit eq "eea379d83350ced6166099ebc8f41ff4e3fa1f42") {
84 my $ls = $r->run("ls-tree", $commit, $dockapp);
85 if (!$ls) {
86 $ls = $r->run("ls-tree", $commit,
87 "$dockapp-$latest_version");
89 my $sha1 = (split(/\s/, $ls))[2];
90 $dockapps{$dockapp}{"$latest_version+$date"} = $sha1;
96 foreach my $dockapp (keys %dockapps) {
97 my $versions = "";
98 foreach my $version (reverse sort keys $dockapps{$dockapp}) {
99 $versions .= "version-$version = " .
100 $dockapps{$dockapp}{$version} . "\n";
102 my $search = quotemeta "[$dockapp]\n";
103 $db =~ s/$search/[$dockapp]\n$versions/;
106 open DB, ">dockapps.db" or die $!;
107 print DB $db;
108 close DB;