Steve Kemp's Blog Writings relating to Debian & Free Software

Debian is missing a tool, want to write it?

Fri, 14 Jun 2013 12:32:38 GMT

Seeing this piece in the news, about how Debian-Multimedia.org is now unsafe, I was reminded we don't have a tool to manipulate sources.lists entries.

For example:

$ apt-sources list
..
deb http://ftp.uk.debian.org/debian/ squeeze main non-free contrib
deb-src http://ftp.uk.debian.org/debian/ squeeze main

deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main
..

How about listing only my repos?

$ apt-sources list steve.org.uk
deb-src http://packages.steve.org.uk/firefox-wrapper/squeeze/ ./
deb     http://packages.steve.org.uk/firefox-wrapper/squeeze/ ./
deb     http://packages.steve.org.uk/meta/squeeze/ ./
deb-src http://packages.steve.org.uk/meta/squeeze/ ./
deb-src http://packages.steve.org.uk/minidlna/squeeze/ ./
deb     http://packages.steve.org.uk/minidlna/squeeze/ ./

Now add in a command to delete lines matching a given pattern:

# apt-sources delete debian-multimedia.org

Doesn't that seem like a tool that should exist?

I've added this quick hack to this repository which you can submit pull requests against, or use as a base.

TODO: Write the "add" handler. Neaten.

Ever felt jealous that Ubuntu users can add PPAs? Nows your chance to do something like this:

# apt-sources add "deb http://packages.steve.org.uk/lumail/wheezy/ ./"

| 11 comments.

 

Comments On This Entry

[gravitar] Martijn Grendelman

Submitted at 07:28:22 on 14 June 2013

Well, the fact that Ubuntu users HAVE such a thing as PPAs, THAT's something to be jealous of.

For the rest, I don't really see how

  1. apt-sources add "deb http://packages.steve.org.uk/lumail/wheezy/ ./"

is substantially easier than

echo "deb http://packages.steve.org.uk/lumail/wheezy/ ./"
> /etc/apt/sources.list.d/lumail.list

Everything else can be done easily with grep, sed and rm :-)

[gravitar] Gioele

Submitted at 07:30:21 on 14 June 2013

Why a new command when add-apt-repository already solves this problem?

- The apt repository source line to add. This is one of:
a complete apt line in quotes,
a repo url and areas in quotes (areas defaults to 'main')
a PPA shortcut.

Examples:
apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
apt-add-repository 'http://myserver/path/to/repo myrepo'
apt-add-repository 'https://packages.medibuntu.org free non-free'
apt-add-repository http://extras.ubuntu.com/ubuntu
apt-add-repository ppa:user/repository

[gravitar] Jean-Christophe Dubacq

Submitted at 07:46:49 on 14 June 2013

Coincidentally, I did write a tool that lists packages by their origin as an exercise in 1/ packaging 2/ apt manipulation. It is still useful to me.

You can find it there: https://github.com/jcdubacq/apt-moreutils/blob/master/bin/apt-origins

