Skip to content

Commit

Permalink
plugin: initrd: fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
  • Loading branch information
kubiko committed Nov 9, 2023
1 parent 712aef9 commit bac7288
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 69 deletions.
70 changes: 35 additions & 35 deletions snapcraft_legacy/plugins/v2/_initrd_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,40 @@ def _link_files_fnc_cmd() -> List[str]:
# link files, accept wild cards
# 1: reference dir, 2: file(s) including wild cards, 3: dst dir
link_files() {
if [ "${2}" = "*" ]; then
for f in $(ls ${1})
do
link_files "${1}" "${f}" "${3}"
done
return 0
fi
if [ -d "${1}/${2}" ]; then
for f in $(ls ${1}/${2})
do
link_files "${1}" "${2}/${f}" "${3}"
done
return 0
fi
local found=""
for f in $(ls ${1}/${2})
do
if [[ -L "${f}" ]]; then
local rel_path=$( realpath --no-symlinks --relative-to=${1} ${f} )
else
local rel_path=$( realpath -se --relative-to=${1} ${f} )
fi
local dir_path=$(dirname ${rel_path})
mkdir -p ${3}/${dir_path}
echo "installing ${f} to ${3}/${dir_path}"
ln -f ${f} ${3}/${dir_path}
found="yes"
done
if [ "yes" = "${found}" ]; then
return 0
else
return 1
fi
if [ "${2}" = "*" ]; then
for f in $(ls ${1})
do
link_files "${1}" "${f}" "${3}"
done
return 0
fi
if [ -d "${1}/${2}" ]; then
for f in $(ls ${1}/${2})
do
link_files "${1}" "${2}/${f}" "${3}"
done
return 0
fi
local found=""
for f in $(ls ${1}/${2})
do
if [[ -L "${f}" ]]; then
local rel_path=$( realpath --no-symlinks --relative-to=${1} ${f} )
else
local rel_path=$( realpath -se --relative-to=${1} ${f} )
fi
local dir_path=$(dirname ${rel_path})
mkdir -p ${3}/${dir_path}
echo "installing ${f} to ${3}/${dir_path}"
ln -f ${f} ${3}/${dir_path}
found="yes"
done
if [ "yes" = "${found}" ]; then
return 0
else
return 1
fi
}
"""
)
Expand Down Expand Up @@ -668,7 +668,7 @@ def _get_initrd_install_command(
install_dir: str,
stage_dir: str,
) -> List[str]:

return [
'echo "building initramfs..."',
"",
Expand Down
68 changes: 34 additions & 34 deletions tests/legacy/unit/plugins/v2/test_initrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,40 +469,40 @@ def _is_sub_array(array, sub_array):
# link files, accept wild cards
# 1: reference dir, 2: file(s) including wild cards, 3: dst dir
link_files() {
if [ "${2}" = "*" ]; then
for f in $(ls ${1})
do
link_files "${1}" "${f}" "${3}"
done
return 0
fi
if [ -d "${1}/${2}" ]; then
for f in $(ls ${1}/${2})
do
link_files "${1}" "${2}/${f}" "${3}"
done
return 0
fi
local found=""
for f in $(ls ${1}/${2})
do
if [[ -L "${f}" ]]; then
local rel_path=$( realpath --no-symlinks --relative-to=${1} ${f} )
else
local rel_path=$( realpath -se --relative-to=${1} ${f} )
fi
local dir_path=$(dirname ${rel_path})
mkdir -p ${3}/${dir_path}
echo "installing ${f} to ${3}/${dir_path}"
ln -f ${f} ${3}/${dir_path}
found="yes"
done
if [ "yes" = "${found}" ]; then
return 0
else
return 1
fi
if [ "${2}" = "*" ]; then
for f in $(ls ${1})
do
link_files "${1}" "${f}" "${3}"
done
return 0
fi
if [ -d "${1}/${2}" ]; then
for f in $(ls ${1}/${2})
do
link_files "${1}" "${2}/${f}" "${3}"
done
return 0
fi
local found=""
for f in $(ls ${1}/${2})
do
if [[ -L "${f}" ]]; then
local rel_path=$( realpath --no-symlinks --relative-to=${1} ${f} )
else
local rel_path=$( realpath -se --relative-to=${1} ${f} )
fi
local dir_path=$(dirname ${rel_path})
mkdir -p ${3}/${dir_path}
echo "installing ${f} to ${3}/${dir_path}"
ln -f ${f} ${3}/${dir_path}
found="yes"
done
if [ "yes" = "${found}" ]; then
return 0
else
return 1
fi
}
"""
)
Expand Down

0 comments on commit bac7288

Please sign in to comment.