<div dir="ltr">Hi all,<br><br>I'm using Debian, I want to make a local repository which can let me <br>install packages more conveniently.<br><br>Considering that the rsync tool is the Debian official proposed tool for <br>syncing the files among its different rsync server sites, I use the rsync <br>client to downloading the deb packages from the different rsync servers <br>distributed around the world-wide for good loadbalancing and high <br>efficiency.<br><br>The steps are as follows:<br><br>1- Make the packages list file to be downloaded based on the Packages.gz <br>files for the corresponding OS distribution and architecture, say, for <br>testing, i.e., coded name by jessie and the amd64 architecture, the <br>following files can be use for extracting the packages list information:<br><br><a href="https://mirrors.ustc.edu.cn/debian/dists/jessie/main/binary-amd64/">https://mirrors.ustc.edu.cn/debian/dists/jessie/main/binary-amd64/</a><br>Packages.gz<br><a href="https://mirrors.ustc.edu.cn/debian/dists/jessie/main/binary-all/">https://mirrors.ustc.edu.cn/debian/dists/jessie/main/binary-all/</a><br>Packages.gz<br><a href="https://mirrors.ustc.edu.cn/debian/dists/jessie/contrib/binary-amd64/">https://mirrors.ustc.edu.cn/debian/dists/jessie/contrib/binary-amd64/</a><br>Packages.gz<br><a href="https://mirrors.ustc.edu.cn/debian/dists/jessie/contrib/binary-all/">https://mirrors.ustc.edu.cn/debian/dists/jessie/contrib/binary-all/</a><br>Packages.gz<br><a href="https://mirrors.ustc.edu.cn/debian/dists/jessie/non-free/binary-amd64/">https://mirrors.ustc.edu.cn/debian/dists/jessie/non-free/binary-amd64/</a><br>Packages.gz<br><a href="https://mirrors.ustc.edu.cn/debian/dists/jessie/non-free/binary-all/">https://mirrors.ustc.edu.cn/debian/dists/jessie/non-free/binary-all/</a><br>Packages.gz<br><br>After I've downloaded all of the above files,  then use the following <br>command for extract the deb packages filenmaes list:<br><br>find /path/to/Packages.gz -type f -name Packages.gz -exec zcat \{\} + | <br>awk '/^Filename:/{ print $2  } ' > deb-file.list<br><br>At this point, the deb-file.list will contain a great number of lines <br>like the following:<br><br>----------<br>[snipped]<br>pool/main/m/mockobjects/libmockobjects-java-doc_0.09-5_all.deb<br>pool/main/s/subtitleeditor/subtitleeditor_0.33.0-3_amd64.deb<br>pool/main/h/haskell-hgl/libghc-hgl-prof_3.2.0.5-1_amd64.deb<br>pool/main/l/lsh-utils/lsh-doc_2.1-5_all.deb<br>pool/main/liba/libav/libswscale3_11.3-1_i386.deb<br>pool/main/s/smokeqt/libsmokeqtuitools4-3_4.12.2-2_amd64.deb<br>pool/main/libo/libotf/libotf0-dbg_0.9.13-2_amd64.deb<br>[snipped]<br>----------<br><br>2- Secondly, I obtain the list for all of the available rsync servers <br>supplied by Debian official and other open-source sites from here:<br><br><a href="https://www.debian.org/CD/mirroring/rsync-mirrors">https://www.debian.org/CD/mirroring/rsync-mirrors</a><br><br>Note, though the above site say these rsync-mirrors are for Debian CD <br>images, in fact, most of them are also have the non-cd sections of Debian <br>repository.  So, I can use them for my purpose without any care.<br><br>At this stage, I make the rsync-mirrors for my purpose as follows:<br><br>curl <a href="https://www.debian.org/CD/mirroring/rsync-mirrors">https://www.debian.org/CD/mirroring/rsync-mirrors</a> 2>/dev/null |awk <br>'/::debian-cd\//{gsub(/debian-cd/,"debian",$NF) ; split($NF,a,"<"); print <br>a[1] }' > mirrors.list<br><br>The content of the mirrors.list looks like the following:<br><br>----------------<br>[snipped]<br>debian.mirror.digitalpacific.com.au::debian-cd/<br>mirror.as24220.net::debian-cd/<br>mirror.intrapower.net.au::debian-cd/<br>mirror.rackcentral.com.au::debian-cd/<br>debian.anexia.at::debian-cd/<br>debian.sil.at::debian-cd/<br>[snipped]<br>----------------<br><br>Currently, I obtain 94 available rsync servers by using the above method <br>which are exactly the content of the file mirrors.list.<br><br>3- Finally, I use the powerful rsync tool to downloading all of these deb <br>files listed in deb-file.list by using all of the rsync servers stored in <br>the mirrors.list.  Considering that the bandwidth and maxconnections <br>limit    imposed by these servers' webmasters -- which are the fact for <br>most of these servers, I want only download one deb file from each of <br>these rsync servers at the same time.  And after the downloading finished <br>for the specific rsync server, than let rsync read in the next deb file <br>from the deb-file.list.  Again and again, till all of the deb files been <br>downloaded successfully by parallely using all of these rsync servers.<br><br>For the above purpose, I must use a script to do it.  I've tried the <br>following one which I struggling for sometime to get it, but it cann't meet all of the above requirements.  In fact it has a great distance from achieving the requirements I <br>posted in the above step 3:<br><br>-------------------<br> mirror=1<br> <br> while read -r -a line <br> do <br> mirror_used=`awk 'NR=='"$mirror"'' mirrors.list`<br> rsync -amH --progress --append-verify --timeout=10 --contimeout=5 \<br> ${mirror_used} ${line[0]} debs/ &<br> mirror=$[mirror+1]<br> done < deb-file.list<br> <br> wait <br>-------------------<br><br>Any hints for this issue?<br><br>Regards<br>-- <br><div class="gmail_signature">Hongyi Zhao <<a href="mailto:hongyi.zhao@gmail.com">hongyi.zhao@gmail.com</a>> <br>Xinjiang Technical Institute of Physics and Chemistry<br>Chinese Academy of Sciences <br>GnuPG DSA: 0xD108493</div>
</div>