Re: Chceking for updates



On Wed, Sep 03, 2003 at 08:25:21AM +0200, Jens Bech Madsen wrote:
> Here's a small script which checks the versions in the garballs with the
> versions on the Gnome FTP site. There are still a ton of kinks to work
> out, but it makes it easy to see if something is out-of-date.
> 
> Obvious improvements would be to automatically update the garballs and
> run makesum and to make it work on other FTP sites.

On a similar note I have made a script (python, attached) that can be
called from e.g. procmail whenever a new release is announced on
ftp-release-list.

Since I have my mail on a different machine than my garnome, the
script doesn't directly update the garnome distribution, but generates
scripts that will update the makefile and the cheksums file and saves
them into a directory which is nfs-mounted on both machines.

The variables to change in the script to fit your setup is 
GNOME_FTP_DIR and GARNOME_DIR

This is what I have in my procmail:
#gnome-ftp list
:0 c
* To: *ftp-release-list gnome org
| /home/disk07/rodaz/bin/shell/gnome-ftp-new.py

Change the path to fit your setup.

A small bash command can update garnome for you (execute in GNOME_FTP_DIR):
for file in `find -type d -maxdepth 1 -mindepth 1 | xargs`; do 
    (cd $file; ./update-checksums.sh; ./update-makefile.sh); 
done

Note that when a bugfix version of older stable versions arrive, the
scripts doesn't recognize this, so you might risk downgrading your
garnome. Suggestions to solve this is most welcome :)

Hope someone can use this,
/Bjarke
-- 
Bjarke <rodaz diku dk>
http://www.diku.dk/hjemmesider/studerende/rodaz

Q: Why is everyone so obsessed about ninjas?
A: Ninjas are the ultimate paradox. On the one hand they don't give a crap, but on the other hand, ninjas are very careful and precise.
			http://www.realultimatepower.net

#!/usr/bin/env python

# lets try to parse mails, to make some shell scripts that can update
# our garnome-distribution

# -- TODO --
# incorporate into the generated scripts that they don't
# accidentially downgrade packages when a new version
# arrives of an older stable package

import sys
import re
import string
import email
import os.path

#change these to fit your garnome setup 
GNOME_FTP_DIR = os.path.expanduser('~/gnome-ftp/')
GARNOME_DIR = os.path.expanduser('/scratch/rodaz/garnome-0.25.1/')

#map from module to dir
dirmap = {'fontconfig': 'misc/',
          'freetype': 'misc/',
          'libesmtp': 'misc/',
          'mozilla': 'misc/',
          'openbox': 'misc/',
          'pcre': 'misc/',
          'redhat-artwork': 'misc/',
          'Xft': 'misc/',
          'Xft1': 'misc/',
          'xine-lib': 'misc/',
          'Xrender': 'misc/',
          'gc': 'mono/',
          'gtk-sharp': 'mono/',
          'mono': 'mono/',
          'mono-debugger': 'mono/',
          'monodoc': 'mono/',
          } 
#parse the mail
rawmail = sys.stdin.read()
msg = email.message_from_string(rawmail)

subject = msg.get('Subject')
(module, version) = string.split(subject)

print "Looking at module " + module + ", version " + version

#Create directory for the module scripts if it doesn't exist
modulescriptdir = GNOME_FTP_DIR + module
if not os.access(modulescriptdir, os.F_OK):
    os.mkdir(modulescriptdir)

#Where is the module located under GARNOME_DIR
moduledir = GARNOME_DIR + dirmap.setdefault(module, 'gnome/') + module
print "\tmodule " + module + " belongs in  " + moduledir

#lets save the raw mail
mailfilename = modulescriptdir + "/latestmail"
f=open(mailfilename, 'w')
f.write(rawmail)
f.close()

msgbody = msg.get_payload()

if msgbody:
    #lets find the download url (tar.gz) and the md5 sum
    url_re = re.compile("^(http://.*)" + module + "-" + version + ".tar.bz2\n  md5sum: (.{32})",
                           re.MULTILINE | re.DOTALL)
    m1 = url_re.search(msgbody)
    master_site = m1.group(1)
    md5sum = m1.group(2)

    # generate a script that can update the Makefile in GARNOME_DIR/<module>/
    print "\tGenerating update-makefile.sh script"
    makefilename = modulescriptdir + "/update-makefile.sh"
    f=open(makefilename, 'w')
    f.write("#!/bin/bash\n"
            + "perl -pi -e 's/GARVERSION = .*$/GARVERSION = " + version + "/g' "
            + moduledir + "/Makefile\n"
            + "perl -pi -e 's/DISTFILES = .*$/DISTFILES = " + module + "-" + version + ".tar.bz2/g' "
            + moduledir + "/Makefile\n")
    f.close()
    os.chmod(makefilename, 0744)

    # generate a script file that can update the checksums file in GARNOME_DIR/<module>/
    print "\tGenerating update-checksums.sh script"
    checksumsfile = modulescriptdir + "/update-checksums.sh";
    f=open(checksumsfile, 'w') 
    f.write("#!/bin/bash\n" +
            "echo \"" + md5sum + "  download/" + module + "-" + version + ".tar.bz2\" >> " +
            moduledir + "/checksums\n")
    f.close()
    os.chmod(checksumsfile, 0744)
    sys.exit(0)

sys.exit(100)
    


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]