From b0483c09d50e673ec761c0518d285d3f9df250ee Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ospite@studenti.unina.it>
Date: Mon, 19 Sep 2011 11:14:49 +0200
Subject: [PATCH] Initial import

---
 .gitignore                     |   2 +
 README                         |  20 +++++++
 pkgs/7-zip.json                |   6 +++
 pkgs/CDBurnerXP.json           |   6 +++
 pkgs/evince.json               |   6 +++
 pkgs/gimp.json                 |   6 +++
 pkgs/inkscape.json             |   6 +++
 pkgs/libreoffice.json          |   6 +++
 pkgs/libreoffice_helppack.json |   6 +++
 pkgs/mozilla_firefox.json      |   6 +++
 pkgs/mozilla_thunderbird.json  |   6 +++
 pkgs/pidgin.json               |   6 +++
 pkgs/vlc.json                  |   6 +++
 pkgs/xp-antispy.json           |   6 +++
 template.json                  |  10 ++++
 winfreed.1.asciidoc            |  58 ++++++++++++++++++++
 winfreed.py                    | 117 +++++++++++++++++++++++++++++++++++++++++
 17 files changed, 279 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 README
 create mode 100644 pkgs/7-zip.json
 create mode 100644 pkgs/CDBurnerXP.json
 create mode 100644 pkgs/evince.json
 create mode 100644 pkgs/gimp.json
 create mode 100644 pkgs/inkscape.json
 create mode 100644 pkgs/libreoffice.json
 create mode 100644 pkgs/libreoffice_helppack.json
 create mode 100644 pkgs/mozilla_firefox.json
 create mode 100644 pkgs/mozilla_thunderbird.json
 create mode 100644 pkgs/pidgin.json
 create mode 100644 pkgs/vlc.json
 create mode 100644 pkgs/xp-antispy.json
 create mode 100644 template.json
 create mode 100644 winfreed.1.asciidoc
 create mode 100755 winfreed.py

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d7e631e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+pkgs/nonfree_*.json
+downloads
diff --git a/README b/README
new file mode 100644
index 0000000..98289fd
--- /dev/null
+++ b/README
@@ -0,0 +1,20 @@
+winfreed - download a selection of Free Software for MS Windows.
+
+When installing a MS Windows OS I always end up downloading a lot of Free
+Software to make the system actually useful, and sometimes even to replace the
+proprietary ones (e.g. VLC beats WMP a million times in my use case).
+
+winfreed makes this process less painful, offering a selection of Free
+Software you can install on MS Windows.
+
+To add a new package copy template.json to pkgs/<progam>.json and change the
+content.
+
+Proprietary software could be necessary on some systems, and I suggest to add
+using packages with names like "pkgs/nonfree_<command>.json", anyway I am not
+going to distribute or publicize those, so don't bother proposing nonfree
+packages.
+
+Take care,
+  Antonio Ospite
+  http://ao2.it
diff --git a/pkgs/7-zip.json b/pkgs/7-zip.json
new file mode 100644
index 0000000..19c09cf
--- /dev/null
+++ b/pkgs/7-zip.json
@@ -0,0 +1,6 @@
+{
+  "name":        "7-Zip",
+  "homepage":    "http://www.7-zip.org/",
+  "description": "7-Zip is a file archiver with a high compression ratio.",
+  "URL":         "http://downloads.sourceforge.net/sevenzip/7z920.exe"
+}
diff --git a/pkgs/CDBurnerXP.json b/pkgs/CDBurnerXP.json
new file mode 100644
index 0000000..f958215
--- /dev/null
+++ b/pkgs/CDBurnerXP.json
@@ -0,0 +1,6 @@
+{
+  "name":        "CDBurnerXP",
+  "homepage":    "http://cdburnerxp.se/",
+  "description": "CDBurnerXP is a free application to burn CDs and DVDs, including Blu-Ray and HD-DVDs.",
+  "URL":         "http://download.cdburnerxp.se/msi/cdbxp_setup_4.3.8.2631.msi"
+}
diff --git a/pkgs/evince.json b/pkgs/evince.json
new file mode 100644
index 0000000..69b8d05
--- /dev/null
+++ b/pkgs/evince.json
@@ -0,0 +1,6 @@
+{
+  "name":        "Evince",
+  "homepage":    "http://projects.gnome.org/evince/",
+  "description": "Evince is a document viewer for multiple document formats.",
+  "URL":         "http://ftp.gnome.org/pub/GNOME/binaries/win32/evince/2.32/evince-2.32.0-144.1.msi"
+}
diff --git a/pkgs/gimp.json b/pkgs/gimp.json
new file mode 100644
index 0000000..ec26175
--- /dev/null
+++ b/pkgs/gimp.json
@@ -0,0 +1,6 @@
+{
+  "name":        "GIMP",
+  "homepage":    "http://www.gimp.org/",
+  "description": "GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring.",
+  "URL":         "http://downloads.sourceforge.net/gimp-win/gimp-2.6.11-i686-setup-1.exe?use_mirror="
+}
diff --git a/pkgs/inkscape.json b/pkgs/inkscape.json
new file mode 100644
index 0000000..478d26f
--- /dev/null
+++ b/pkgs/inkscape.json
@@ -0,0 +1,6 @@
+{
+  "name":        "Inkscape",
+  "homepage":    "http://inkscape.org/",
+  "description": "An Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format.",
+  "URL":         "http://sourceforge.net/projects/inkscape/files/inkscape/0.48.2/Inkscape-0.48.2-1-win32.exe/download"
+}
diff --git a/pkgs/libreoffice.json b/pkgs/libreoffice.json
new file mode 100644
index 0000000..c2bb6f9
--- /dev/null
+++ b/pkgs/libreoffice.json
@@ -0,0 +1,6 @@
+{
+  "name":        "LibreOffice",
+  "homepage":    "http://www.libreoffice.org/",
+  "description": "LibreOffice is the power-packed free, libre and open source personal productivity suite for Windows, Macintosh and GNU/Linux.",
+  "URL":         "http://download.documentfoundation.org/libreoffice/stable/3.4.3/win/x86/LibO_3.4.3_Win_x86_install_multi.exe"
+}
diff --git a/pkgs/libreoffice_helppack.json b/pkgs/libreoffice_helppack.json
new file mode 100644
index 0000000..426228b
--- /dev/null
+++ b/pkgs/libreoffice_helppack.json
@@ -0,0 +1,6 @@
+{
+  "name":        "LibreOffice Help Pack",
+  "homepage":    "http://www.libreoffice.org/",
+  "description": "Localized Help Pack for LibreOffice",
+  "URL":         "http://download.documentfoundation.org/libreoffice/stable/3.4.3/win/x86/LibO_3.4.3_Win_x86_helppack_%s.exe"
+}
diff --git a/pkgs/mozilla_firefox.json b/pkgs/mozilla_firefox.json
new file mode 100644
index 0000000..cd90321
--- /dev/null
+++ b/pkgs/mozilla_firefox.json
@@ -0,0 +1,6 @@
+{
+  "name":        "Mozilla Firefox",
+  "homepage":    "http://www.mozilla.org/firefox/",
+  "description": "The Firefox browser is created by Mozilla, a non-profit organization whose mission is to promote openness, innovation and opportunity on the Web.",
+  "URL":         "http://download.mozilla.org/?product=firefox-6.0.2&os=win&lang=%s"
+}
diff --git a/pkgs/mozilla_thunderbird.json b/pkgs/mozilla_thunderbird.json
new file mode 100644
index 0000000..dc97907
--- /dev/null
+++ b/pkgs/mozilla_thunderbird.json
@@ -0,0 +1,6 @@
+{
+  "name":        "Mozilla Thunderbird",
+  "homepage":    "https://www.mozilla.org/thunderbird/",
+  "description": "Thunderbird is a free email application that's easy to set up and customize - and it's loaded with great features!",
+  "URL":         "http://download.mozilla.org/?product=thunderbird-3.1.14&os=win&lang=%s"
+}
diff --git a/pkgs/pidgin.json b/pkgs/pidgin.json
new file mode 100644
index 0000000..5c19891
--- /dev/null
+++ b/pkgs/pidgin.json
@@ -0,0 +1,6 @@
+{
+  "name":        "Pidgin",
+  "homepage":    "http://pidgin.im/",
+  "description": "Pidgin is an easy to use and free chat client used by millions. Connect to AIM, MSN, Yahoo, and more chat networks all at once.",
+  "URL":         "http://sourceforge.net/projects/pidgin/files/Pidgin/2.10.0/pidgin-2.10.0.exe"
+}
diff --git a/pkgs/vlc.json b/pkgs/vlc.json
new file mode 100644
index 0000000..f37bff7
--- /dev/null
+++ b/pkgs/vlc.json
@@ -0,0 +1,6 @@
+{
+  "name":        "VLC Media Player",
+  "homepage":    "http://www.videolan.org/",
+  "description": "VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVD, Audio CD, VCD, and various streaming protocols.",
+  "URL":         "http://sourceforge.net/projects/vlc/files/1.1.11/win32/vlc-1.1.11-win32.exe/download"
+}
diff --git a/pkgs/xp-antispy.json b/pkgs/xp-antispy.json
new file mode 100644
index 0000000..5d5d475
--- /dev/null
+++ b/pkgs/xp-antispy.json
@@ -0,0 +1,6 @@
+{
+  "name":        "XP Antispy",
+  "homepage":    "http://xp-antispy.org/",
+  "description": "The xp-AntiSpy is a little utility that lets you disable some built-in update and authentication 'features' in WindowsXP.",
+  "URL":         "http://xp-antispy.org/index.php/en/download?func=download&itemid=4&mirrorid=1"
+}
diff --git a/template.json b/template.json
new file mode 100644
index 0000000..dbf588b
--- /dev/null
+++ b/template.json
@@ -0,0 +1,10 @@
+{
+  "name":        "Example program",
+  "homepage":    "http://example.com/",
+  "description": "Example program doesn't do anything useful that we know of.",
+
+  /* A "%s" in the URL will be replaced with a language code,
+   * this can be useful for localized downloads.
+   */
+  "URL":         "http://example.com/program-0.1-%s.zip"
+}
diff --git a/winfreed.1.asciidoc b/winfreed.1.asciidoc
new file mode 100644
index 0000000..b580575
--- /dev/null
+++ b/winfreed.1.asciidoc
@@ -0,0 +1,58 @@
+WINFREED(1)
+===========
+:doctype: manpage
+
+
+NAME
+----
+winfreed - download a selection of Free Software for MS Windows
+
+
+SYNOPSIS
+--------
+*winfreed* <'COMMAND'>
+
+
+DESCRIPTION
+-----------
+The winfreed(1) command allows to download a selection of Free Software you 
+can install on MS Windows.
+
+
+COMMANDS
+--------
+
+*show*::
+    Show info about all the available packages
+
+*download*::
+   Download all the packages
+
+
+TODO Add command arguments like in "download <package>"
+
+
+EXIT STATUS
+-----------
+*0*::
+    Success
+
+*1*::
+    Failure (syntax or usage error; configuration error; document
+    processing failure; unexpected error).
+
+
+AUTHOR
+------
+WinFreed was originally written by Antonio Ospite.
+
+
+RESOURCES
+---------
+Main web site: <http://git.ao2.it/winfreed/>
+
+
+COPYING
+-------
+Copyright \(C) 2011  Antonio Ospite. Free use of this software is
+granted under the terms of the GNU General Public License v3 (GPLv3).
diff --git a/winfreed.py b/winfreed.py
new file mode 100755
index 0000000..c465b63
--- /dev/null
+++ b/winfreed.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+#
+# winfreed - download a selection of Free Software for MS Windows.
+#
+# Copyright (C) 2011  Antonio Ospite <ospite@studenti.unina.it>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+import glob
+import json
+import urllib2
+from progressbar import Bar, ETA, FileTransferSpeed, Percentage, ProgressBar
+
+# TODO make OUTPUT_DIR and LANGCODE configurable from command line
+OUTPUT_DIR = 'downloads'
+LANGCODE = 'en-US'
+
+# TODO PKG_DIR in $(datadir) or something like that for python projects
+PKG_DIR = 'pkgs'
+CHUNK_SIZE = 8192
+
+def process_all(path, cb):
+    listing = glob.glob(os.path.join(path, '*.json'))
+    for json_file in listing:
+        with open(json_file, mode='r') as f:
+            entry = json.load(f)
+            basename = os.path.basename(json_file)
+            package_name = os.path.splitext(basename)[0]
+            entry['package'] = package_name
+            cb(entry)
+            f.close()
+
+def show(entry):
+    print 'Package:  ', entry['package']
+    print 'Program:  ', entry['name']
+    print 'Homepage: ', entry['homepage']
+    print
+
+def download(entry):
+    # the "%s" in URLs are meant to be replaced with LANGCODE
+    try:
+        url = entry['URL'] % LANGCODE
+    except:
+        url = entry['URL']
+        pass
+
+    response = urllib2.urlopen(url)
+    filename = urllib2.unquote(os.path.basename(response.geturl()))
+    destfile = os.path.join(OUTPUT_DIR, filename)
+    if os.path.exists(destfile):
+        sys.stderr.write("Warning: %s exists!\n" % destfile)
+        return
+    outfile = open(destfile, mode='w')
+
+    total_size = response.info().getheader('Content-Length').strip()
+    total_size = int(total_size)
+
+    widgets = [entry['name'], ' ', Percentage(), ' ', Bar(marker='=', left='[', right=']'),
+               ' ', ETA(), ' ', FileTransferSpeed()]
+    pbar = ProgressBar(widgets=widgets, maxval=total_size).start()
+
+    bytes_so_far = 0
+    while 1:
+        chunk = response.read(CHUNK_SIZE)
+        if not chunk:
+            break
+
+        bytes_so_far += len(chunk)
+        outfile.write(chunk)
+        pbar.update(bytes_so_far)
+    pbar.finish()
+
+def show_all():
+    process_all(PKG_DIR, show)
+
+def download_all():
+    if os.path.exists(OUTPUT_DIR) == False:
+        os.mkdir(OUTPUT_DIR, 0755)
+
+    process_all(PKG_DIR, download)
+
+def usage():
+    usage = "winfreed - download a selection of Free Software for MS Windows.\n\n"
+    usage += "usage: %s <COMMAND>\n\n" % sys.argv[0]
+    usage += "COMMANDS:\n"
+    usage += "\tshow        Show info about all the available packages\n"
+    usage += "\tdownload    Download all the packages\n"
+    print usage
+
+if __name__ == "__main__":
+
+    if len(sys.argv) < 2:
+        usage()
+        sys.exit(1)
+
+    if sys.argv[1] == 'download':
+        download_all()
+    elif sys.argv[1] == 'show':
+        show_all()
+    else:
+        usage()
+        sys.exit(1)
+    
+    sys.exit(0)
-- 
2.1.4