SilverWav's Journal

The best is yet to come…

Archive for April 2010

Listing latest published packages in a PPA

leave a comment »

OK so now I have a way of listing the latest published packages in a PPA. :-)

The key is that I can specify the series e.g. lucid or karmic and get results for each.

Note: Learning python as I go… :-)
Yes a better function is called for but this will do for now.

Advantages over the web interface:
It is easy to see the 8 packages I am interested in (out of the 50 in the ppa).
I can also quickly confirm when all the packages have been built (I just check the date).



#! /usr/bin/env python

from launchpadlib.launchpad import Launchpad
launchpad = Launchpad.login_with('bot100', 'edge')

distro = launchpad.distributions["ubuntu"]
ppa = launchpad.people['ubuntu-mozilla-daily'].archive

def getPS(seri, source):
    series = distro.getSeries(name_or_version = seri)

    last_app = ppa.getPublishedSources(
    apptemp = last_app.source_package_version

    print apptemp
    return apptemp

appff10 = getPS('lucid','firefox')
appff20 = getPS('lucid','firefox-3.7')
appff30 = getPS('lucid','xulrunner-1.9.2')
appff40 = getPS('lucid','xulrunner-1.9.3')
appff1 = getPS('karmic','firefox')
appff2 = getPS('karmic','firefox-3.7')
appff3 = getPS('karmic','xulrunner-1.9.2')
appff4 = getPS('karmic','xulrunner-1.9.3')



$ ./




Written by SilverWav

April 29, 2010 at 5:28 pm

Launchpad syncSources missing “from series”

leave a comment »

OK a new project involving PPA’s, Launchpad, launchpadlib, Soyuz.

Lets start documenting some of this stuff while its fresh.

Tag the project “onedailyamonth” so I can find it later.

This may be a rather brutal introduction to python for me…
Oh well learning something new is always fun :-)

It works… everything else is bonus points.


$ python
##Start up the Launchpad command line.
>>> from launchpadlib.launchpad import Launchpad

##Start up your application and login.
launchpad = Launchpad.login_with('bot100', 'edge')
##Authorise the app in Launchpad and away you go...

Run the script or paste each command in turn to test it.

#! /usr/bin/env python

