Monday, June 15, 2009

Build a local repository of EeePC Asus Update

With the success of my approach to restoring EeePC Linux from USB to a minimal system, in the coming few days, I am expecting to run more tests on different iso versions I have on hand, and probably removing and re-installing different sets of packages.

To speed up the re-installation process, I think it is better to download all the packages for the EeePC Linux version 1.6 I am working on from http://update.eeepc.asus.com/ and build a local repository, so that I don't need to spend long time to download the packages for re-installation, and may be even automate the process with a script.

Download Asus Update packages with wget

In Linux, there is a handy tool called wget that comes pre-installed in every distribution. There are also GUI frontends for wget (e.g. Gwget from the Debian repositories), but I think it is simple enough just to run it in the terminal. If you prefer to work in Microsoft Windows, there is also a Windows version wGetGUI.

Take the example of a 701 en_US 1.6 version, first you need to know the URL where the packages are hosted, and this information can be obtained from your /etc/apt/sources.list, e.g.
deb http://update.eeepc.asus.com/1.6 common main
deb http://update.eeepc.asus.com/1.6 p701 main
deb http://update.eeepc.asus.com/1.6 en main
This means that the *.deb packages you need will be hosted in URLs:
http://update.eeepc.asus.com/1.6/pool/common
http://update.eeepc.asus.com/1.6/pool/en
http://update.eeepc.asus.com/1.6/pool/p701
And with this command, wget will download all files from the URL you specified:
wget -r -w 20 -nd -np -l 1 http://update.eeepc.asus.com/1.6/pool/common
Here, the option "-w 20" ask wget to wait 20 seconds before retrievals. If you are not in a hurry, this is considered a good practice so that you don't stress the server too much occupying all its bandwidth. Be considerate to others!

Also, the option "-l 1" set the depth level to 1, so that wget will not get packages from "Parent Directory". But you will have to run this command for every folder in the URL lists you want to download. e.g. There is a sub-folder "openssl" in "common", and you will have to run wget again to download files in this folder:
/media/D:/1.6/pool/common/openssl> wget -r -nd -np -l 1 http://update.eeepc.asus.com/1.6/pool/common/openssl
--21:37:02-- http://update.eeepc.asus.com/1.6/pool/common/openssl
=> `openssl'
Resolving update.eeepc.asus.com... 211.72.249.195
Connecting to update.eeepc.asus.com|211.72.249.195|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://update.eeepc.asus.com/1.6/pool/common/openssl/ [following]
--21:37:02-- http://update.eeepc.asus.com/1.6/pool/common/openssl/
=> `index.html'
Reusing existing connection to update.eeepc.asus.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 1,279 (1.2K) [text/html]

100%[====================================================>] 1,279 --.--K/s

21:37:03 (40.05 MB/s) - `index.html' saved [1279/1279]

...

--21:37:08-- http://update.eeepc.asus.com/1.6/pool/common/openssl/openssl_0.9.8c-4etch5_i386.deb
=> `openssl_0.9.8c-4etch5_i386.deb'
Reusing existing connection to update.eeepc.asus.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 1,015,578 (992K) [application/x-debian-package]

100%[====================================================>] 1,015,578 617.73K/s

21:37:10 (615.75 KB/s) - `openssl_0.9.8c-4etch5_i386.deb' saved [1015578/1015578]

FINISHED --21:37:10--
Downloaded: 3,991,869 bytes in 4 files
/media/D:/1.6/pool/common/openssl>
For more information on wget options, read the GNU Wget Manual.

What I did is I put the commands into a script and ran it before I left for work. When I returned home, the download has already finished. A total of 2.96 GB has been downloaded.

Build a local Repository on an USB stick for my EeePC

For the local repository, I need an USB stick of at least 4 GB, where I can copy the 3 folders "common", "en" and "p701", and the deb packages they contain. You can place it in any folder, but my choice is "1.6/pool".

Here, most of the packages are in the folder "common", with some packages in the "p701" and just a few in the "en" folders. "p701" folder is for packages specific to 701 model, and "en" folder is for packages specific to US English version.

I have deleted the sub-folders "firefox3", "p901-system-update" and "staroffice", and also search and delete deb packages for locales other than "zh-tw".

The folder "firefox3" contains the "firefox-upgrade" package which will installed firefox3, flashplayer10, upgrade libc6 to version 2.7-13, and gtk libraries to 2.12.1. This is convenient for those who like firefox3, but will cause problem when I install packages from Debian etch repositories later, e.g. vlc. So I prefer alternative solutions.

To build the local repositories, you can refer to this APT HOWTO: How to use APT locally.

Basically, what you need to do is: first create the folder tree for saving the package list to be generated, then run the command "dpkg-scanpackages" which will read the control files in each deb package, e.g. "pool/common/*.deb", and generate the file "Packages":
mkdir -p dists/common/main/binary-i386
mkdir -p dists/en/main/binary-i386
mkdir -p dists/p701/main/binary-i386
dpkg-scanpackages -m pool/common /dev/null > dists/common/main/binary-i386/Packages
dpkg-scanpackages -m pool/en /dev/null > dists/en/main/binary-i386/Packages
dpkg-scanpackages -m pool/p701 /dev/null > dists/p701/main/binary-i386/Packages
Here is an example of the terminal output running this:
/media/D:/1.6> dpkg-scanpackages -m pool/en /dev/null > dists/en/Packages
** Packages in archive but missing from override file: **
kaffeine-dtv v4ldvbpb voice-command-en

Wrote 3 entries to output Packages file.
/media/D:/1.6>

To use this local repositories, you will need to edit /etc/apt/sources.list and add the following entries:
deb file:/media/"D:"/1.6/ common main
deb file:/media/"D:"/1.6/ p701 main
deb file:/media/"D:"/1.6/ en main
Then update apt cache:
/media/D:/1.6> sudo apt-get update
Ign file: common Release.gpg
Ign file: p701 Release.gpg
Ign file: en Release.gpg
Ign file: common Release
Ign file: p701 Release
Ign file: en Release
Ign file: common/main Packages
Ign file: p701/main Packages
Ign file: en/main Packages
Reading package lists... Done
/media/D:/1.6>
If no error comes up, you can now fire up synaptic and check if the local repositories are available. Now, you will be able to re-install all the packages you have removed in a swift!

No comments:

Post a Comment