[lxc-devel] [PATCH] fix open check (0 is a valid fd)
Signed-off-by: Dwight Engen --- src/lxc/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/console.c b/src/lxc/console.c index 73bec78..c3f892b 100644 --- a/src/lxc/console.c +++ b/src/lxc/console.c @@ -145,7 +145,7 @@ static int get_default_console(char **console) if (!access("/dev/tty", F_OK)) { fd = open("/dev/tty", O_RDWR); - if (fd > 0) { + if (fd >= 0) { close(fd); *console = strdup("/dev/tty"); goto out; -- 1.7.12.3 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH 3/5] lxc-alpine: add --repository option
This allows specifying what repository to use for the container. Signed-off-by: Natanael Copa --- templates/lxc-alpine.in | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in index 7787e75..87886f5 100644 --- a/templates/lxc-alpine.in +++ b/templates/lxc-alpine.in @@ -119,7 +119,10 @@ die() { } usage() { -echo "Usage: $(basename $0) [-h|--help] -p|--path -n|--name " >&2 +cat >&2 <] + -p|--path -n|--name +EOF } usage_err() { @@ -153,6 +156,11 @@ while [ $# -gt 0 ]; do path=$1 shift ;; +-r|--repository) +optarg_check $opt "$1" +repository=$1 +shift + ;; --) break;; --*=*) -- 1.8.0.3 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH 2/5] lxc-alpine: indent fixes
Signed-off-by: Natanael Copa --- templates/lxc-alpine.in | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in index 6f7c90d..7787e75 100644 --- a/templates/lxc-alpine.in +++ b/templates/lxc-alpine.in @@ -136,41 +136,41 @@ optarg_check() { default_path=@LXCPATH@ while [ $# -gt 0 ]; do -opt="$1" -shift -case "$opt" in --h|--help) +opt="$1" +shift +case "$opt" in +-h|--help) usage exit 0 ;; --n|--name) +-n|--name) optarg_check $opt "$1" name=$1 shift ;; --p|--path) +-p|--path) optarg_check $opt "$1" path=$1 shift ;; ---) +--) break;; ---*=*) -# split --myopt=foo=bar into --myopt foo=bar -set -- ${opt%=*} ${opt#*=} "$@" +--*=*) +# split --myopt=foo=bar into --myopt foo=bar +set -- ${opt%=*} ${opt#*=} "$@" ;; --?) +-?) usage_err "unknown option '$opt'" ;; --*) +-*) # split opts -abc into -a -b -c set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@" ;; -*) +*) usage exit 1 ;; -esac +esac done -- 1.8.0.3 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH 5/5] lxc-alpine: add support for installing optional packages
Let users append a list of packages they want install in the container Signed-off-by: Natanael Copa --- templates/lxc-alpine.in | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in index 5b685b1..b06215f 100644 --- a/templates/lxc-alpine.in +++ b/templates/lxc-alpine.in @@ -2,6 +2,7 @@ install_alpine() { rootfs="$1" +shift mkdir -p "$rootfs"/etc/apk || return 1 cp -r ${keys_dir:-/etc/apk/keys} "$rootfs"/etc/apk/ if [ -n "$repository" ]; then @@ -13,7 +14,7 @@ install_alpine() { if [ -n "$apk_arch" ]; then opt_arch="--arch $apk_arch" fi -${APK:-apk} add -U --initdb --root $rootfs $opt_arch alpine-base +${APK:-apk} add -U --initdb --root $rootfs $opt_arch "$@" alpine-base } configure_alpine() { @@ -128,7 +129,7 @@ die() { usage() { cat >&2 <] [-a|--arch ] - -p|--path -n|--name + -p|--path -n|--name [PKG...] EOF } @@ -186,10 +187,6 @@ while [ $# -gt 0 ]; do # split opts -abc into -a -b -c set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@" ;; -*) -usage -exit 1 -;; esac done @@ -217,6 +214,6 @@ case "$arch" in *) die "unsupported architecture: $arch";; esac -install_alpine "$rootfs" || die "Failed to install rootfs for $name" +install_alpine "$rootfs" "$@" || die "Failed to install rootfs for $name" configure_alpine "$rootfs" "$name" || die "Failed to configure $name" copy_configuration "$path" "$rootfs" "$name" -- 1.8.0.3 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH 4/5] lxc-alpine: add support for setting arch from command line
This allows us to lxc-create 32 bit guests on x86_64 hosts. Signed-off-by: Natanael Copa --- templates/lxc-alpine.in | 28 ++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in index 87886f5..5b685b1 100644 --- a/templates/lxc-alpine.in +++ b/templates/lxc-alpine.in @@ -9,7 +9,11 @@ install_alpine() { else cp /etc/apk/repositories "$rootfs"/etc/apk/repositories || return 1 fi -${APK:-apk} add -U --initdb --root $rootfs alpine-base +opt_arch= +if [ -n "$apk_arch" ]; then +opt_arch="--arch $apk_arch" +fi +${APK:-apk} add -U --initdb --root $rootfs $opt_arch alpine-base } configure_alpine() { @@ -68,6 +72,9 @@ copy_configuration() { grep -q "^lxc.rootfs" $path/config 2>/dev/null \ || echo "lxc.rootfs = $rootfs" >> $path/config +if [ -n "$lxc_arch" ]; then +echo "lxc.arch = $lxc_arch" >> $path/config +fi cat <> $path/config lxc.tty = 4 lxc.pts = 1024 @@ -120,7 +127,7 @@ die() { usage() { cat >&2 <] +Usage: $(basename $0) [-h|--help] [-r|--repository ] [-a|--arch ] -p|--path -n|--name EOF } @@ -161,6 +168,11 @@ while [ $# -gt 0 ]; do repository=$1 shift ;; +-a|--arch) +optarg_check $opt "$1" +arch=$1 +shift + ;; --) break;; --*=*) @@ -193,6 +205,18 @@ if [ -z "$rootfs" ]; then rootfs="${path}/rootfs" fi +lxc_arch=$arch +apk_arch=$arch + +case "$arch" in + i[3-6]86) + apk_arch=x86;; + x86) + lxc_arch=i686;; + x86_64|"") ;; + *) die "unsupported architecture: $arch";; +esac + install_alpine "$rootfs" || die "Failed to install rootfs for $name" configure_alpine "$rootfs" "$name" || die "Failed to configure $name" copy_configuration "$path" "$rootfs" "$name" -- 1.8.0.3 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
[lxc-devel] [PATCH 1/5] templates: install lxc-alpine
Make sure we actually install lxc-alpine Signed-off-by: Natanael Copa --- templates/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/Makefile.am b/templates/Makefile.am index 9a94f32..be7e9f6 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -13,4 +13,5 @@ templates_SCRIPTS = \ lxc-altlinux \ lxc-busybox \ lxc-sshd \ - lxc-archlinux + lxc-archlinux \ + lxc-alpine -- 1.8.0.3 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel