个人工具

“UbuntuHelp:Debmirror”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/Debmirror}}
 
{{From|https://help.ubuntu.com/community/Debmirror}}
 
{{Languages|UbuntuHelp:Debmirror}}
 
{{Languages|UbuntuHelp:Debmirror}}
 
 
 
=== To build a mirror with debmirror follow these steps ===
 
=== To build a mirror with debmirror follow these steps ===
 
 
This is not covering all use cases but it will allow you experiment. To do this safely 8.2 gigs of space are needed to mirror main source and binaries. This number grows a lot as time progresses.
 
This is not covering all use cases but it will allow you experiment. To do this safely 8.2 gigs of space are needed to mirror main source and binaries. This number grows a lot as time progresses.
 
 
==== Alternative Consideration ====
 
==== Alternative Consideration ====
 
 
If you want to download all the apt binaries for all boxes onto one box on a network then maybe apt-cache or a transparent proxy (eg [http://help.ubuntu.com/community/HttpReplicator http-replicator] is all you need.
 
If you want to download all the apt binaries for all boxes onto one box on a network then maybe apt-cache or a transparent proxy (eg [http://help.ubuntu.com/community/HttpReplicator http-replicator] is all you need.
 
 
Another method is to use rsync. The [http://help.ubuntu.com/community/Rsyncmirror Rsyncmirror] page goes into greater detail on this method. Rsync can create a full mirror of a site and selects files indiscriminately. Debmirror, however, does allow for better control over which packages are mirrored and can be easier on the amount of hard drive space required.
 
Another method is to use rsync. The [http://help.ubuntu.com/community/Rsyncmirror Rsyncmirror] page goes into greater detail on this method. Rsync can create a full mirror of a site and selects files indiscriminately. Debmirror, however, does allow for better control over which packages are mirrored and can be easier on the amount of hard drive space required.
 
 
==== Start The Mirror Build Process ====
 
==== Start The Mirror Build Process ====
 
 
Open gnome-terminal by clicking Applications -> Accessories -> Terminal.
 
Open gnome-terminal by clicking Applications -> Accessories -> Terminal.
 
<br>If your sources list has universe enabled, skip the next step.
 
<br>If your sources list has universe enabled, skip the next step.
第21行: 第13行:
 
<br>Then save and return to a prompt.
 
<br>Then save and return to a prompt.
 
<br>In the example above, cc is your countrys code (eg au means Australia), and dapper is replaced with the release your using.
 
<br>In the example above, cc is your countrys code (eg au means Australia), and dapper is replaced with the release your using.
 
 
Update the package lists (sudo apt-get update) and then install debmirror (sudo apt-get install debmirror).
 
Update the package lists (sudo apt-get update) and then install debmirror (sudo apt-get install debmirror).
 
<br> Now we have to create a directory to save the files too. The approximate size of the components of the mirror (i386 only) are:
 
<br> Now we have to create a directory to save the files too. The approximate size of the components of the mirror (i386 only) are:
第30行: 第21行:
 
| dapper          ||  15G    || main, restricted, universe, multiverse  
 
| dapper          ||  15G    || main, restricted, universe, multiverse  
 
|}
 
|}
 
 
 
Please ensure where ever you make the mirror has room for the packages you want to download!
 
Please ensure where ever you make the mirror has room for the packages you want to download!
 
<br>(If you are more advanced you can make different parts of the mirror on different volumes, but thats not something for this howto).
 
<br>(If you are more advanced you can make different parts of the mirror on different volumes, but thats not something for this howto).
第38行: 第27行:
 
sudo mkdir /home/UbuntuMirror
 
sudo mkdir /home/UbuntuMirror
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Create the file `mirrorbuild.sh` ===
 
=== Create the file `mirrorbuild.sh` ===
 
 
Now to create `mirrorbuild.sh`
 
Now to create `mirrorbuild.sh`
 
<br>Open your prefered editor thus
 
<br>Open your prefered editor thus
第46行: 第33行:
 
sudo sensible-editor /usr/local/bin/mirrorbuild.sh
 
sudo sensible-editor /usr/local/bin/mirrorbuild.sh
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Copy the text from the box below into the editor.
 
Copy the text from the box below into the editor.
 
<br>You may omit the lines starting with # (NB EXCEPTION  the line that starts #!/bin/bash must be left in.)
 
<br>You may omit the lines starting with # (NB EXCEPTION  the line that starts #!/bin/bash must be left in.)
 
 
==== Contents of the mirror script, please adapt it to your needs ====
 
==== Contents of the mirror script, please adapt it to your needs ====
 
<pre><nowiki>
 
<pre><nowiki>
 
 
#!/bin/bash
 
#!/bin/bash
 
 
 
# Arch= -a # Architecture. For Ubuntu can be i386, powerpc or amd64.
 
# Arch= -a # Architecture. For Ubuntu can be i386, powerpc or amd64.
 
# sparc, only starts in dapper, it is only the later models of sparc
 
# sparc, only starts in dapper, it is only the later models of sparc
 
#
 
#
 
arch=i386
 
arch=i386
 
 
# Minimum Ubuntu system requires main, restricted
 
# Minimum Ubuntu system requires main, restricted
 
# Section= -s # Section (One of the following - main/restricted/universe/multiverse).
 
# Section= -s # Section (One of the following - main/restricted/universe/multiverse).
 
#
 
#
 
section=main,restricted,universe,multiverse
 
section=main,restricted,universe,multiverse
 
 
# Release= -d # Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired)
 
# Release= -d # Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired)
 
#
 
#
 
release=dapper,dapper-security,dapper-updates
 
release=dapper,dapper-security,dapper-updates
 
 
# Server= -h # Server name, minus the protocol and the path at the end
 
# Server= -h # Server name, minus the protocol and the path at the end
 
# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia  ca. in Canada.
 
# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia  ca. in Canada.
第75行: 第54行:
 
#
 
#
 
server=cc.archive.ubuntu.com
 
server=cc.archive.ubuntu.com
 
 
# Dir= -r # Path from the main server, so http://my.web.server/$dir, Server dependant
 
# Dir= -r # Path from the main server, so http://my.web.server/$dir, Server dependant
 
#
 
#
 
inPath=/ubuntu
 
inPath=/ubuntu
 
 
# Proto= -e # Protocol to use for transfer (http, ftp, hftp, rsync)
 
# Proto= -e # Protocol to use for transfer (http, ftp, hftp, rsync)
 
# Choose one - http is most usual the service, and the service must be avaialbe on the server you point at.
 
# Choose one - http is most usual the service, and the service must be avaialbe on the server you point at.
 
#
 
#
 
proto=http
 
proto=http
 
 
# Outpath= # Directory to store the mirror in
 
# Outpath= # Directory to store the mirror in
 
# Make this a full path to where you want to mirror the material.
 
# Make this a full path to where you want to mirror the material.
 
#
 
#
 
outPath=/home/UbuntuMirror
 
outPath=/home/UbuntuMirror
 
 
# The --nosource option only downloads debs and not deb-src's
 
# The --nosource option only downloads debs and not deb-src's
 
# The --progress option shows files as they are downloaded
 
# The --progress option shows files as they are downloaded
第104行: 第79行:
 
-e $proto \
 
-e $proto \
 
$outPath
 
$outPath
 
 
 
</nowiki></pre>
 
</nowiki></pre>
 
 
==== How to use the file ====
 
==== How to use the file ====
 
Save the file and exit.
 
Save the file and exit.
 
 
* Now change the permissions and ownership on the mirror. The group name is your username:
 
* Now change the permissions and ownership on the mirror. The group name is your username:
 
<pre><nowiki>
 
<pre><nowiki>
第125行: 第96行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Now walk away. Your machine has a lot of downloading to do!
 
Now walk away. Your machine has a lot of downloading to do!
 
 
=== Set up the mirror ===
 
=== Set up the mirror ===
 
 
We need to install Apache2, you could choose apache version 1.3 but that is beyond the scope of this document.
 
We need to install Apache2, you could choose apache version 1.3 but that is beyond the scope of this document.
 
<br> We can do this with `sudo apt-get install apache2`
 
<br> We can do this with `sudo apt-get install apache2`
第138行: 第107行:
 
<br>
 
<br>
 
<br> Right! So we have all the packages, and a working server. Now we need to set up the clients.
 
<br> Right! So we have all the packages, and a working server. Now we need to set up the clients.
 
 
 
=== Set up a client system ===
 
=== Set up a client system ===
 
 
Open a terminal and enter
 
Open a terminal and enter
 
<pre><nowiki>
 
<pre><nowiki>
第149行: 第115行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Now in your editor, put the following lines:
 
Now in your editor, put the following lines:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# Local network mirror sources.
 
# Local network mirror sources.
第156行: 第121行:
 
deb http://mirrorbox/ubuntu dapper-security main restricted universe multiverse
 
deb http://mirrorbox/ubuntu dapper-security main restricted universe multiverse
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Then save and exit
 
Then save and exit
 
<br> If you then run
 
<br> If you then run

2007年11月30日 (五) 16:40的版本

To build a mirror with debmirror follow these steps

This is not covering all use cases but it will allow you experiment. To do this safely 8.2 gigs of space are needed to mirror main source and binaries. This number grows a lot as time progresses.

Alternative Consideration

If you want to download all the apt binaries for all boxes onto one box on a network then maybe apt-cache or a transparent proxy (eg http-replicator is all you need. Another method is to use rsync. The Rsyncmirror page goes into greater detail on this method. Rsync can create a full mirror of a site and selects files indiscriminately. Debmirror, however, does allow for better control over which packages are mirrored and can be easier on the amount of hard drive space required.

Start The Mirror Build Process

Open gnome-terminal by clicking Applications -> Accessories -> Terminal.
If your sources list has universe enabled, skip the next step.
Open your sources list (sudo sensible-editor /etc/apt/sources.list), and add the following line
deb http://cc.archive.ubuntu.com/ubuntu/ dapper universe
Then save and return to a prompt.
In the example above, cc is your countrys code (eg au means Australia), and dapper is replaced with the release your using. Update the package lists (sudo apt-get update) and then install debmirror (sudo apt-get install debmirror).
Now we have to create a directory to save the files too. The approximate size of the components of the mirror (i386 only) are:

  1. Changes over time.
feisty ~27G main, restricted, universe, multiverse
dapper 15G main, restricted, universe, multiverse

Please ensure where ever you make the mirror has room for the packages you want to download!
(If you are more advanced you can make different parts of the mirror on different volumes, but thats not something for this howto).
We will make our mirror on /home/ with

sudo mkdir /home/UbuntuMirror

Create the file `mirrorbuild.sh`

Now to create `mirrorbuild.sh`
Open your prefered editor thus

sudo sensible-editor /usr/local/bin/mirrorbuild.sh

Copy the text from the box below into the editor.
You may omit the lines starting with # (NB EXCEPTION the line that starts #!/bin/bash must be left in.)

Contents of the mirror script, please adapt it to your needs

#!/bin/bash
# Arch=		-a	# Architecture. For Ubuntu can be i386, powerpc or amd64.
# sparc, only starts in dapper, it is only the later models of sparc
#
arch=i386
# Minimum Ubuntu system requires main, restricted
# Section=	-s	# Section (One of the following - main/restricted/universe/multiverse).
#
section=main,restricted,universe,multiverse
# Release=	-d	# Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired)
#
release=dapper,dapper-security,dapper-updates
# Server=	-h	# Server name, minus the protocol and the path at the end
# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia  ca. in Canada.
# This can be found in your own /etc/apt/sources.list file, assuming you have Ubuntu installed.
#
server=cc.archive.ubuntu.com
# Dir=		-r	# Path from the main server, so http://my.web.server/$dir, Server dependant
#
inPath=/ubuntu
# Proto=	-e	# Protocol to use for transfer (http, ftp, hftp, rsync)
# Choose one - http is most usual the service, and the service must be avaialbe on the server you point at.
#
proto=http
# Outpath=		# Directory to store the mirror in
# Make this a full path to where you want to mirror the material.
#
outPath=/home/UbuntuMirror
# The --nosource option only downloads debs and not deb-src's
# The --progress option shows files as they are downloaded
# --source \ in the place of --no-source \ if you want sources also.
# Start script
#
debmirror	-a $arch \
		--no-source \
		-s $section \
		-h $server \
		-d $release \
		-r $inPath \
		--progress \
		-e $proto \
		$outPath

How to use the file

Save the file and exit. * Now change the permissions and ownership on the mirror. The group name is your username:

sudo chown -R root.username /home/UbuntuMirror
sudo chmod -R 571 /home/UbuntuMirror
  • Set up your keyring to correctly verify Release signatures
gpg --no-default-keyring --keyring trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg

* And the final part of setting up the mirror is to download the files

buildmirror.sh

Now walk away. Your machine has a lot of downloading to do!

Set up the mirror

We need to install Apache2, you could choose apache version 1.3 but that is beyond the scope of this document.
We can do this with `sudo apt-get install apache2`

Then (for simplicity sake) lets make a link from /home/UbuntuMirror to /var/www/ubuntu.

ln -s /home/UbuntuMirror /var/www/ubuntu

This means when you go to download from your mirror, you will visit `http://mirrorbox/ubuntu/`.

Right! So we have all the packages, and a working server. Now we need to set up the clients.

Set up a client system

Open a terminal and enter

cd /etc/apt
sudo mv sources.list sources.list.orig
sudo sensible-editor sources.list

Now in your editor, put the following lines:

# Local network mirror sources.
deb http://mirrorbox/ubuntu dapper main restricted universe multiverse
deb http://mirrorbox/ubuntu dapper-updates main restricted universe multiverse
deb http://mirrorbox/ubuntu dapper-security main restricted universe multiverse

Then save and exit
If you then run

sudo apt-get update
sudo apt-get dist-upgrade

you should be updating from your new server!