[lxc-devel] [PATCH] lxc-ubuntu-cloud: various small changes

Stéphane Graber stgraber at ubuntu.com
Thu Jan 30 09:41:13 UTC 2014


On Wed, Jan 29, 2014 at 02:37:03PM -0500, Scott Moser wrote:
>  * ppc64el images now exist and generally function.
>    Instead of failing because an arch isnt in the list,
>    let that check happen by ability to download something.
>  * update the hard coded ubuntu releases to know about 'trusty'
>  * shorten the logic that decides if host and container arch
>    are supported.
>  * update usage to reference 'tryreleased' as the default 'stream'
>  * give good error message if user tries 'released' and there
>    is no released version available.
> 
> Signed-off-by: Scott Moser <smoser at ubuntu.com>
> ---
>  templates/lxc-ubuntu-cloud.in | 42 ++++++++++++++----------------------------
>  1 file changed, 14 insertions(+), 28 deletions(-)
> 
> diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
> index 42ee563..9f8cb95 100644
> --- a/templates/lxc-ubuntu-cloud.in
> +++ b/templates/lxc-ubuntu-cloud.in
> @@ -25,6 +25,7 @@ STATE_DIR="@LOCALSTATEDIR@"
>  HOOK_DIR="@LXCHOOKDIR@"
>  CLONE_HOOK_FN="$HOOK_DIR/ubuntu-cloud-prep"
>  LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
> +KNOWN_RELEASES="lucid natty oneiric precise quantal raring saucy trusty"

Let's drop natty, oneiric and raring from there, they aren't supported anymore.

>  
>  if [ -r /etc/default/lxc ]; then
>      . /etc/default/lxc
> @@ -136,7 +137,7 @@ Generic Options
>  [ -a | --arch ]: Architecture of container, defaults to host architecture
>  [ -T | --tarball ]: Location of tarball
>  [ -d | --debug ]: Run with 'set -x' to debug errors
> -[ -s | --stream]: Use specified stream rather than 'released'
> +[ -s | --stream]: Use specified stream rather than 'tryreleased'
>  
>  Additionally, clone hooks can be passed through (ie, --userdata).  For those,
>  see:
> @@ -158,7 +159,7 @@ release=precise
>  if [ -f /etc/lsb-release ]; then
>      . /etc/lsb-release
>      rels=$(ubuntu-distro-info --supported 2>/dev/null) ||
> -        rels="lucid natty oneiric precise quantal raring saucy"
> +        rels="$KNOWN_RELEASES"
>      for r in $rels; do
>          [ "$DISTRIB_CODENAME" = "$r" ] && release="$r"
>      done
> @@ -226,31 +227,12 @@ if [ "$arch" = "i686" ]; then
>      arch=i386
>  fi
>  
> -if [ $arch != "i386" -a $arch != "amd64" -a $arch != "armhf" -a $arch != "armel" ]; then
> -    echo "Only i386, amd64, armel and armhf are supported by the ubuntu cloud template."
> -    exit 1
> -fi
> -
> -if [ $hostarch != "i386" -a $hostarch != "amd64" -a $hostarch != "armhf" -a $hostarch != "armel" ]; then
> -    echo "Only i386, amd64, armel and armhf are supported as host."
> -    exit 1
> -fi
> -
> -if [ $hostarch = "amd64" -a $arch != "amd64" -a $arch != "i386" ]; then
> -    echo "can't create $arch container on $hostarch"
> -    exit 1
> -fi
> -
> -if [ $hostarch = "i386" -a $arch != "i386" ]; then
> -    echo "can't create $arch container on $hostarch"
> -    exit 1
> -fi
> -
> -if [ $hostarch = "armhf" -o $hostarch = "armel" ] && \
> -   [ $arch != "armhf" -a $arch != "armel" ]; then
> -    echo "can't create $arch container on $hostarch"
> -    exit 1
> -fi
> +case "$hostarch:$arch" in
> +    $arch:$arch) : ;; # the host == container
> +    amd64:i386|armhf:armel|armel:armhf) :;; # supported "cross"
> +    *) echo "cannot create '$arch' container on hostarch '$hostarch'";
> +       exit 1;;
> +esac

Can you also include arm64:armel and arm64:armhf? We may not have cloud
images for arm64 but if we start having those in the next 5 years,
having that code will save us some work then (SRU, ...).

>  
>  if [ "$stream" != "daily" -a "$stream" != "released" -a "$stream" != "tryreleased" ]; then
>      echo "Only 'daily' and 'released' and 'tryreleased' streams are supported"
> @@ -298,7 +280,11 @@ fi
>  if [ -n "$tarball" ]; then
>      url2="$tarball"
>  else
> -    url1=`ubuntu-cloudimg-query $release $stream $arch --format "%{url}\n"`
> +    if ! url1=`ubuntu-cloudimg-query $release $stream $arch --format "%{url}\n"`; then
> +        echo "There is no download available for release=$release, stream=$stream, arch=$arch"
> +        [ "$stream" = "daily" ] || echo "You may try with '--stream=daily'"
> +        exit
> +    fi
>      url2=`echo $url1 | sed -e 's/.tar.gz/-root\0/'`
>  fi
>  
> -- 
> 1.8.5.3
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140130/0f0880be/attachment.pgp>


More information about the lxc-devel mailing list