特殊:Badtitle/NS100:AptGet/AptOff:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/AptGet/AptOff}} | {{From|https://help.ubuntu.com/community/AptGet/AptOff}} | ||
{{Languages|UbuntuHelp:AptGet/AptOff}} | {{Languages|UbuntuHelp:AptGet/AptOff}} | ||
See also [[AptGet/Offline]] | See also [[UbuntuHelp:AptGet/Offline]] | ||
Compare this to | Compare this to [http://wiki.debian.org/AptMedium apt-medium]. | ||
---- | ---- | ||
Tired for waiting my internet connection, and as many people ask for how to do it, here is a little script to allow the use of apt-get offline. The main advantage is that it doesn't need to have apt on the connected computer (i.e. you can download packages from a rpm-based distribution, for instance). | Tired for waiting my internet connection, and as many people ask for how to do it, here is a little script to allow the use of apt-get offline. The main advantage is that it doesn't need to have apt on the connected computer (i.e. you can download packages from a rpm-based distribution, for instance). |
2008年10月19日 (日) 14:15的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/AptGet/AptOff }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/af | • {{#if: UbuntuHelp:AptGet/AptOff|Afrikaans| [[::AptGet/AptOff/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ar | • {{#if: UbuntuHelp:AptGet/AptOff|العربية| [[::AptGet/AptOff/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/az | • {{#if: UbuntuHelp:AptGet/AptOff|azərbaycanca| [[::AptGet/AptOff/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/bcc | • {{#if: UbuntuHelp:AptGet/AptOff|جهلسری بلوچی| [[::AptGet/AptOff/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/bg | • {{#if: UbuntuHelp:AptGet/AptOff|български| [[::AptGet/AptOff/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/br | • {{#if: UbuntuHelp:AptGet/AptOff|brezhoneg| [[::AptGet/AptOff/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ca | • {{#if: UbuntuHelp:AptGet/AptOff|català| [[::AptGet/AptOff/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/cs | • {{#if: UbuntuHelp:AptGet/AptOff|čeština| [[::AptGet/AptOff/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/de | • {{#if: UbuntuHelp:AptGet/AptOff|Deutsch| [[::AptGet/AptOff/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/el | • {{#if: UbuntuHelp:AptGet/AptOff|Ελληνικά| [[::AptGet/AptOff/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/es | • {{#if: UbuntuHelp:AptGet/AptOff|español| [[::AptGet/AptOff/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/fa | • {{#if: UbuntuHelp:AptGet/AptOff|فارسی| [[::AptGet/AptOff/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/fi | • {{#if: UbuntuHelp:AptGet/AptOff|suomi| [[::AptGet/AptOff/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/fr | • {{#if: UbuntuHelp:AptGet/AptOff|français| [[::AptGet/AptOff/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/gu | • {{#if: UbuntuHelp:AptGet/AptOff|ગુજરાતી| [[::AptGet/AptOff/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/he | • {{#if: UbuntuHelp:AptGet/AptOff|עברית| [[::AptGet/AptOff/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/hu | • {{#if: UbuntuHelp:AptGet/AptOff|magyar| [[::AptGet/AptOff/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/id | • {{#if: UbuntuHelp:AptGet/AptOff|Bahasa Indonesia| [[::AptGet/AptOff/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/it | • {{#if: UbuntuHelp:AptGet/AptOff|italiano| [[::AptGet/AptOff/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ja | • {{#if: UbuntuHelp:AptGet/AptOff|日本語| [[::AptGet/AptOff/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ko | • {{#if: UbuntuHelp:AptGet/AptOff|한국어| [[::AptGet/AptOff/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ksh | • {{#if: UbuntuHelp:AptGet/AptOff|Ripoarisch| [[::AptGet/AptOff/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/mr | • {{#if: UbuntuHelp:AptGet/AptOff|मराठी| [[::AptGet/AptOff/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ms | • {{#if: UbuntuHelp:AptGet/AptOff|Bahasa Melayu| [[::AptGet/AptOff/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/nl | • {{#if: UbuntuHelp:AptGet/AptOff|Nederlands| [[::AptGet/AptOff/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/no | • {{#if: UbuntuHelp:AptGet/AptOff|norsk| [[::AptGet/AptOff/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/oc | • {{#if: UbuntuHelp:AptGet/AptOff|occitan| [[::AptGet/AptOff/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/pl | • {{#if: UbuntuHelp:AptGet/AptOff|polski| [[::AptGet/AptOff/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/pt | • {{#if: UbuntuHelp:AptGet/AptOff|português| [[::AptGet/AptOff/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ro | • {{#if: UbuntuHelp:AptGet/AptOff|română| [[::AptGet/AptOff/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/ru | • {{#if: UbuntuHelp:AptGet/AptOff|русский| [[::AptGet/AptOff/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/si | • {{#if: UbuntuHelp:AptGet/AptOff|සිංහල| [[::AptGet/AptOff/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/sq | • {{#if: UbuntuHelp:AptGet/AptOff|shqip| [[::AptGet/AptOff/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/sr | • {{#if: UbuntuHelp:AptGet/AptOff|српски / srpski| [[::AptGet/AptOff/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/sv | • {{#if: UbuntuHelp:AptGet/AptOff|svenska| [[::AptGet/AptOff/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/th | • {{#if: UbuntuHelp:AptGet/AptOff|ไทย| [[::AptGet/AptOff/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/tr | • {{#if: UbuntuHelp:AptGet/AptOff|Türkçe| [[::AptGet/AptOff/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/vi | • {{#if: UbuntuHelp:AptGet/AptOff|Tiếng Việt| [[::AptGet/AptOff/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/yue | • {{#if: UbuntuHelp:AptGet/AptOff|粵語| [[::AptGet/AptOff/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/zh | • {{#if: UbuntuHelp:AptGet/AptOff|中文| [[::AptGet/AptOff/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/zh-hans | • {{#if: UbuntuHelp:AptGet/AptOff|中文(简体)| [[::AptGet/AptOff/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AptGet/AptOff | UbuntuHelp:AptGet/AptOff | {{#if: | :}}AptGet/AptOff}}/zh-hant | • {{#if: UbuntuHelp:AptGet/AptOff|中文(繁體)| [[::AptGet/AptOff/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:AptGet/AptOff|:AptGet/AptOff|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :AptGet/AptOff/zh | | {{#ifexist: AptGet/AptOff/zh | | {{#ifeq: {{#titleparts:AptGet/AptOff|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:AptGet/AptOff|1|-1|}} | zh | | }}
See also UbuntuHelp:AptGet/Offline Compare this to apt-medium.
Tired for waiting my internet connection, and as many people ask for how to do it, here is a little script to allow the use of apt-get offline. The main advantage is that it doesn't need to have apt on the connected computer (i.e. you can download packages from a rpm-based distribution, for instance). Here it is, just copy this code in your favorite text editor, save it as apt-off on your usb flash/hard drive (or any other kind of mobile disk) and make it executable by typing chmod +x apt-off in a terminal.
#!/bin/bash # # Copyright 2006, Goulven Guillard. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA BOLD="\\033[1;39m" NORMAL="\\033[0;39m" GREEN="\\033[32m" RED="\\033[31m" PINK="\\033[35m" BLUE="\\033[34m" if [[ $1 == -h || $1 == --help ]]; then echo -e "\\033[2J\\033[0;0f$BOLD$BLUE""NAME"$NORMAL echo -e "\tapt-off\n" echo -e $BOLD$BLUE"SYNOPSIS"$NORMAL echo -e $GREEN"\tapt-off [option] [packages/dist-upgrade]\n"$NORMAL echo -e $BOLD$BLUE"DESCRIPTION"$NORMAL echo -e "\t$GREEN""apt-off$NORMAL is a script designed to allow the use of the apt tool on a" echo -e "\tcomputer without any network connection. It proceeds in three steps," echo -e "\twhich must be done in the directory containing the apt-off file :" echo -e "\t1- packages selection (option -g)" echo -e "\t2- packages download (option -d); this step has to be done on a Linux" echo -e "\tsystem computer (it$BOLD does not need$NORMAL apt, but uses$GREEN wget$NORMAL ; if you only" echo -e "\thave access to a Windows system, you should uncomment one of the two" echo -e "\tdedicated lines at the end of the apt-off file and download all the" echo -e "\tpackages listed in the $GREEN""offline.packages_url$NORMAL or in the" echo -e "\t$GREEN""offline.packages_list$NORMAL files by hand...) with an internet connection" echo -e "\t3- packages installation (option -x)\n" echo -e $BOLD$BLUE"WARNING"$NORMAL echo -e $BOLD$RED"\tCAUTION :$NORMAL the installation of packages and the use of the dist-upgrade" echo -e "\toption can pose some risks. You are strongly encouraged to" echo -e "\tsimulate these operations with apt-get before to use apt-off." echo -e "\tThe author cannot be considered as responseable for any problem.\n" fi if [[ $1 == -h || $1 == --help || $1 == -o || $1 == --options ]]; then echo -e $BOLD$BLUE"OPTIONS"$NORMAL echo -e $GREEN"\t-c$NORMAL ou$GREEN --configure$NORMAL" echo -e "\tDownload apt configuration files.\n" echo -e $GREEN"\t-d$NORMAL ou$GREEN --download$NORMAL" echo -e "\tDownload packages. This option has to be used on a Linux system" echo -e "\twith an internet connection.$BOLD$RED Don't forget the offline.packages" echo -e "\tfile !!!$NORMAL\n" echo -e $GREEN"\t-g$NORMAL or$GREEN --generate$BLUE [package1 package2 ...]$NORMAL or$BLUE [dist-upgrade]$NORMAL" echo -e "\tGenerate packages list, stored in the $BLUE offline.packages$NORMAL file.\n" echo -e $GREEN"\t-h$NORMAL or$GREEN --help"$NORMAL echo -e "\tPrint this help.\n" echo -e $GREEN"\t-o$NORMAL or$GREEN --options$NORMAL" echo -e "\tDisplay options.\n" echo -e $GREEN"\t-x$NORMAL or$GREEN --extract$BLUE [package1 package2 ...]$NORMAL or$BLUE [dist-upgrade]$NORMAL" echo -e "\tExtract and install packages.\n" if [[ $1 == -h || $1 == --help ]]; then echo -e $BOLD$BLUE"COPYRIGHT"$NORMAL echo -e "\tCopyright 2006, Goulven Guillard." echo -e "\tThis program is copyleft : copy, modification and diffusion are" echo -e "\tauthorized and encouraged if they are free." echo -e "\tPlease report bugs at$BLUE lecotegougdelaforce [at] free.fr$NORMAL.\n" fi elif [[ $1 == -c || $1 == --configure ]]; then if [[ -e config_files/config_apt ]]; then cd config_files sh -x ./config_apt cd .. else echo -e "You didn't execute$GREEN apt-off -p$NORMAL yet, or you have deleted the$VERT config_files$NORMAL directory and the$VERT config_apt$NORMAL file there was in it... Please restart all the procedure." fi elif [[ $1 == -g || $1 == --generate ]]; then if [[ `ls /var/lib/apt/lists/ | grep binary-i386_Packages | wc -l` == 0 ]]; then if [[ ! -e config_files ]]; then mkdir config_files awk '($1=="deb"||$1=="deb-src")&&!match($2,"cdrom"){split($2,A,"/");for(i=4;i<=NF;++i) print "wget -O "A[3]"_"A[4]"_dists_"$3"_"$i"_binary-i386_Packages.gz "$2"dists/"$3"/"$i"/binary-i386/Packages.gz"}' < /etc/apt/sources.list > config_files/config_apt echo -e "WARNING : Your computer isn't correctly configured in order to use the apt tool." echo -e "This program will configure it for you. You now have to execute the$VERT apt-off -c$NORMAL" echo -e "command on a computer with an internet connexion. The configuration will end" echo -e "automatically next time you will use apt-off." exit elif [[ `ls config_files | grep gz | wc -l` > 0 ]]; then sudo cp config_files/*.gz /var/lib/apt/lists/ sudo gunzip /var/lib/apt/lists/*.gz else echo -e "Vous devez d'abord exécuter$VERT apt-off -c$NORMAL sur un ordinateur avec internet !" exit fi fi if [[ -e offline.packages ]]; then echo "WARNING : The offline.packages file already exists, do you want to overwrite it (if not, the packages will be added to the existing list) ? (y/n)" read OVERWRITE fi if [[ $OVERWRITE == y ]]; then echo "cd ./deb" > offline.packages else echo "cd ./deb" >> offline.packages fi if [[ "$#" < 2 ]]; then echo "WARNING : You have to indicate which packages you want to install," echo "or \"dist-upgrade\" !!!" exit elif [[ $2 == dist-upgrade ]]; then sudo apt-get -qq --print-uris dist-upgrade > .offline_tmp else for ((i=2; i<="$#"; i++ )) do sudo apt-get -qq --print-uris install ${!i} >> .offline_tmp done fi awk '{print "wget -O " $2 " " $1}' < .offline_tmp >> offline.packages echo "cd .." >> offline.packages # awk '{print $1}' < .offline_tmp >> offline.packages_url # awk '{print $2}' < .offline_tmp >> offline.packages_list rm -f .offline_tmp elif [[ $1 == -d || $1 == --download ]]; then if [[ ! -e deb ]]; then mkdir deb fi sh -x ./offline.packages elif [[ $1 == -x || $1 == --extract ]]; then if [[ ! -e deb/partial ]]; then PARTIAL_CREATED=true mkdir deb/partial else PARTIAL_CREATED=false fi if [[ "$#" < 2 ]]; then echo "WARNING : You have to indicate which packages you want to install, or \"dist-upgrade\" !" exit elif [[ $2 == dist-upgrade ]]; then sudo apt-get -o dir::cache::archives=$PWD/deb/ dist-upgrade else for ((i=2; i<="$#"; i++ )) do sudo apt-get -o dir::cache::archives=$PWD/deb/ install ${!i} done fi if [[ PARTIAL_CREATED ]]; then rm -rf deb/partial fi else ./apt-off -o fi