www.smartbusinesschoices.com

Leading Business and Technology,
News and information


Part of the Identityscape.com network...

getxfactor.com jmoodmusic.com smartbusinesschoices.com mintdepot.com lowfaresalways.com evangelicalview.com shoppingpodder.com soproudlywehail.com webnews.ws currenthumor.com

 

 

Factoring sources.list
   Smart Linux Business Choices! - the Best of UseNet Postings! Forum Index -> General Linux Discussion  
View previous topic :: View next topic  
Author Message
Lawrence D'Oliveiro
Guest






PostPosted: Sun Nov 16, 2008 7:30 am    Post subject: Factoring sources.list Reply with quote

The Kubuntu install on my Eee has a sources.list file full of repetitive
entries like

deb http://au.archive.ubuntu.com/ubuntu/ intrepid universe
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid universe
deb http://au.archive.ubuntu.com/ubuntu/ intrepid-updates universe
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid-updates universe

Every "deb" line also has a "deb-src" line. And originally the "au"
said "nz", until I discovered that the NZ repository didn't seem to be
complete, so I had to do a search-replace with Emacs, changing all the
references. Then there's the issue of commenting or uncommenting all
the "multiverse" lines at once.

I thought: wouldn't it be easier to be able to factor all the entries into a
form that's easier to edit? The obvious thing to do was use the m4 macro
package. I came up with the following macros:

define(`country', `au')dnl which country-specific repository to use
define(`vername', `intrepid')dnl
define(`archive_base', `http://'country`.archive.ubuntu.com/ubuntu/')dnl
dnl `use_archive' generates two lines, one deb and one deb-src,
dnl for the specified version name and category(es) of packages.
dnl `use_all_archive' uses `use_archive' to generate 3 pairs of deb and
dnl deb-src lines, one for the base version, one for updates, and one
dnl for security updates.
define(`use_archive',
``$3'deb archive_base $1 $2
`$3'deb-src archive_base $1 $2')dnl
define(`use_all_archive',
`use_archive(vername, `$1', `$2')
use_archive(vername-updates, `$1', `$2')
use_archive(vername-security, `$1', `$2')')dnl

With the above, the single line

use_all_archive(`main restricted', `')

expands to

deb http://au.archive.ubuntu.com/ubuntu/ intrepid main restricted
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid main restricted
deb http://au.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted
deb http://au.archive.ubuntu.com/ubuntu/ intrepid-security main restricted
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid-security main restricted

and similarly for the other categories.

The .m4 version wasn't much smaller in total (54 lines versus 5Cool, but it's
so much easier to make changes: thus, replacing the "au" with "nz" is just a
one-line change. And when "intrepid" is upgraded to "jaunty", that too will
be a one-line change.

It's just that, after making any changes, I have to re-expand my factored
version:

m4 <sources.list.m4 >sources.list

It would be nice to automate this somehow. But then again, the manual step
provides a check against another opportunity for things to go wrong. Smile
Back to top
Baron
Guest






PostPosted: Sun Nov 16, 2008 8:24 am    Post subject: Re: Factoring sources.list Reply with quote

Lawrence D'Oliveiro wrote:

Quote:
The Kubuntu install on my Eee has a sources.list file full of
repetitive entries like

deb http://au.archive.ubuntu.com/ubuntu/ intrepid universe
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid universe
deb http://au.archive.ubuntu.com/ubuntu/ intrepid-updates universe
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid-updates
universe

Every "deb" line also has a "deb-src" line. And originally the "au"
said "nz", until I discovered that the NZ repository didn't seem to be
complete, so I had to do a search-replace with Emacs, changing all the
references. Then there's the issue of commenting or uncommenting all
the "multiverse" lines at once.

I thought: wouldn't it be easier to be able to factor all the entries
into a form that's easier to edit? The obvious thing to do was use the
m4 macro package. I came up with the following macros:

define(`country', `au')dnl which country-specific repository to
use define(`vername', `intrepid')dnl
define(`archive_base',
`http://'country`.archive.ubuntu.com/ubuntu/')dnl dnl
`use_archive' generates two lines, one deb and one deb-src, dnl
for the specified version name and category(es) of packages. dnl
`use_all_archive' uses `use_archive' to generate 3 pairs of deb
and dnl deb-src lines, one for the base version, one for updates,
and one dnl for security updates. define(`use_archive',
``$3'deb archive_base $1 $2
`$3'deb-src archive_base $1 $2')dnl
define(`use_all_archive',
`use_archive(vername, `$1', `$2')
use_archive(vername-updates, `$1', `$2')
use_archive(vername-security, `$1', `$2')')dnl

With the above, the single line

use_all_archive(`main restricted', `')

expands to

deb http://au.archive.ubuntu.com/ubuntu/ intrepid main restricted
deb-src http://au.archive.ubuntu.com/ubuntu/ intrepid main
restricted deb http://au.archive.ubuntu.com/ubuntu/
intrepid-updates main restricted deb-src
http://au.archive.ubuntu.com/ubuntu/ intrepid-updates main
restricted deb http://au.archive.ubuntu.com/ubuntu/
intrepid-security main restricted deb-src
http://au.archive.ubuntu.com/ubuntu/ intrepid-security main
restricted

and similarly for the other categories.

The .m4 version wasn't much smaller in total (54 lines versus 5Cool, but
it's so much easier to make changes: thus, replacing the "au" with
"nz" is just a one-line change. And when "intrepid" is upgraded to
"jaunty", that too will be a one-line change.

It's just that, after making any changes, I have to re-expand my
factored version:

m4 <sources.list.m4 >sources.list

It would be nice to automate this somehow. But then again, the manual
step provides a check against another opportunity for things to go
wrong. Smile

You should offer this back to the developers ! Its quite neat.

--
Best Regards:
Baron.
Back to top
Display posts from previous:   
   Smart Linux Business Choices! - the Best of UseNet Postings! Forum Index -> General Linux Discussion  
Page 1 of 1
All times are GMT

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum