From 40a654411ea9b69cbdd0b74c9959d67f49a99fb9 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Thu, 22 Dec 2011 15:18:24 +0100 Subject: [PATCH 1/5] Bug #1002: move mkfs-dependant option "-F" from tm_mkimage.sh to fs/mkfs-script --- src/image_mad/remotes/fs/mkfs | 27 +++++---------------------- src/mad/sh/scripts_common.sh | 27 +++++++++++++++++++++++++++ src/tm_mad/lvm/tm_mkimage.sh | 4 +++- src/tm_mad/shared/tm_mkimage.sh | 4 +++- src/tm_mad/ssh/tm_mkimage.sh | 6 ++++-- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/image_mad/remotes/fs/mkfs b/src/image_mad/remotes/fs/mkfs index d4e8c61157..344e669335 100755 --- a/src/image_mad/remotes/fs/mkfs +++ b/src/image_mad/remotes/fs/mkfs @@ -21,7 +21,7 @@ # as (FS) ############################################################################### -# ------------ Set up the environment to source common tools ------------ +# ------------ Set up the environment to source common tools ------------ if [ -z "${ONE_LOCATION}" ]; then LIB_LOCATION=/usr/lib/one @@ -32,37 +32,20 @@ fi . $LIB_LOCATION/sh/scripts_common.sh source $(dirname $0)/fsrc -# ------------ Create the image to the repository ------------ +# ------------ Create the image to the repository ------------ FSTYPE=$1 SIZE=$2 ID=$3 -# Specific options for different FS -case "$FSTYPE" in - "ext2"|"ext3"|"ext4"|"ntfs") - OPTS="-F" - ;; - - "reiserfs") - OPTS="-f -q" - ;; - - "jfs") - OPTS="-q" - ;; - *) - OPTS="" - ;; -esac - DST=`generate_image_path` +MKFS_CMD=`mkfs_command $DST $FSTYPE` + exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST" -exec_and_log "$MKFS -t $FSTYPE $OPTS $DST" \ +exec_and_log "$MKFS_CMD" \ "Unable to create filesystem $FSTYPE in $DST" - exec_and_log "chmod 0660 $DST" # ---------------- Get the size of the image ------------ diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 5730e0b99c..0153c6bff6 100755 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -148,3 +148,30 @@ function timeout_exec_and_log exit $CMD_CODE fi } + +# This function will return a command that upon execution will format a +# filesystem with its proper parameters based on the filesystem type +function mkfs_command { + DST=$1 + FSTYPE=${2:-ext3} + + # Specific options for different FS + case "$FSTYPE" in + "ext2"|"ext3"|"ext4"|"ntfs") + OPTS="-F" + ;; + + "reiserfs") + OPTS="-f -q" + ;; + + "jfs") + OPTS="-q" + ;; + *) + OPTS="" + ;; + esac + + echo "$MKFS -t $FSTYPE $OPTS $DST" +} diff --git a/src/tm_mad/lvm/tm_mkimage.sh b/src/tm_mad/lvm/tm_mkimage.sh index d092a8b9b2..1410eae120 100755 --- a/src/tm_mad/lvm/tm_mkimage.sh +++ b/src/tm_mad/lvm/tm_mkimage.sh @@ -32,7 +32,9 @@ DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` + exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" -exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" +exec_and_log "$SSH $DST_HOST $MKFS_CMD" exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" diff --git a/src/tm_mad/shared/tm_mkimage.sh b/src/tm_mad/shared/tm_mkimage.sh index b30c0ff327..97985c0368 100755 --- a/src/tm_mad/shared/tm_mkimage.sh +++ b/src/tm_mad/shared/tm_mkimage.sh @@ -36,11 +36,13 @@ fix_dst_path DST_DIR=`dirname $DST_PATH` +MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` + exec_and_log "mkdir -p $DST_DIR" \ "Error creating directory $DST_DIR" exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST_PATH" -exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH" \ +exec_and_log "$MKFS_CMD" \ "Unable to create filesystem $FSTYPE in $DST_PATH" exec_and_log "chmod a+rw $DST_PATH" diff --git a/src/tm_mad/ssh/tm_mkimage.sh b/src/tm_mad/ssh/tm_mkimage.sh index 81ff20f32c..dec17c3d1e 100755 --- a/src/tm_mad/ssh/tm_mkimage.sh +++ b/src/tm_mad/ssh/tm_mkimage.sh @@ -32,10 +32,12 @@ DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` + exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \ "Error creating directory $DST_DIR" exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST_PATH" -exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" \ +exec_and_log "$SSH $DST_HOST $MKFS_CMD" \ "Unable to create filesystem $FSTYPE in $DST_PATH" -exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" \ No newline at end of file +exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" From 14579991f154156d36d172b114a07771ee71836c Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 22 Dec 2011 16:54:54 +0100 Subject: [PATCH 2/5] bug #1023: fix host cpu retrieval for procps-ng --- src/im_mad/remotes/kvm.d/kvm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb index 9fd51c7eb6..9e717c2cd1 100755 --- a/src/im_mad/remotes/kvm.d/kvm.rb +++ b/src/im_mad/remotes/kvm.d/kvm.rb @@ -51,9 +51,9 @@ exit(-1) if $?.exitstatus != 0 top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output top_text.split(/\n/).each{|line| - if line.match('^Cpu') + if line.match('^%?Cpu') line[7..-1].split(",").each{|elemento| - temp = elemento.strip.split("%") + temp = elemento.strip.split(/[% ]/) if temp[1]=="id" idle = temp[0] $free_cpu = idle.to_f * $total_cpu.to_f / 100 From 047cfe49812255864aa7f0c41c6befa7d0bc9630 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 22 Dec 2011 16:33:28 +0100 Subject: [PATCH 3/5] bug #1031: now the folder deleted is just disk.n (cherry picked from commit 4da7c9060f36eb40a1d5b07377487fb6375af137) --- src/tm_mad/vmware/tm_ln.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tm_mad/vmware/tm_ln.sh b/src/tm_mad/vmware/tm_ln.sh index 878b0785f7..f590a7894d 100755 --- a/src/tm_mad/vmware/tm_ln.sh +++ b/src/tm_mad/vmware/tm_ln.sh @@ -42,7 +42,7 @@ REPO_NAME="images" RELATIVE_SRC_PATH="../../$REPO_NAME/$VM_FOLDER_NAME" log "Creating directory $DST_PATH" -exec_and_log "rm -rf $DST_PATH" +exec_and_log "rm -rf $DST" exec_and_log "mkdir -p $DST_PATH" exec_and_log "chmod a+w $DST_PATH" From 8db6c0ed57fea3a0a3eb32ad277f63727c57c745 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 22 Dec 2011 18:34:24 +0100 Subject: [PATCH 4/5] feature #1020: Fix for better vmware disk moving (cherry picked from commit cb5e13c1490a435b8113c965d4cbb241e7200e51) --- src/tm_mad/vmware/tm_ln.sh | 3 +++ src/tm_mad/vmware/tm_mv.sh | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tm_mad/vmware/tm_ln.sh b/src/tm_mad/vmware/tm_ln.sh index f590a7894d..d815341511 100755 --- a/src/tm_mad/vmware/tm_ln.sh +++ b/src/tm_mad/vmware/tm_ln.sh @@ -56,5 +56,8 @@ for file in `find $RELATIVE_SRC_PATH/* -type f`; do exec_and_log "ln -sf ../$file $DST_PATH/$file_name" done +# Put the symlink mark for tm_mv +exec_and_log "ln -sf $RELATIVE_SRC_PATH $DST_PATH/.disk" + diff --git a/src/tm_mad/vmware/tm_mv.sh b/src/tm_mad/vmware/tm_mv.sh index 29d895a212..8a4b27f875 100755 --- a/src/tm_mad/vmware/tm_mv.sh +++ b/src/tm_mad/vmware/tm_mv.sh @@ -41,9 +41,11 @@ SRC_PATH=`fix_dir_slashes "$SRC_PATH"` if [ "$SRC_PATH" = "$DST_PATH" ]; then log "Will not move, source and destination are equal" +elif [ -f "$SRC_PATH/.disk" ]; then # This link was set in tm_ln.sh +  exec_and_log "mv $SRC_PATH/.disk $DST_PATH" elif echo $SRC_PATH | grep -q 'disk\.[0-9]\+$'; then - log "Moving $SRC_PATH" - exec_and_log "mv $SRC_PATH $DST_PATH" +    log "Moving $SRC_PATH" +    exec_and_log "mv $SRC_PATH $DST_PATH" elif [ -d $SRC_PATH ]; then log "Will not move, is not saving image" else From 16a1b24b8228b2b301078a5e9946a48ef4b0bb74 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 23 Dec 2011 10:14:58 -0600 Subject: [PATCH 5/5] feature #914: update rubygems if version older than 1.3.6 --- share/install_gems/install_gems | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 9b1da6f65d..d0dd30ac98 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -90,6 +90,62 @@ class String end end +def good_gem_version? + v=`gem --version`.strip + version=Gem::Version.new(v) + version>=Gem::Version.new('1.3.6') +end + +def install_rubygems + if !good_gem_version? + puts(<<-EOT.unindent()) + The rubygems version installed is too old to install some required + libraries. We are about to update your rubygems version. If you + want to do this by other means cancel this installation with + CTRL+C now. + + Press ENTER to continue... + +EOT + + STDIN.readline + + `gem install rubygems-update --version '= 1.3.6'` + + if $?.ecxitstatus!=0 + puts "Error updating rubygems" + exit(-1) + end + + update_rubygems_path=[ + '/usr/bin/update_rubygems', + '/var/lib/gems/1.8/bin/update_rubygems', + '/var/lib/gems/1.9/bin/update_rubygems' + ] + + installed=false + + update_rubygems_path.each do |path| + if File.exist?(path) + `#{path}` + + if $?.exitstatus!=0 + puts "Error executing update_rubygems" + exit(-1) + end + + installed=true + break + end + end + + if !installed + puts "Could not find update_rubygems executable" + exit(-1) + end + end +end + def installed_gems text=`gem list --no-versions --no-details` if $?.exitstatus!=0 @@ -331,6 +387,7 @@ try_library :mkmf, <<-EOT.unindent * Install the ruby development package for your distro EOT +install_rubygems command='' params=ARGV