Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2585 from danmcp/master
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed May 22, 2013
2 parents 1eccca9 + 5672180 commit 4bf9d12
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
32 changes: 7 additions & 25 deletions node/lib/openshift-origin-node/model/application_repository.rb
Expand Up @@ -149,11 +149,17 @@ def deploy

env = Utils::Environ.load(PathUtils.join(@user.homedir, '.env'))

Utils.oo_spawn(ERB.new(GIT_DEPLOY_SUBMODULES).result(binding),
cache = PathUtils.join(env['OPENSHIFT_TMP_DIR'], 'git_cache')
FileUtils.rm_r(cache) if File.exist?(cache)
FileUtils.mkpath(cache)

Utils.oo_spawn("/bin/sh #{File.join('/usr/libexec/openshift/lib', "deploy_git_submodules.sh")} #{@path} #{@target_dir}",
chdir: @user.homedir,
env: env,
uid: @user.uid,
expected_exitstatus: 0)

Utils.oo_spawn("/bin/rm -rf #{cache} &")
end

def destroy
Expand Down Expand Up @@ -239,30 +245,6 @@ def build_bare(path)
shopt -s dotglob;
rm -rf <%= @target_dir %>/*;
git archive --format=tar HEAD | (cd <%= @target_dir %> && tar --warning=no-timestamp -xf -);
}

GIT_DEPLOY_SUBMODULES = %Q{\
# if GIT_DIR is set we need to unset it
[ ! -z "${GIT_DIR+xxx}" ] && unset GIT_DIR
set -xe;
# explode tree into a tmp dir
tmp_dir=${OPENSHIFT_TMP_DIR}
submodule_tmp_dir=${tmp_dir}/submodules
pushd ${tmp_dir} > /dev/null
[ -e ${submodule_tmp_dir} ] && rm -rf ${submodule_tmp_dir}
git clone <%= @path %> submodules
pushd ${submodule_tmp_dir} > /dev/null
# initialize submodules and pull down source
git submodule update --init --recursive
# archive and copy the submodules
git submodule foreach --recursive "git archive --format=tar HEAD | (cd <%= @target_dir %>/\\$name && tar --warning=no-timestamp -xf -)"
popd > /dev/null
popd > /dev/null
rm -rf ${submodule_tmp_dir}
}

GIT_DESCRIPTION = %Q{
Expand Down
3 changes: 2 additions & 1 deletion node/lib/openshift-origin-node/utils/shell_exec.rb
Expand Up @@ -104,7 +104,8 @@ def self.oo_spawn(command, options = {})
# Only switch contexts if necessary
if (current_context != target_context) || (Process.uid != options[:uid])
target_name = Etc.getpwuid(options[:uid]).name
command = %Q{/sbin/runuser -m -s /bin/sh #{target_name} -c "exec /usr/bin/runcon '#{target_context}' /bin/sh -c \\"#{command}\\""}
exec = %Q{exec /usr/bin/runcon '#{target_context}' /bin/sh -c \\"#{command}\\"}
command = %Q{/sbin/runuser -m -s /bin/sh #{target_name} -c "#{exec}"}
end
end

Expand Down
20 changes: 20 additions & 0 deletions node/misc/libexec/lib/deploy_git_submodules.sh
@@ -0,0 +1,20 @@
#!/bin/bash
git_dir=$1
target_dir=$2

# if GIT_DIR is set we need to unset it
[ ! -z "${GIT_DIR+xxx}" ] && unset GIT_DIR
set -xe;

pushd ${OPENSHIFT_TMP_DIR} > /dev/null
git clone $git_dir git_cache

pushd git_cache > /dev/null
# initialize submodules and pull down source
git submodule update --init --recursive

# archive and copy the submodules
git submodule foreach --recursive "git archive --format=tar HEAD | (cd $target_dir/\$name && tar --warning=no-timestamp -xf -)"

popd > /dev/null
popd > /dev/null
2 changes: 2 additions & 0 deletions node/rubygem-openshift-origin-node.spec
Expand Up @@ -135,6 +135,7 @@ mkdir -p %{buildroot}/usr/libexec/openshift/lib
mv %{buildroot}%{gem_instdir}/misc/libexec/lib/teardown_pam_fs_limits.sh %{buildroot}/usr/libexec/openshift/lib
mv %{buildroot}%{gem_instdir}/misc/libexec/lib/setup_pam_fs_limits.sh %{buildroot}/usr/libexec/openshift/lib
mv %{buildroot}%{gem_instdir}/misc/libexec/lib/quota_attrs.sh %{buildroot}/usr/libexec/openshift/lib
mv %{buildroot}%{gem_instdir}/misc/libexec/lib/deploy_git_submodules.sh %{buildroot}/usr/libexec/openshift/lib
# Install the cartridge SDK files and environment variables for each
mkdir -p %{buildroot}/usr/lib/openshift/cartridge_sdk
Expand Down Expand Up @@ -239,6 +240,7 @@ fi
/usr/libexec/openshift/lib/setup_pam_fs_limits.sh
/usr/libexec/openshift/lib/teardown_pam_fs_limits.sh
/usr/libexec/openshift/lib/quota_attrs.sh
/usr/libexec/openshift/lib/deploy_git_submodules.sh
%attr(0755,-,-) /usr/lib/openshift/cartridge_sdk
%attr(0755,-,-) /usr/lib/openshift/cartridge_sdk/bash
%attr(0744,-,-) /usr/lib/openshift/cartridge_sdk/bash/*
Expand Down
3 changes: 0 additions & 3 deletions node/test/functional/application_repository_func_test.rb
Expand Up @@ -266,8 +266,6 @@ def test_source
end

def test_bare_submodule
=begin
TODO: There is a conflict when called directly but works when called from git
create_template(File.join(@cartridge_home, 'template', 'perl'))
create_bare_submodule
expected_path = File.join(@user.homedir, 'git', @user.app_name + '.git')
Expand Down Expand Up @@ -295,7 +293,6 @@ def test_bare_submodule
#{e.backtrace.join("\n")}}
raise
end
=end
end

def create_template(path)
Expand Down

0 comments on commit 4bf9d12

Please sign in to comment.