[原]ubuntu下制作ubuntu源

ubuntu下可以用debmirror来下载ubuntu的所有源:

配置ubuntu12.04_mirror.sh

  1 ###########################################################################
  2 ##                                                                       ##
  3 ##                         Ubuntu Mirror Script                          ##
  4 ##                                                                       ##
  5 ## Creation:    06.07.2008                                               ##
  6 ## Last Update: 02.06.2012                                               ##
  7 ##                                                                       ##
  8 ## Copyright (c) 2008-2012 by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
  9 ##                                                                       ##
 10 ## This program is free software; you can redistribute it and/or modify  ##
 11 ## it under the terms of the GNU General Public License as published by  ##
 12 ## the Free Software Foundation; either version 2 of the License, or     ##
 13 ## (at your option) any later version.                                   ##
 14 ##                                                                       ##
 15 ###########################################################################
 16 #!/bin/sh
 17 
 18 # Ubuntu mirror server and mirror directory
 19 #SOURCE_SRV=cn.archive.ubuntu.com
 20 #SOURCE_SRV=archive.ubuntu.com
 21 SOURCE_SRV=cn.archive.ubuntu.com
 22 SOURCE_DIR=/ubuntu
 23 
 24 # Distribution, section and architecture list
 25 DIST=precise,precise-security,precise-updates,precise-backports,precise-proposed
 26 SECTION=main,main/debian-installer,main/i18n,main/dist-upgrader-all,main/installer-amd64,main/installer-i386,main/uefi,restricted,restricted/debian-installer,restricted/i18n,universe,universe/debian-installer,universe/i18n,multiverse,multiverse/debian-installer,multiverse/i18n
 27 ARCH=i386,amd64
 28 
 29 # Local mirror directory
 30 #MIRRORDIR=/var/ftp/pub/linux/ubuntu/
 31 MIRRORDIR=/home/ubuntu/
 32 
 33 # Log file
 34 LOGFILE=/var/log/ubuntu_mirror.log
 35 
 36 # Debug file (if you do not want to debug the download process set this option to "/dev/null")
 37 DEBUGFILE=/var/log/ubuntu_mirror.debug
 38 
 39 # Who will be informed in case if anything goes wrong (if you do not want to be informed via mail, set this option to "")
 40 #MAILNOTIFY="root@localhost"
 41 
 42 # Lock file
 43 LOCK=/var/tmp/ubuntu_mirror.lock
 44 
 45 ##################################################################
 46 # NORMALY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT #
 47 ##################################################################
 48 
 49 function log()
 50   {
 51     echo `date +%d.%m.%Y%t%H:%M:%S` "    LOG:" $1 >>${LOGFILE}
 52   }
 53 
 54 function error()
 55   {
 56     echo `date +%d.%m.%Y%t%H:%M:%S` "    ERROR:" $1 >>${LOGFILE}
 57     if [ -n "$MAILNOTIFY" ] ; then
 58       echo `date +%d.%m.%Y%t%H:%M:%S` "    ERROR:" $1 | mail -s "ERROR while synchronizing Ubuntu" $MAILNOTIFY
 59     fi
 60        echo $1 | grep "Lockfile" >/dev/null
 61     if [ $? = 1 ] ; then
 62       rm -f ${LOCK}
 63     fi
 64     exit 1
 65   }
 66 
 67 function status()
 68   {
 69     case "$1" in
 70       0)
 71         log "Synchronization completed."
 72         ;;
 73       1)
 74         error "DEBMIRROR: Connection closed"
 75         ;;
 76       2)
 77         error "DEBMIRROR: Timeout"
 78         ;;
 79       *)
 80         error "DEBMIRROR: Unknown error $1"
 81         ;;
 82     esac
 83   }
 84 
 85 if [ -f ${LOCK} ] ; then
 86   error "Lockfile ${LOCK} exists."
 87 fi
 88 
 89 touch ${LOCK}
 90 
 91 # Create local mirror directory if not exists
 92 if [ ! -d ${MIRRORDIR} ] ; then
 93   log "Creating local mirror directory."
 94   mkdir -p ${MIRRORDIR}
 95 fi
 96 
 97 log "Starting Ubuntu download process."
 98 debmirror -v -e http -h ${SOURCE_SRV} -r ${SOURCE_DIR} --ignore-release-gpg --dist=${DIST} --section=${SECTION} --arch=${ARCH} ${MIRRORDIR} >> ${DEBUGFILE} 2>&1
 99 status $?
100 
101 rm -f ${LOCK}
102 
103 exit 0           

3、执行脚本,下载ubuntu包:

nohup bash ubuntu12.04_mirror.sh &

下载的包会放在指定的目录中:/home/ubuntu

4、安装apache2:

apt-get install apache2

5、把ubuntu包路径放到apache:

ln -s /home/ubuntu /var/www

6、客户端配置:

mv /etc/apt/source.list /etc/apt/source.list.bak

vim /etc/apt/source.list

 1 deb http://ip/ubuntu/ precise main restricted universe multiverse
 2 
 3 deb-src http://ip/ubuntu/ precise main restricted universe multiverse
 4 
 5 deb http://ip/ubuntu/ precise-updates main restricted universe multiverse
 6 
 7 deb-src http://ip/ubuntu/ precise-updates main restricted universe multiverse
 8 
 9 deb http://ip/ubuntu/ precise-backports main restricted universe multiverse
10 
11 deb-src http://ip/ubuntu/ precise-backports main restricted universe multiverse
12 
13 deb http://ip/ubuntu/ precise-security main restricted universe multiverse
14 
15 deb-src http://ip/ubuntu/ precise-security main restricted universe multiverse

7、测试:

客户端:apt-get update




作者:yuandianlws 发表于2014-1-23 15:29:45 原文链接
阅读:46 评论:0 查看评论
原文地址:https://www.cnblogs.com/yuandianliws/p/3568244.html