| View previous topic :: View next topic |
| Author |
Message |
Lawrence D'Oliveiro Guest
|
Posted: Sun Nov 16, 2008 7:30 am Post subject: Factoring sources.list |
|
|
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 5 , 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.  |
|
| |
|
Back to top |
Baron Guest
|
Posted: Sun Nov 16, 2008 8:24 am Post subject: Re: Factoring sources.list |
|
|
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 5 , 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.
|
You should offer this back to the developers ! Its quite neat.
--
Best Regards:
Baron. |
|
| |
|
Back to top |
|