[原]ubuntu下制作ubuntu源

时间:2024-04-14 19:29:43

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

配置ubuntu12.04_mirror.sh

 ###########################################################################
## ##
## Ubuntu Mirror Script ##
## ##
## Creation: 06.07. ##
## Last Update: 02.06. ##
## ##
## Copyright (c) - by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
## ##
## 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 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/sh # Ubuntu mirror server and mirror directory
#SOURCE_SRV=cn.archive.ubuntu.com
#SOURCE_SRV=archive.ubuntu.com
SOURCE_SRV=cn.archive.ubuntu.com
SOURCE_DIR=/ubuntu # Distribution, section and architecture list
DIST=precise,precise-security,precise-updates,precise-backports,precise-proposed
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
ARCH=i386,amd64 # Local mirror directory
#MIRRORDIR=/var/ftp/pub/linux/ubuntu/
MIRRORDIR=/home/ubuntu/ # Log file
LOGFILE=/var/log/ubuntu_mirror.log # Debug file (if you do not want to debug the download process set this option to "/dev/null")
DEBUGFILE=/var/log/ubuntu_mirror.debug # Who will be informed in case if anything goes wrong (if you do not want to be informed via mail, set this option to "")
#MAILNOTIFY="root@localhost" # Lock file
LOCK=/var/tmp/ubuntu_mirror.lock ##################################################################
# NORMALY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT #
################################################################## function log()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " LOG:" $ >>${LOGFILE}
} function error()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $ >>${LOGFILE}
if [ -n "$MAILNOTIFY" ] ; then
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $ | mail -s "ERROR while synchronizing Ubuntu" $MAILNOTIFY
fi
echo $ | grep "Lockfile" >/dev/null
if [ $? = ] ; then
rm -f ${LOCK}
fi
exit
} function status()
{
case "$1" in
)
log "Synchronization completed."
;;
)
error "DEBMIRROR: Connection closed"
;;
)
error "DEBMIRROR: Timeout"
;;
*)
error "DEBMIRROR: Unknown error $1"
;;
esac
} if [ -f ${LOCK} ] ; then
error "Lockfile ${LOCK} exists."
fi touch ${LOCK} # Create local mirror directory if not exists
if [ ! -d ${MIRRORDIR} ] ; then
log "Creating local mirror directory."
mkdir -p ${MIRRORDIR}
fi log "Starting Ubuntu download process."
debmirror -v -e http -h ${SOURCE_SRV} -r ${SOURCE_DIR} --ignore-release-gpg --dist=${DIST} --section=${SECTION} --arch=${ARCH} ${MIRRORDIR} >> ${DEBUGFILE} >&
status $? rm -f ${LOCK} exit

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

 deb http://ip/ubuntu/ precise main restricted universe multiverse

 deb-src http://ip/ubuntu/ precise main restricted universe multiverse

 deb http://ip/ubuntu/ precise-updates main restricted universe multiverse

 deb-src http://ip/ubuntu/ precise-updates main restricted universe multiverse

 deb http://ip/ubuntu/ precise-backports main restricted universe multiverse

 deb-src http://ip/ubuntu/ precise-backports main restricted universe multiverse

 deb http://ip/ubuntu/ precise-security main restricted universe multiverse

 deb-src http://ip/ubuntu/ precise-security main restricted universe multiverse

7、测试:

客户端:apt-get update

作者:yuandianlws 发表于2014-1-23 15:29:45 原文链接
阅读:46 评论:0 查看评论