from launchpadlib.launchpad import Launchpad
launchpad = Launchpad.login_with('bot100', 'edge')

    from_archive = launchpad.people['ubuntu-mozilla-daily'].archive
    to_archive ='one-daily-a-month')
    sources_to_be_copied = ['firefox','xulrunner-1.9.2']
    print to_archive.syncSources(
    sources_to_be_copied = ['firefox-3.7', 'xulrunner-1.9.3']
    to_archive ='one-daily-a-month-1')
    print to_archive.syncSources(


This is great except it will not do a series, e.g. karmic, separately :-(
“API for copying packages (syncSources) needs a “from series” parameter” Bug #493914

So I will need to use syncSource instead.

This further means, that I will need a way to find the specific version name, for each of the packages.

Looking at the examples gives me something I can use…

“Listing the current package versions in a particular distroseries” here API/Examples.

OK we have a plan :-)

Written by SilverWav

April 29, 2010 at 1:42 pm

Note: Using the launchpad API for copying

leave a comment »

Saved for reference.

Celso Providelo said on 2009-03-20:

It will probably get too boring, at this point you might consider writing a script using the launchpad API for copying your stuff. Check the API guide at and try something along these lines:

    from_archive =
    to_archive = launchpad.people['kde3-maintainers'].archive
    sources_to_be_copied = ['x', 'y', 'z']
    print to_archive.syncSources(

Written by SilverWav

April 28, 2010 at 2:52 pm

Note: getPublishedSources

leave a comment »

Saved for reference.

Celso Providelo

Sources can be found, basically, by name, version, distroseries and status by calling getPublishedSources on a target archive.

When it run, the output is:

firefox-3.5 3.5~b4~hg20090415r24712+nobinonly-0ubuntu1~umd1 in jaunty

 >>> def test_source_lookup(lp):
     ppa = lp.people['ubuntu-mozilla-daily'].archive
     ubuntu = lp.distributions['ubuntu']
     jaunty = ubuntu.getSeries(name_or_version='jaunty')
     last_firefox = ppa.getPublishedSources(
         source_name='firefox-3.5', status='Published', distro_series=jaunty,
     print last_firefox.displayname


Note: displayname gives an error message, use this instead:

print last_firefox.source_package_version

Written by SilverWav

April 27, 2010 at 2:58 pm

Note: syncSource

leave a comment »

Saved for reference.

Celso Providelo

An authenticated user may copy sources (including their binaries or not) from any public archive to any PPA he has permission to upload using syncSource

One practical example is backporting recent SRUs to LTS series using your PPAs. Let say, we want the latest libvirt version available for testing in your Hardy instance.

libvirt – 0.6.1-0ubuntu5.1 will be rebuilt in your PPA for hardy and if everything is compatible in few minutes you will be able to use and share it with other users.

ubuntu = lp.distributions['ubuntu']
primary, partner = ubuntu.archives
ppa ='ppa')
source_name='libvirt', version='0.6.1-0ubuntu5.1',
from_archive=primary, include_binaries=False,
to_series='hardy', to_pocket='Release')

Written by SilverWav

April 27, 2010 at 2:18 pm

Note: md5sum for each file in directory

leave a comment »


This is a recursive command, that is, it will create a md5 for all files in sub directories as well.

1. Create md5sum’s for each file in the directory and output to the file check.md5.

find . -type f 2>/dev/null -exec md5sum {} \; >check.md5

Note: You may need to run from root e.g sudo -i, which is not best practice.

2. Confirm files in the directory against check.md5 and output to the file results.md5

md5sum -c check.md5 > results.md5

Written by SilverWav

April 25, 2010 at 12:16 pm

Posted in Notes

Tagged with , , ,

Note: Shred All Files in a Directory

with 3 comments

Important – Could Delete Your System!

Make sure you use “Open in Terminal” or cd to the correct directory before running this command.

Or you will be sorry.


Overwrite then Delete All Files in a Directory

find -type f -execdir shred -u -z '{}' \;

The find command itself is used to find files matching a certain expression, on a certain path.

The the path argument is omitted, so find starts the search from the default current working directory.

The next argument to find, -type f, tells find to match only regular files (as we can’t shred directories).

The -execdir argument tells find to execute the command following the argument on each file matched (from that file’s parent directory).

We could alternatively have used the -exec argument, but -execdir is more secure because it changes directories before executing the command.

The remaining arguments are taken as the command to execute, until a terminating ‘;’ character is encountered.

We tell find to execute the shred command (with options) on each file matched.

The -u option to shred tells it to remove the file after shredding.

Find replaces the ‘{}’ string with the current file name being processed.

Note the braces are quoted to prevent expansion by the shell.

Finally, a semi-colon terminates the -execdir command.

The ; character is again escaped, this time with a ‘\’, to prevent expansion by the shell.


Important – Could Kill Your Cat!

I don’t use this command, added for completeness.

If you do use it, ensure you have important data backed-up and a way of reinstalling your system.

I use Nautilus to delete directories as its safer :-)


Delete a Tree of Directories.

Quote from opentux:
After executing the first command, all files in the directory tree have been securely shredded and removed, and all that is left is a tree of empty directories. Since the directories themselves contain no sensitive information (they are just a list of names and i-node numbers), they can be safely removed with rm.
I specified using the command
$>rm -rf *
to recursively (-r) remove all the directories without prompt (-f), since I knew all sensitive files to have been securely removed already. But alternatively if you wanted to make doubly sure you weren’t unsecurely removing any missed files, you could invoke rmdir on each remaining directory (from the bottom up).


Written by SilverWav

April 25, 2010 at 11:07 am

Posted in Notes

Tagged with , , , , ,