Commit 6af726e9 authored by HgO's avatar HgO

Upgrade yunocube scripts and rebuild Yunohost image

parent 8ffbf169
......@@ -727,23 +727,28 @@ function download_image() {
mkdir -p "$CUBE_RESOURCES_LOCATION"
pushd "$CUBE_RESOURCES_LOCATION" > /dev/null
local cube_build_script_enabled=false
debug $"Finding latest Yunohost $board image..."
ynh_image_zip="$(curl --show-error --fail --silent $YNH_IMG_LOCATION \
local ynh_image_zip="$(curl --show-error --fail --silent $YNH_IMG_LOCATION \
| grep "${YUNOHOST_PREFIX}-${DEBIAN_CODENAME}-[\d\.]+-$board-stable.img.zip" -Po \
| sort -V \
| tail -n 1)"
ynh_image_sum="$ynh_image_zip.sha256sum"
ynh_image_sig="$ynh_image_zip.sig"
local ynh_image_sum="$ynh_image_zip.sha256sum"
local ynh_image_sig="$ynh_image_zip.sig"
local version=$(cut -d '-' -f 3 <<< $ynh_image_zip)
version=$(cut -d '-' -f 3 <<< $ynh_image_zip)
info $"Latest Yunohost $board image is v$version!"
ynh_image="${YUNOHOST_PREFIX}-${DEBIAN_CODENAME}-${version}-${board}-stable.img"
local ynh_image="${YUNOHOST_PREFIX}-${DEBIAN_CODENAME}-${version}-${board}-stable.img"
# The image path is used globally
image="${ynh_image/${YUNOHOST_PREFIX}/${INTERNETCUBE_PREFIX}}"
if [[ ! -f $image ]]
then
cube_build_script_enabled=true
if [[ ! -f $ynh_image ]]
then
if [[ ! -f $ynh_image_zip ]]
......@@ -767,27 +772,47 @@ function download_image() {
unzip -p "$ynh_image_zip" > "$ynh_image"
rm "$ynh_image_zip"
fi
fi
if [[ ! -f $CUBE_BUILD_SCRIPT_NAME ]]
if [[ ! -d $CUBE_BUILD_SCRIPT_DIR ]]
then
info $"Downloading internetcube scripts..."
git clone -q ${CUBE_BUILD_SCRIPT_LOCATION} ${CUBE_BUILD_SCRIPT_DIR} > /dev/null
cube_build_script_enabled=true
else
local cube_build_script_current_revision
if [[ $CUBE_BUILD_SCRIPT_REVISION != "master" ]]
then
cube_build_script_current_revision=$(git -C $CUBE_BUILD_SCRIPT_DIR rev-parse HEAD)
fi
if [[ $cube_build_script_current_revision != $CUBE_BUILD_SCRIPT_REVISION ]]
then
info $"Downloading internetcube scripts..."
git clone -q ${CUBE_BUILD_SCRIPT_LOCATION} ${CUBE_BUILD_SCRIPT_DIR} > /dev/null
git -C ${CUBE_BUILD_SCRIPT_DIR} checkout -q ${CUBE_BUILD_SCRIPT_REVISION} > /dev/null
info $"Upgrading internetcube scripts..."
git -C ${CUBE_BUILD_SCRIPT_DIR} remote set-url origin ${CUBE_BUILD_SCRIPT_LOCATION}
git -C ${CUBE_BUILD_SCRIPT_DIR} fetch
cube_build_script_enabled=true
fi
fi
if [[ $cube_build_script_enabled == true ]]
then
git -C ${CUBE_BUILD_SCRIPT_DIR} checkout -q ${CUBE_BUILD_SCRIPT_REVISION} > /dev/null
debug $"Building internetcube image..."
info $"Building internetcube image..."
check_sudo
sudo chmod u+x $CUBE_BUILD_SCRIPT_NAME
if ! sudo "./$CUBE_BUILD_SCRIPT_NAME" "$ynh_image"; then
if ! sudo "./$CUBE_BUILD_SCRIPT_NAME" "$ynh_image"
then
# when the script fails, ensure that there isn't any corrupted built image left behind
rm -f "$image"
return 1
fi
rm -rf "$CUBE_BUILD_SCRIPT_DIR" "tmp"
rm -rf "tmp"
fi
info $"We've got our internetcube image!"
popd > /dev/null
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment