mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
ubuntu-cd/sync: cleaned up error handling, variable safety, and readability
This commit is contained in:
parent
35391d572c
commit
4f74d71a39
46
ubuntu-cd
46
ubuntu-cd
@ -1,26 +1,40 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
# Get the latest CD snapshot release.
|
# Get the latest CD snapshot release.
|
||||||
Distro=$1
|
Distro="$1"
|
||||||
Ver=gutsy
|
if [ -z "$Distro" ]; then
|
||||||
|
echo "Which distro?" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Release="$2"
|
||||||
|
if [ -z "$Release" ]; then
|
||||||
|
echo "Which ISO release?" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Ver=gutsy
|
||||||
Code=tribe
|
Code=tribe
|
||||||
|
|
||||||
cd ~/distros/ubuntu/${Distro}/${Ver}
|
cd ~/distros/ubuntu/"${Distro}"/"${Ver}"
|
||||||
mkdir -p ${Code}-$2
|
mkdir -p "${Code}"-"${Release}"
|
||||||
cd ${Code}-$2
|
cd "${Code}"-"${Release}"
|
||||||
|
|
||||||
cp ../*.iso .
|
cp ../*.iso . || true
|
||||||
|
|
||||||
if [ "${Distro}" == "ubuntu" ]; then
|
if [ "${Distro}" == "ubuntu" ]; then
|
||||||
rsync rsync://cdimage.ubuntu.com/cdimage/releases/${Ver}/${Code}-$2/${Ver}-alternate-i386.iso ${Ver}-alternate-i386.iso
|
Origin="releases"
|
||||||
rsync rsync://cdimage.ubuntu.com/cdimage/releases/${Ver}/${Code}-$2/${Ver}-desktop-i386.iso ${Ver}-desktop-i386.iso
|
Flavors="alternate desktop server"
|
||||||
#rsync rsync://cdimage.ubuntu.com/cdimage/releases/${Ver}/${Code}-$2/${Ver}-server-i386.iso ${Ver}-server-i386.iso
|
Archs="i386"
|
||||||
#rsync rsync://cdimage.ubuntu.com/cdimage/releases/${Ver}/${Code}-$2/${Ver}-alternate-amd64.iso ${Ver}-alternate-amd64.iso
|
#Archs="i386 amd64 powerpc"
|
||||||
#rsync rsync://cdimage.ubuntu.com/cdimage/releases/${Ver}/${Code}-$2/${Ver}-desktop-amd64.iso ${Ver}-desktop-amd64.iso
|
|
||||||
#rsync rsync://cdimage.ubuntu.com/cdimage/releases/${Ver}/${Code}-$2/${Ver}-server-amd64.iso ${Ver}-server-amd64.iso
|
|
||||||
else
|
else
|
||||||
rsync rsync://cdimage.ubuntu.com/cdimage/${Distro}/releases/${Ver}/${Code}-$2/${Ver}-alternate-i386.iso ${Ver}-alternate-i386.iso
|
Origin="${Distro}/releases"
|
||||||
rsync rsync://cdimage.ubuntu.com/cdimage/${Distro}/releases/${Ver}/${Code}-$2/${Ver}-desktop-i386.iso ${Ver}-desktop-i386.iso
|
Flavors="alternate desktop"
|
||||||
#rsync rsync://cdimage.ubuntu.com/cdimage/${Distro}/releases/${Ver}/${Code}-$2/${Ver}-alternate-amd64.iso ${Ver}-alternate-amd64.iso
|
Archs="i386"
|
||||||
#rsync rsync://cdimage.ubuntu.com/cdimage/${Distro}/releases/${Ver}/${Code}-$2/${Ver}-desktop-amd64.iso ${Ver}-desktop-amd64.iso
|
#Archs="i386 amd64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for arch in $Archs; do
|
||||||
|
for flavor in $Flavors; do
|
||||||
|
rsync "rsync://cdimage.ubuntu.com/cdimage/${Origin}/${Ver}/${Code}-${Release}/${Ver}-${flavor}-${arch}.iso" "${Ver}-${flavor}-${arch}.iso"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
86
ubuntu-sync
86
ubuntu-sync
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
# Syncronise new ubuntu CD images, depending on command-line flags given.
|
# Syncronise new ubuntu CD images, depending on command-line flags given.
|
||||||
# If none are given, sync all images.
|
# If none are given, sync all images.
|
||||||
@ -8,44 +9,40 @@ if [ -e /tmp/ubuntu-sync.01532-lock ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Ubuntu_Distro_Dir=$HOME/distros/ubuntu
|
Ubuntu_Distro_Dir="$HOME/distros/ubuntu"
|
||||||
Dist=gutsy
|
Dist=gutsy
|
||||||
|
|
||||||
# Only sync the oldest images, and only i386 images if low bandwidth.
|
# Only sync the oldest images, and only i386 images if low bandwidth.
|
||||||
Low_Bandwidth=1
|
Low_Bandwidth=1
|
||||||
|
|
||||||
while [ "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-u)
|
-u)
|
||||||
Image_Sets="${Image_Sets} ubuntu"
|
Image_Sets="${Image_Sets} ubuntu"
|
||||||
shift 1
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
-k)
|
-k)
|
||||||
Image_Sets="${Image_Sets} kubuntu"
|
Image_Sets="${Image_Sets} kubuntu"
|
||||||
shift 1
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
-e)
|
-e)
|
||||||
Image_Sets="${Image_Sets} edubuntu"
|
Image_Sets="${Image_Sets} edubuntu"
|
||||||
shift 1
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
-x)
|
-x)
|
||||||
Image_Sets="${Image_Sets} xubuntu"
|
Image_Sets="${Image_Sets} xubuntu"
|
||||||
shift 1
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
-s)
|
-s)
|
||||||
Image_Sets="${Image_Sets} ubuntu-server"
|
Image_Sets="${Image_Sets} ubuntu-server"
|
||||||
shift 1
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
shift || true
|
||||||
done
|
done
|
||||||
if [ "${Low_Bandwidth}" == 1 ] && [ "${Image_Sets}" == "" ]; then
|
if [ "${Low_Bandwidth}" == 1 ] && [ "${Image_Sets}" == "" ]; then
|
||||||
cd ${Ubuntu_Distro_Dir}
|
cd "${Ubuntu_Distro_Dir}"
|
||||||
Image_Sets=`ls -td1 */${Dist} | tail -1 | cut -f 1 -d /`
|
Image_Sets=`ls -td1 */"${Dist}" | tail -1 | cut -f 1 -d /`
|
||||||
elif [ "${Low_Bandwidth}" == 0 ] && [ "${Image_Sets}" == "" ]; then
|
elif [ "${Low_Bandwidth}" == 0 ] && [ "${Image_Sets}" == "" ]; then
|
||||||
Image_Sets="ubuntu xubuntu ubuntu-server edubuntu kubuntu"
|
Image_Sets="ubuntu xubuntu ubuntu-server edubuntu kubuntu"
|
||||||
fi
|
fi
|
||||||
@ -56,48 +53,39 @@ if [ ! -e /tmp/ubuntu-sync.01532-lock ]; then
|
|||||||
fi
|
fi
|
||||||
for Current_Set in ${Image_Sets}
|
for Current_Set in ${Image_Sets}
|
||||||
do
|
do
|
||||||
cd ${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}
|
mkdir -p "${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}"/.partial
|
||||||
Rsync_Options="--partial-dir=${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}/.partial"
|
cd "${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}"
|
||||||
|
|
||||||
|
# Figure out remote path
|
||||||
if [ "${Current_Set}" == "ubuntu" ]; then
|
if [ "${Current_Set}" == "ubuntu" ]; then
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/daily/current/${Dist}-alternate-i386.iso ${Dist}-alternate-i386.iso ; then
|
Origin=""
|
||||||
date > alternate-i386-sync
|
|
||||||
fi
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/daily-live/current/${Dist}-desktop-i386.iso ${Dist}-desktop-i386.iso ; then
|
|
||||||
date > desktop-i386-sync
|
|
||||||
fi
|
|
||||||
if [ "${Low_Bandwidth}" == 0 ]; then
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/ports/daily/current/${Dist}-alternate-powerpc.iso ${Dist}-alternate-powerpc.iso ; then
|
|
||||||
date > alternate-powerpc-sync
|
|
||||||
fi
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/ports/daily-live/current/${Dist}-desktop-powerpc.iso ${Dist}-desktop-powerpc.iso ; then
|
|
||||||
date > desktop-powerpc-sync
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [ "${Current_Set}" == "edubuntu" ]; then
|
Origin="${Current_Set}"
|
||||||
Install=install
|
|
||||||
Live=live
|
|
||||||
elif [ "${Current_Set}" == "ubuntu-server" ]; then
|
|
||||||
Install=server
|
|
||||||
Live=live
|
|
||||||
else
|
|
||||||
Install=alternate
|
|
||||||
Live=desktop
|
|
||||||
fi
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/${Current_Set}/daily/current/${Dist}-${Install}-i386.iso ${Dist}-${Install}-i386.iso ; then
|
|
||||||
date > ${Install}-i386-sync
|
|
||||||
fi
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/${Current_Set}/daily-live/current/${Dist}-${Live}-i386.iso ${Dist}-${Live}-i386.iso ; then
|
|
||||||
date > ${Live}-i386-sync
|
|
||||||
fi
|
|
||||||
if [ "${Low_Bandwidth}" == 0 ]; then
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/${Current_Set}/daily/current/${Dist}-${Install}-powerpc.iso ${Dist}-${Install}-powerpc.iso ; then
|
|
||||||
date > ${Install}-powerpc-sync
|
|
||||||
fi
|
|
||||||
if rsync ${Rsync_Options} rsync://cdimage.ubuntu.com/cdimage/${Current_Set}/daily-live/current/${Dist}-${Live}-powerpc.iso ${Dist}-${Live}-powerpc.iso ; then
|
|
||||||
date > ${Live}-powerpc-sync
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Which flavors to download
|
||||||
|
if [ "${Current_Set}" == "edubuntu" ]; then
|
||||||
|
Flavors="install live"
|
||||||
|
elif [ "${Current_Set}" == "ubuntu-server" ]; then
|
||||||
|
Flavors="server live"
|
||||||
|
else
|
||||||
|
Flavors="alternate desktop"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Which archs to download
|
||||||
|
if [ "${Low_Bandwidth}" == 0 ]; then
|
||||||
|
Archs="i386 powerpc"
|
||||||
|
#Archs="i386 amd64 powerpc"
|
||||||
|
else
|
||||||
|
Archs="i386"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for arch in $Archs; do
|
||||||
|
for flavor in $Flavors; do
|
||||||
|
if rsync --partial-dir="${Ubuntu_Distro_Dir}/${Current_Set}/${Dist}/.partial" "rsync://cdimage.ubuntu.com/cdimage/${Origin}/daily/current/${Dist}-${flavor}-${arch}.iso" "${Dist}-${flavor}-${arch}.iso" ; then
|
||||||
|
date > "${flavor}-${arch}-sync"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
done
|
done
|
||||||
rm /tmp/ubuntu-sync.01532-lock
|
rm /tmp/ubuntu-sync.01532-lock
|
||||||
|
Loading…
x
Reference in New Issue
Block a user