It outputs things like these:
,------------------------------------------------------------------------------.
| debian.dubacq.fr.unstable |
`------------------------------------------------------------------------------'
apt-moreutils cryptstore jcdubacq-archive-keyring liblmdb0 liblmdb0-dev
,------------------------------------------------------------------------------.
| security.stable |
`------------------------------------------------------------------------------'
libxcb-dri2-0 libxcb-glx0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb1
libxcursor1 libxext6 libxfixes3 libxi6 libxinerama1 libxp6 libxrandr2
libxrender1 libxres1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1
linux-image-3.2.0-4-amd64 linux-libc-dev xserver-xorg-video-openchrome
,------------------------------------------------------------------------------.
| debian.experimental |
`------------------------------------------------------------------------------'
xul-ext-gnome-keyring
,------------------------------------------------------------------------------.
| debian.stable |
`------------------------------------------------------------------------------'
Too many packages (1832). Use --tabular or --lines=X (x>=1832).
,------------------------------------------------------------------------------.
| debian.testing |
`------------------------------------------------------------------------------'
auctex libopenmpi1.6 libopenmpi1.6-dbg libopenmpi1.6-dev libspiro0
libuninameslist0 openmpi1.6-bin openmpi1.6-checkpoint openmpi1.6-common
openmpi1.6-doc
,------------------------------------------------------------------------------.
| debian.unstable |
`------------------------------------------------------------------------------'
calendar-google-provider emacs24 emacs24-bin-common emacs24-common
xul-ext-adblock-plus
,------------------------------------------------------------------------------.
| installed |
`------------------------------------------------------------------------------'
equivs-nodejs

[gravitar] Alex

Submitted at 09:46:00 on 14 June 2013

Why not just make use of /etc/apt/sources.list.d?

All we'd need is standardized naming scheme. I'd propose this:

$TYPE-$DOMAIN-$RELEASE.list

e.g.:

binary-ftp.debian.org-wheezy.list

or

source-security.debian.org-wheezy.list

If the installer created such files and we'd recommend those over additional
lines in the sources.list, all of the task mentioned above could be done via
standard UNIX tools.

[gravitar] Qball Cow

Submitted at 10:11:44 on 14 June 2013

This is very interesting, going to try it out tonight.

Thanks!

[gravitar] rjc

Submitted at 10:52:17 on 14 June 2013

If I may suggest a slighlty different format:

% apt-sources add "http://packages.steve.org.uk/lumail/wheezy/ ./"

where 'deb' would be the default '-s' changes the begaviour to 'deb-src' (there are some repositories which only provide source packages without binary ones, i.e. mentors.debian.net), '-b' would add both 'deb' and 'deb-src'. Also '-t' could be used to specify transport, i.e. 'ftp', 'file', 'http', etc. 'http://' could be omitted and treated as the default transport rendering the above:

% apt-sources add "packages.steve.org.uk/lumail/wheezy/ ./"

Just a thought...

[gravitar] Steve

Submitted at 12:47:16 on 14 June 2013

apt-add-repository is not a well-known command. I had to search for it to find it.

Still it looks like that is the official solution.


[gravitar] David Kalnischkies

Submitted at 14:47:22 on 14 June 2013

I know that this is a quick hack and all, but support for read/write of these files should really be in libapt-pkg, so that front-ends can use it (also via python and perl bindings), so I would encourage anyone who wants to see that happen to join deity@lists.debian.org.

The problem with "UNIX way" of managing the files is that sources can (and will) have options attached to them (e.g. arch=, trusted=, …), the order in which these entries are discovered might be important (as you can prefer local over network sources this way), just taking the hostname doesn't work for hosts with multiple repositories (think launchpad or Debians upcoming "bikeshred") and/or this far away dream of using a more "Debian-like" deb822 format for them.

[gravitar] Joaquin Bogado

Submitted at 17:17:10 on 14 June 2013

From a user point of view, type some like
# apt-sources add "deb http://packages.steve.org.uk/lumail/wheezy/ ./"
isn't neat.
Just a though, but what about per repo file with the repository description?
I think Scientific Linux do some like this. You download a .repo file from the a repository you want to add, an the just type
# apt-sources add mynew.repo

[gravitar] Steve Kemp

Submitted at 19:11:51 on 14 June 2013

Joaquin that would be ideal, but first we'd have to define the repo format, and require help from everybody before the tool could use them.

My quick hack requires no special format, though certainly you could bake in shortcuts such as:

add steve.org.uk:lumail/wheezy

Or an Ubuntu-like PPA-shortcut to point to mentors.debian.net.


[gravitar] Mélodie

Submitted at 14:16:33 on 15 June 2013

Hi,

Would you consider porting software-properties-gtk from Ubuntu to Debian, and make it a standalone tool?

You can read here:
Re : Re : Re : Users warned to remove Debian Multimedia repository - http://linuxvillage.net/index.php/topic,409.msg2805.html#msg2805


 

Comments are closed on posts which are more than ten days old.

Spiral Logo

Search

Recent Posts

Recent Tags

Links

RSS Feed

  • Subscribe to feed