Merge remote-tracking branch 'origin/pr/10'
* origin/pr/10: - Fixed 'Qubes Builder: install-templates.sh wants to install the 'same' image multiple times'. Fixes QubesOS/qubes-issues#1109
This commit is contained in:
commit
24f3f78e72
@ -5,9 +5,50 @@
|
|||||||
# Creates a small script to copy to dom0 to retrieve the generated template rpm's
|
# Creates a small script to copy to dom0 to retrieve the generated template rpm's
|
||||||
#
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
template_dir="$(readlink -m ./rpm/install-templates.sh)"
|
template_dir="$(readlink -m ./rpm/install-templates.sh)"
|
||||||
files=( $(ls rpm/noarch) )
|
path="$(readlink -m .)/rpm/noarch"
|
||||||
name=$(xenstore-read name)
|
version="-$(cat ./version)"
|
||||||
|
name="$(xenstore-read name)"
|
||||||
|
|
||||||
|
files_list_temp="$(echo "rpm/noarch/"*)"
|
||||||
|
files_list_temp="$(printf "%s \n" ${files_list_temp[@]})"
|
||||||
|
## Newest versions first.
|
||||||
|
files_list_temp="$(echo "$files_list_temp" | sort --reverse)"
|
||||||
|
|
||||||
|
for file_name in $files_list_temp ; do
|
||||||
|
file_name_without_version="$(echo "${file_name}" | sed -r "s/(${version}).+$//")"
|
||||||
|
template_name="$(basename "$file_name_without_version")"
|
||||||
|
template_list+="$template_name "
|
||||||
|
done
|
||||||
|
|
||||||
|
template_list="$(printf "%s \n" ${template_list[@]})"
|
||||||
|
template_list="$(echo "$template_list" | sort --unique)"
|
||||||
|
echo "template_list: $template_list"
|
||||||
|
|
||||||
|
declare -A -g remembered
|
||||||
|
|
||||||
|
for template_item_from_template_list in $template_list ; do
|
||||||
|
for file_name in $files_list_temp ; do
|
||||||
|
file_name_without_version="$(echo "${file_name}" | sed -r "s/(${version}).+$//")"
|
||||||
|
template_name="$(basename "$file_name_without_version")"
|
||||||
|
file_name_basename="$(basename "$file_name")"
|
||||||
|
if [ ! "$template_item_from_template_list" = "$template_name" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "${remembered["$template_name"]}" = "true" ]; then
|
||||||
|
files+="#$file_name_basename "
|
||||||
|
else
|
||||||
|
remembered["$template_name"]="true"
|
||||||
|
files+="$file_name_basename "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
files="
|
||||||
|
$(printf "%s \n" ${files[@]})
|
||||||
|
"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Write $vars
|
# Write $vars
|
||||||
@ -18,12 +59,10 @@ cat << EOF > "${template_dir}"
|
|||||||
# Use the following command in DOM0 to retreive this file:
|
# Use the following command in DOM0 to retreive this file:
|
||||||
# qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh
|
# qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh
|
||||||
|
|
||||||
files="
|
files="${files}"
|
||||||
$(printf "%s \n" ${files[@]})
|
|
||||||
"
|
|
||||||
|
|
||||||
path="$(readlink -m .)/rpm/noarch"
|
path="${path}"
|
||||||
version="-$(cat ./version)"
|
version="${version}"
|
||||||
name="${name}"
|
name="${name}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@ -32,15 +71,19 @@ EOF
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
cat << 'EOF' >> "${template_dir}"
|
cat << 'EOF' >> "${template_dir}"
|
||||||
|
|
||||||
for file in ${files[@]}; do
|
for file_name in ${files[@]}; do
|
||||||
if [ ! -e ${file} ]; then
|
if echo "$file_name" | grep -q '^#' ; then
|
||||||
echo "Copying ${file} from ${name} to ${PWD}/${file}..."
|
continue
|
||||||
qvm-run --pass-io ${name} "cat ${path}/${file}" > ${file}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo yum erase $(echo "${file}" | sed -r "s/(${version}).+$//") && {
|
if [ ! -e "${file_name}" ]; then
|
||||||
sudo yum install ${file} && {
|
echo "Copying ${file_name} from ${name} to ${PWD}/${file_name}..."
|
||||||
rm -f ${file}
|
qvm-run --pass-io "${name}" "cat ${path}/${file_name}" > "${file_name}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo yum erase $(echo "${file_name}" | sed -r "s/(${version}).+$//") && {
|
||||||
|
sudo yum install "${file_name}" && {
|
||||||
|
rm -f "${file_name}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
@ -51,5 +94,3 @@ EOF
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
echo "Use the following command in DOM0 to retreive this file:"
|
echo "Use the following command in DOM0 to retreive this file:"
|
||||||
echo "qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh"
|
echo "qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user