Ubuntu软件源配置

参考

ubuntu下的apt-get内网本地源的搭建
Ubuntu的apt-get本地源搭配——根据需要自己添加软件作源
ubuntu16.04 自建源
ubuntu局域网apt-get源搭建
ubuntu下安装程序的三种方法

手动安装deb包

安装和安装所有软件包,

# sudo dpkg -i package.deb
# sudo dpkg -i *.deb

配置阿里源

jj@jj-ProLiant-DL388-Gen9:~$ sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
jj@jj-ProLiant-DL388-Gen9:~$ lsb_release -c
Codename:	xenial
jj@jj-ProLiant-DL388-Gen9:~$ sudo gedit /etc/apt/sources.list

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
#deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
#deb http://archive.canonical.com/ubuntu xenial partner
#deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
	
jj@jj-ProLiant-DL388-Gen9:~$ sudo apt-get update

利用apt-get缓存建立本地源

安装dpkg-dev,apache2,查看本地源,

j2@j2-pc:~$ sudo apt-get install dpkg-dev apache2
j2@j2-pc:~$ ls /var/cache/apt/archives
apache2_2.4.18-2ubuntu3.9_amd64.deb        libaprutil1_1.5.4-1build1_amd64.deb              partial
apache2-bin_2.4.18-2ubuntu3.9_amd64.deb    libaprutil1-dbd-sqlite3_1.5.4-1build1_amd64.deb  tftpd-hpa_5.2+20150808-1ubuntu1.16.04.1_amd64.deb
apache2-data_2.4.18-2ubuntu3.9_all.deb     libaprutil1-ldap_1.5.4-1build1_amd64.deb         tftp-hpa_5.2+20150808-1ubuntu1.16.04.1_amd64.deb
apache2-utils_2.4.18-2ubuntu3.9_amd64.deb  libdpkg-perl_1.18.4ubuntu1.5_all.deb             xinetd_1%3a2.3.15-6_amd64.deb
dpkg-dev_1.18.4ubuntu1.5_all.deb           liblua5.1-0_5.1.5-8ubuntu1_amd64.deb
libapr1_1.5.2-3_amd64.deb                  lock

建立源,

j2@j2-pc:~$ sudo mkdir /var/www/html/soft
j2@j2-pc:~$ sudo mkdir /var/www/html/dists
j2@j2-pc:~$ sudo mkdir /var/www/html/dists/zc
j2@j2-pc:~$ sudo mkdir /var/www/html/dists/zc/main
j2@j2-pc:~$ sudo mkdir /var/www/html/dists/zc/main/binary-i386
j2@j2-pc:~$ sudo mkdir /var/www/html/dists/zc/main/binary-amd64

j2@j2-pc:~$ cd /var/www/html
j2@j2-pc:/var/www/html$ sudo chmod -Rf a+w dists
j2@j2-pc:/var/www/html$ sudo chmod -Rf a+w soft 

j2@j2-pc:/var/www/html$ cp /var/cache/apt/archives/*.deb /var/www/html/soft 
j2@j2-pc:/var/www/html$ awk 'BEGIN { cmd="cp -vri /var/cache/apt/archives/*.deb /var/www/html/soft"; print "n" |cmd; }'

j2@j2-pc:/var/www/html$ dpkg-scanpackages /var/www/html/soft/ /dev/null | gzip > /var/www/html/dists/zc/main/binary-i386/Packages.gz
dpkg-scanpackages: 警告: Packages in archive but missing from override file:
dpkg-scanpackages: 警告:   apache2 apache2-bin apache2-data apache2-utils dpkg-dev libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdpkg-perl liblua5.1-0 tftp-hpa tftpd-hpa xinetd
dpkg-scanpackages: info: Wrote 14 entries to output Packages file.
j2@j2-pc:/var/www/html$ dpkg-scanpackages /var/www/html/soft/ /dev/null | gzip > /var/www/html/dists/zc/main/binary-amd64/Packages.gz
dpkg-scanpackages: 警告: Packages in archive but missing from override file:
dpkg-scanpackages: 警告:   apache2 apache2-bin apache2-data apache2-utils dpkg-dev libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdpkg-perl liblua5.1-0 tftp-hpa tftpd-hpa xinetd
dpkg-scanpackages: info: Wrote 14 entries to output Packages file.

j2@j2-pc:~/develop$ cat update_deb.sh 
#!/bin/sh

awk 'BEGIN { cmd="cp -vri /var/cache/apt/archives/*.deb /var/www/html/soft/"; print "n" |cmd; }'
dpkg-scanpackages /var/www/html/soft/ /dev/null | gzip > /var/www/html/dists/zc/main/binary-i386/Packages.gz
dpkg-scanpackages /var/www/html/soft/ /dev/null | gzip > /var/www/html/dists/zc/main/binary-amd64/Packages.gz

dpkg-scanpackages packages/ | gzip > packages/Packages.gz

在座的各位都是垃圾,来看看,不用压缩,压缩了ubuntu16.04反而不识别,一定是这个目录/var/www/html,不用麻烦,

j2@j2-pc:/var/www/html$ sudo mkdir packages
j2@j2-pc:/var/www/html$ sudo mv soft/* packages/
j2@j2-pc:/var/www/html$ dpkg-scanpackages packages > packages/Packages
dpkg-scanpackages: info: Wrote 183 entries to output Packages file.
j2@j2-pc:~$ cat develop/update_deb.sh 
#!/bin/sh

cur_path=$(pwd)
awk 'BEGIN { cmd="cp -vri /var/cache/apt/archives/*.deb /var/www/html/packages"; print "n" |cmd; }'
cd /var/www/html
dpkg-scanpackages packages > packages/Packages
dpkg-scanpackages packages | gzip > packages/Packages.gz
cd $cur_path

客户端配置

编辑/etc/apt/sources.list,

deb http://192.168.6.81 packages/
deb http://127.0.0.1 packages/
jj@jj-ProLiant-DL388-Gen9:~$ sudo apt-get update

你可能感兴趣的:(编程工具)