~aleteoryx/muditaos

21fe3f4f7f608bdb1a24ee093b0fa2353da049d1 — Roman Kubiak 5 years ago 958e304
[EGD-4160] renamed PureOS -> MUDITAOS (#901)

M config/common.sh => config/common.sh +20 -19
@@ 2,17 2,18 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

PURE_PARTITION_PRIMARY="PUREOS"
PURE_PARTITION_RECOVERY="RECOVER"
PURE_OS_CURRENT="current"
PURE_OS_PREVIOUS="previous"
PURE_OS_FACTORY="factory"
PURE_OS_VERSION_MAJOR=""
PURE_OS_VERSION_MINOR=""
PURE_OS_VERSION_PATCH=""
PURE_OS_GIT_TAG=""
PURE_US_GIT_REV=""
PURE_OS_GIT_BRANCH=""
MUDITAOS_PARTITION_PRIMARY="MUDITAOS"
MUDITAOS_PARTITION_RECOVERY="RECOVER"
MUDITAOS_CURRENT="current"
MUDITAOS_PREVIOUS="previous"
MUDITAOS_FACTORY="factory"
MUDITAOS_UPDATES="updates"
MUDITAOS_VERSION_MAJOR=""
MUDITAOS_VERSION_MINOR=""
MUDITAOS_VERSION_PATCH=""
MUDITAOS_GIT_TAG=""
MUDITAUS_GIT_REV=""
MUDITAOS_GIT_BRANCH=""

IMAGE_FILES="data assets country-codes.db Luts.bin user .boot.json .boot.json.crc32"
IMAGE_MOVE_TO_ROOT="user .boot.json .boot.json.crc32"


@@ 31,12 32,12 @@ check_target_linux() {
    check_any_arch "${@}" '(GNU/Linux)'
}

PURE_OS_GIT_TAG=`git describe --tags | awk -F'-' '{print $2}'`
PURE_OS_GIT_REV=`git log --pretty=format:'%h' -n 1`
PURE_OS_GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
MUDITAOS_GIT_TAG=`git describe --tags | awk -F'-' '{print $2}'`
MUDITAOS_GIT_REV=`git log --pretty=format:'%h' -n 1`
MUDITAOS_GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`

version=( ${PURE_OS_GIT_TAG//./ } )
PURE_OS_VERSION_STRING=$PURE_OS_GIT_TAG
PURE_OS_VERSION_MAJOR=${version[0]}
PURE_OS_VERSION_MINOR=${version[1]}
PURE_OS_VERSION_PATCH=${version[2]}
version=( ${MUDITAOS_GIT_TAG//./ } )
MUDITAOS_VERSION_STRING=$MUDITAOS_GIT_TAG
MUDITAOS_VERSION_MAJOR=${version[0]}
MUDITAOS_VERSION_MINOR=${version[1]}
MUDITAOS_VERSION_PATCH=${version[2]}

M config/genupdatepkg.sh => config/genupdatepkg.sh +10 -10
@@ 88,13 88,13 @@ fi
vjson=update/tmp/version.json
cp config/version.json.template $vjson

sed -i -e 's/__GIT_BRANCH__/'$PURE_OS_GIT_BRANCH'/g' $vjson
sed -i -e 's/__GIT_TAG__/'$PURE_OS_GIT_TAG'/g' $vjson
sed -i -e 's/__GIT_REVISION__/'$PURE_OS_GIT_REV'/g' $vjson
sed -i -e 's/__GIT_BRANCH__/'$MUDITAOS_GIT_BRANCH'/g' $vjson
sed -i -e 's/__GIT_TAG__/'$MUDITAOS_GIT_TAG'/g' $vjson
sed -i -e 's/__GIT_REVISION__/'$MUDITAOS_GIT_REV'/g' $vjson

sed -i -e 's/__VERSION_MAJOR__/'$PURE_OS_VERSION_MAJOR'/g' $vjson
sed -i -e 's/__VERSION_MINOR__/'$PURE_OS_VERSION_MINOR'/g' $vjson
sed -i -e 's/__VERSION_PATCH__/'$PURE_OS_VERSION_PATCH'/g' $vjson
sed -i -e 's/__VERSION_MAJOR__/'$MUDITAOS_VERSION_MAJOR'/g' $vjson
sed -i -e 's/__VERSION_MINOR__/'$MUDITAOS_VERSION_MINOR'/g' $vjson
sed -i -e 's/__VERSION_PATCH__/'$MUDITAOS_VERSION_PATCH'/g' $vjson

BUILD_HOST=`uname -r`
BUILD_USER=`whoami`


@@ 134,11 134,11 @@ fi

rm -f update/*.tar
curpwd=`pwd`
vstr=$PURE_OS_VERSION_MAJOR.$PURE_OS_VERSION_MINOR.$PURE_OS_VERSION_PATCH-$PURE_OS_GIT_REV
vstr=$MUDITAOS_VERSION_MAJOR.$MUDITAOS_VERSION_MINOR.$MUDITAOS_VERSION_PATCH-$MUDITAOS_GIT_REV
echo -ne "-- "
cd update/tmp && rhash -ru checksums.txt .
cd $curpwd
echo "-- create tar update/pureos-$vstr.tar"
cd update/tmp && tar -cf ../pureos-$vstr.tar .
echo "-- create tar update/muditaos-$vstr.tar"
cd update/tmp && tar -cf ../muditaos-$vstr.tar .
cd $curpwd
ls -alh update/pureos-$vstr.tar
ls -alh update/muditaos-$vstr.tar

M config/partition_emmc.sh => config/partition_emmc.sh +4 -4
@@ 79,10 79,10 @@ part1=$(sfdisk $dev --dump | grep bootable | awk '{print $1}')
part2=$(sfdisk $dev --dump | tail -n 1 | awk '{print $1}')

echo "create FATs"
echo "FAT: $PURE_PARTITION_PRIMARY $part1"
mkfs.vfat -n $PURE_PARTITION_PRIMARY $part1
echo "FAT: $PURE_PARTITION_RECOVERY $part2"
mkfs.vfat -n $PURE_PARTITION_RECOVERY $part2
echo "FAT: $MUDITAOS_PARTITION_PRIMARY $part1"
mkfs.vfat -n $MUDITAOS_PARTITION_PRIMARY $part1
echo "FAT: $MUDITAOS_PARTITION_RECOVERY $part2"
mkfs.vfat -n $MUDITAOS_PARTITION_RECOVERY $part2

echo "probe new partitions to OS"
partprobe

M flash_eMMC.sh => flash_eMMC.sh +30 -29
@@ 16,71 16,72 @@ fi

check_target_rt1051 "$BUILD_PATH"

PURE_DEV=/dev/disk/by-id/usb-NXP_SEMI_NXP_MASS_STORAGE_0123456789ABCDEF-0:0-part1
PURE_DEV_RECOVER=/dev/disk/by-id/usb-NXP_SEMI_NXP_MASS_STORAGE_0123456789ABCDEF-0:0-part2
PURE_DISK=`readlink -f $PURE_DEV`
PURE_DISK_RECOVER=`readlink -f $PURE_DEV_RECOVER`
MUDITAOS_DEV=/dev/disk/by-id/usb-NXP_SEMI_NXP_MASS_STORAGE_0123456789ABCDEF-0:0-part1
MUDITAOS_DEV_RECOVER=/dev/disk/by-id/usb-NXP_SEMI_NXP_MASS_STORAGE_0123456789ABCDEF-0:0-part2
MUDITAOS_DISK=`readlink -f $MUDITAOS_DEV`
MUDITAOS_DISK_RECOVER=`readlink -f $MUDITAOS_DEV_RECOVER`
# check if already mouted

MOUNT_ENTRY_RECOVER=$(grep "$PURE_DISK_RECOVER" /etc/mtab)
MOUNT_ENTRY=$(grep "$PURE_DISK" /etc/mtab)
MOUNT_ENTRY_RECOVER=$(grep "$MUDITAOS_DISK_RECOVER" /etc/mtab)
MOUNT_ENTRY=$(grep "$MUDITAOS_DISK" /etc/mtab)
if [ $? -ne 0 ]; then
	>&2 echo "PurePhone not mounted. Mount or retry with Ozone. https://github.com/muditacom/PurePhone/blob/master/doc/running_on_phone.md#eMMC_upload"
	exit 2
fi

PURE_PATH=$(echo $MOUNT_ENTRY | awk -F " " '{print $2}')
MUDITAOS_PATH=$(echo $MOUNT_ENTRY | awk -F " " '{print $2}')
# unespace
PURE_PATH_CURRENT=$(echo -e $PURE_PATH)/current
PURE_PATH_ROOT=$(echo -e $PURE_PATH)
MUDITAOS_PATH_CURRENT=$(echo -e $MUDITAOS_PATH)/current
MUDITAOS_PATH_ROOT=$(echo -e $MUDITAOS_PATH)

echo "PurePhone remove all files"
rm -rf "$PURE_PATH_ROOT"/* -r &>/dev/null || echo "PurePhone disk alread empty"
rm -f "$PURE_PATH_ROOT"/.boot.ini
rm -f "$PURE_PATH_ROOT"/.boot.ini.crc32
rm -rf "$MUDITAOS_PATH_ROOT"/* -r &>/dev/null || echo "PurePhone disk alread empty"
rm -f "$MUDITAOS_PATH_ROOT"/.boot.ini
rm -f "$MUDITAOS_PATH_ROOT"/.boot.ini.crc32

echo "Create directories"
mkdir -p $PURE_PATH_ROOT/$PURE_OS_CURRENT
mkdir -p $PURE_PATH_ROOT/$PURE_OS_PREVIOUS
mkdir -p $PURE_PATH_ROOT/$PURE_OS_FACTORY
mkdir -p $MUDITAOS_PATH_ROOT/$MUDITAOS_CURRENT
mkdir -p $MUDITAOS_PATH_ROOT/$MUDITAOS_PREVIOUS
mkdir -p $MUDITAOS_PATH_ROOT/$MUDITAOS_FACTORY
mkdir -p $MUDITAOS_PATH_ROOT/$MUDITAOS_UPDATES

# sudo sync $PURE_DEV
# sudo sync $MUDITAOS_DEV

echo "PurePhone copy build files"
cp -v $BUILD_PATH/boot.bin "$PURE_PATH_CURRENT"/  # | sed 's/'-\>'/'→'/g'
cp -v $BUILD_PATH/boot.bin "$MUDITAOS_PATH_CURRENT"/  # | sed 's/'-\>'/'→'/g'

for file in $IMAGE_FILES; do
	echo Copying $file
	cp -vr $BUILD_PATH/$file "$PURE_PATH_CURRENT"/
	cp -vr $BUILD_PATH/$file "$MUDITAOS_PATH_CURRENT"/
done

for file in $IMAGE_MOVE_TO_ROOT; do
	echo "Moving $PURE_PATH_CURRENT/$file to $PURE_PATH_ROOT"
	mv "$PURE_PATH_CURRENT"/"$file" "$PURE_PATH_ROOT"/
	echo "Moving $MUDITAOS_PATH_CURRENT/$file to $MUDITAOS_PATH_ROOT"
	mv "$MUDITAOS_PATH_CURRENT"/"$file" "$MUDITAOS_PATH_ROOT"/
done

# sudo sync $PURE_DEV # https://unix.stackexchange.com/a/345950
# sudo sync $MUDITAOS_DEV # https://unix.stackexchange.com/a/345950
echo -e "PurePhone copied\n"

PURE_PARTITION=$(lsblk -nlp $PURE_DISK | tail +2 | awk '{print $1}')
MUDITAOS_PARTITION=$(lsblk -nlp $MUDITAOS_DISK | tail +2 | awk '{print $1}')

if [ -z $PURE_PARTITION ]; then
       PURE_PARTITION=$PURE_DISK # it is formatted like so apparently
if [ -z $MUDITAOS_PARTITION ]; then
       MUDITAOS_PARTITION=$MUDITAOS_DISK # it is formatted like so apparently
fi

if [ "$MOUNT_ENTRY" != "" ]; then
	echo "Unmounting disk: $PURE_DISK ($MOUNT_ENTRY)"
	udisksctl unmount -b $PURE_DISK > /dev/null
	echo "Unmounting disk: $MUDITAOS_DISK ($MOUNT_ENTRY)"
#	udisksctl unmount -b $MUDITAOS_DISK > /dev/null
fi

if [ "$MOUNT_ENTRY_RECOVER" != "" ]; then
	echo "Unmounting disk: $PURE_DISK_RECOVER ($MOUNT_ENTRY_RECOVER)"
	udisksctl unmount -b $PURE_DISK_RECOVER > /dev/null
	echo "Unmounting disk: $MUDITAOS_DISK_RECOVER ($MOUNT_ENTRY_RECOVER)"
#	udisksctl unmount -b $MUDITAOS_DISK_RECOVER > /dev/null
fi

sleep 1
echo "PurePhone unmouted"
echo "Ejecting USB"
timeout --signal=SIGINT 1 udisksctl power-off -b $PURE_DISK
#timeout --signal=SIGINT 1 udisksctl power-off -b $MUDITAOS_DISK
echo
echo "Reset your phone now"

M generate_fatfs_image.sh => generate_fatfs_image.sh +1 -1
@@ 62,7 62,7 @@ unit: sectors

PART1="$IMAGE_NAME@@1048576"
PART2="$IMAGE_NAME@@14604566528"
mformat -i "$PART1" -F -T 28522496 -v PUREOS
mformat -i "$PART1" -F -T 28522496 -v MUDITAOS
mformat -i "$PART2" -F -T 2097152 -v RECOVER
mmd -i "$PART1" ::/current
cd "$SRC_DATA"

M module-apps/application-desktop/ApplicationDesktop.hpp => module-apps/application-desktop/ApplicationDesktop.hpp +1 -1
@@ 11,7 11,7 @@
#include <service-cellular/messages/CellularMessage.hpp>
#include <service-db/messages/DBNotificationMessage.hpp>
#include <module-db/queries/notifications/QueryNotificationsGetAll.hpp>
#include <service-desktop/endpoints/update/UpdatePureOS.hpp>
#include <service-desktop/endpoints/update/UpdateMuditaOS.hpp>
#include <module-services/service-desktop/ServiceDesktop.hpp>
#include "DesktopMessages.hpp"


M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +3 -3
@@ 13,7 13,7 @@ ServiceDesktop::ServiceDesktop() : sys::Service(service::name::service_desktop, 
{
    LOG_INFO("[ServiceDesktop] Initializing");

    updateOS = std::make_unique<UpdatePureOS>(this);
    updateOS = std::make_unique<UpdateMuditaOS>(this);
}

ServiceDesktop::~ServiceDesktop()


@@ 61,13 61,13 @@ sys::ReturnCodes ServiceDesktop::InitHandler()

        if (updateOsMsg != nullptr &&
            updateOsMsg->messageType == updateos::UpdateMessageType::UpdateCheckForUpdateOnce) {
            fs::path file = UpdatePureOS::checkForUpdate();
            fs::path file = UpdateMuditaOS::checkForUpdate();

            if (file.has_filename()) {
                /* send info to applicationDesktop that there is an update waiting */
                auto msgToSend =
                    std::make_shared<sdesktop::UpdateOsMessage>(updateos::UpdateMessageType::UpdateFoundOnBoot, file);
                msgToSend->updateStats.versioInformation = UpdatePureOS::getVersionInfoFromFile(file);
                msgToSend->updateStats.versioInformation = UpdateMuditaOS::getVersionInfoFromFile(file);
                sys::Bus::SendUnicast(msgToSend, app::name_desktop, this);
            }
        }

M module-services/service-desktop/ServiceDesktop.hpp => module-services/service-desktop/ServiceDesktop.hpp +2 -2
@@ 4,7 4,7 @@
#pragma once

#include "WorkerDesktop.hpp"
#include "module-services/service-desktop/endpoints/update/UpdatePureOS.hpp"
#include "module-services/service-desktop/endpoints/update/UpdateMuditaOS.hpp"

namespace service::name
{


@@ 28,6 28,6 @@ class ServiceDesktop : public sys::Service
    sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override;
    sys::Message_t DataReceivedHandler(sys::DataMessage *msg, sys::ResponseMessage *resp) override;

    std::unique_ptr<UpdatePureOS> updateOS;
    std::unique_ptr<UpdateMuditaOS> updateOS;
    std::unique_ptr<WorkerDesktop> desktopWorker;
};

M module-services/service-desktop/endpoints/CMakeLists.txt => module-services/service-desktop/endpoints/CMakeLists.txt +1 -1
@@ 33,7 33,7 @@ target_sources(${PROJECT_NAME}
		"factoryReset/FactoryReset.cpp"
		"restore/RestoreEndpoint.cpp"
		"update/UpdateEndpoint.cpp"
		"update/UpdatePureOS.cpp"
		"update/UpdateMuditaOS.cpp"
		"developerMode/DeveloperModeEndpoint.cpp"
		"developerMode/DeveloperModeHelper.cpp"


R module-services/service-desktop/endpoints/update/UpdatePureOS.cpp => module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp +34 -34
@@ 1,7 1,7 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "UpdatePureOS.hpp"
#include "UpdateMuditaOS.hpp"
#if defined(TARGET_RT1051)
#include "board/cross/eMMC/eMMC.hpp"
#endif


@@ 27,26 27,26 @@ json11::Json FileInfo::to_json() const
        {"name", fileName}, {"size", std::to_string(fileSize)}, {"crc32", std::to_string(fileCRC32)}};
}

UpdatePureOS::UpdatePureOS(ServiceDesktop *ownerService) : owner(ownerService)
UpdateMuditaOS::UpdateMuditaOS(ServiceDesktop *ownerService) : owner(ownerService)
{
    status = updateos::UpdateState::Initial;
}

updateos::UpdateError UpdatePureOS::setUpdateFile(fs::path updateFileToUse)
updateos::UpdateError UpdateMuditaOS::setUpdateFile(fs::path updateFileToUse)
{
    updateFile = purefs::dir::os_updates / updateFileToUse;
    if (vfs.fileExists(updateFile.c_str())) {
        versioInformation = UpdatePureOS::getVersionInfoFromFile(updateFile);
        versioInformation = UpdateMuditaOS::getVersionInfoFromFile(updateFile);
        if (mtar_open(&updateTar, updateFile.c_str(), "r") == MTAR_ESUCCESS) {
            totalBytes = vfs.filelength(updateTar.stream);
        }
        else {
            informError("UpdatePureOS::setUpdateFile can't open TAR file %s", updateFile.c_str());
            informError("UpdateMuditaOS::setUpdateFile can't open TAR file %s", updateFile.c_str());
            return updateos::UpdateError::CantOpenUpdateFile;
        }
    }
    else {
        informError("UpdatePureOS::setUpdateFile %s does not exist", updateFile.c_str());
        informError("UpdateMuditaOS::setUpdateFile %s does not exist", updateFile.c_str());
        return updateos::UpdateError::CantOpenUpdateFile;
    }



@@ 54,7 54,7 @@ updateos::UpdateError UpdatePureOS::setUpdateFile(fs::path updateFileToUse)
    return updateos::UpdateError::NoError;
}

updateos::UpdateError UpdatePureOS::runUpdate()
updateos::UpdateError UpdateMuditaOS::runUpdate()
{
    informDebug("Prepraring temp dir");



@@ 114,7 114,7 @@ updateos::UpdateError UpdatePureOS::runUpdate()
    return err;
}

updateos::UpdateError UpdatePureOS::unpackUpdate()
updateos::UpdateError UpdateMuditaOS::unpackUpdate()
{
    mtar_header_t tarHeader;
    filesInUpdatePackage.clear();


@@ 144,7 144,7 @@ updateos::UpdateError UpdatePureOS::unpackUpdate()
    return updateos::UpdateError::NoError;
}

updateos::UpdateError UpdatePureOS::verifyChecksums()
updateos::UpdateError UpdateMuditaOS::verifyChecksums()
{
    status = updateos::UpdateState::ChecksumVerification;



@@ 178,7 178,7 @@ updateos::UpdateError UpdatePureOS::verifyChecksums()
    return updateos::UpdateError::NoError;
}

updateos::UpdateError UpdatePureOS::verifyVersion()
updateos::UpdateError UpdateMuditaOS::verifyVersion()
{
    status = updateos::UpdateState::VersionVerificiation;



@@ 199,13 199,13 @@ updateos::UpdateError UpdatePureOS::verifyVersion()
    return updateos::UpdateError::NoError;
}

updateos::UpdateError UpdatePureOS::updateBootloader()
updateos::UpdateError UpdateMuditaOS::updateBootloader()
{
    informDebug("updateBootloader noError");
    return updateos::UpdateError::NoError;
}

unsigned long UpdatePureOS::getExtractedFileCRC32(const std::string &filePath)
unsigned long UpdateMuditaOS::getExtractedFileCRC32(const std::string &filePath)
{
    for (auto file : filesInUpdatePackage) {
        if (file.fileName == filePath) {


@@ 215,7 215,7 @@ unsigned long UpdatePureOS::getExtractedFileCRC32(const std::string &filePath)
    return 0;
}

void UpdatePureOS::getChecksumInfo(const std::string &infoLine, std::string &filePath, unsigned long *fileCRC32Long)
void UpdateMuditaOS::getChecksumInfo(const std::string &infoLine, std::string &filePath, unsigned long *fileCRC32Long)
{
    std::size_t lastSpacePos = infoLine.find_last_of(' ');
    if (lastSpacePos > 0) {


@@ 232,7 232,7 @@ void UpdatePureOS::getChecksumInfo(const std::string &infoLine, std::string &fil
    }
}

updateos::UpdateError UpdatePureOS::prepareRoot()
updateos::UpdateError UpdateMuditaOS::prepareRoot()
{
    informDebug("prepareRoot()");
    int ret;


@@ 289,7 289,7 @@ updateos::UpdateError UpdatePureOS::prepareRoot()
    return updateBootJSON();
}

updateos::UpdateError UpdatePureOS::updateBootJSON()
updateos::UpdateError UpdateMuditaOS::updateBootJSON()
{
    unsigned long bootJSONAbsoulteCRC = 0;
    fs::path bootJSONAbsoulte         = purefs::dir::eMMC_disk / purefs::file::boot_json;


@@ 322,7 322,7 @@ updateos::UpdateError UpdatePureOS::updateBootJSON()
    return updateos::UpdateError::NoError;
}

bool UpdatePureOS::unpackFileToTemp(mtar_header_t &h, unsigned long *crc32)
bool UpdateMuditaOS::unpackFileToTemp(mtar_header_t &h, unsigned long *crc32)
{
    std::unique_ptr<unsigned char[]> readBuf(new unsigned char[purefs::buffer::tar_buf]);
    const fs::path fullPath = getUpdateTmpChild(h.name);


@@ 380,7 380,7 @@ bool UpdatePureOS::unpackFileToTemp(mtar_header_t &h, unsigned long *crc32)
    return true;
}

updateos::UpdateError UpdatePureOS::cleanupAfterUpdate()
updateos::UpdateError UpdateMuditaOS::cleanupAfterUpdate()
{
    if (vfs.isDir(updateTempDirectory.c_str()) && vfs.deltree(updateTempDirectory.c_str())) {
        informError("ff_deltree failed on %s", updateTempDirectory.c_str());


@@ 395,12 395,12 @@ updateos::UpdateError UpdatePureOS::cleanupAfterUpdate()
    return updateos::UpdateError::NoError;
}

const fs::path UpdatePureOS::getUpdateTmpChild(const fs::path &childPath)
const fs::path UpdateMuditaOS::getUpdateTmpChild(const fs::path &childPath)
{
    return updateTempDirectory / childPath;
}

updateos::UpdateError UpdatePureOS::prepareTempDirForUpdate()
updateos::UpdateError UpdateMuditaOS::prepareTempDirForUpdate()
{
    status = updateos::UpdateState::CreatingDirectories;



@@ 457,7 457,7 @@ updateos::UpdateError UpdatePureOS::prepareTempDirForUpdate()
    return updateos::UpdateError::NoError;
}

updateos::BootloaderUpdateError UpdatePureOS::writeBootloader(fs::path bootloaderFile)
updateos::BootloaderUpdateError UpdateMuditaOS::writeBootloader(fs::path bootloaderFile)
{
    status = updateos::UpdateState::UpdatingBootloader;



@@ 503,21 503,21 @@ updateos::BootloaderUpdateError UpdatePureOS::writeBootloader(fs::path bootloade
#endif
}

const json11::Json UpdatePureOS::getVersionInfoFromFile(const fs::path &updateFile)
const json11::Json UpdateMuditaOS::getVersionInfoFromFile(const fs::path &updateFile)
{
    if (vfs.fileExists(updateFile.c_str())) {
        mtar_t tar;
        mtar_header_t h;

        if (mtar_open(&tar, updateFile.c_str(), "r") == MTAR_EOPENFAIL) {
            LOG_INFO("UpdatePureOS::getVersionInfoFromFile %s can't open", updateFile.c_str());
            LOG_INFO("UpdateMuditaOS::getVersionInfoFromFile %s can't open", updateFile.c_str());
            return json11::Json();
        }

        std::unique_ptr<char[]> versionFilename(new char[purefs::buffer::crc_buf]);
        sprintf(versionFilename.get(), "./%s", updateos::file::version.c_str());
        if (mtar_find(&tar, versionFilename.get(), &h) == MTAR_ENOTFOUND) {
            LOG_INFO("UpdatePureOS::getVersionInfoFromFile can't find %s in %s",
            LOG_INFO("UpdateMuditaOS::getVersionInfoFromFile can't find %s in %s",
                     updateos::file::version.c_str(),
                     updateFile.c_str());



@@ 528,7 528,7 @@ const json11::Json UpdatePureOS::getVersionInfoFromFile(const fs::path &updateFi
        /* this file should never be larger then purefs::buffer::tar_buf */
        std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);
        if (mtar_read_data(&tar, readBuf.get(), h.size) != MTAR_ESUCCESS) {
            LOG_INFO("UpdatePureOS::getVersionInfoFromFile can't read %s in %s",
            LOG_INFO("UpdateMuditaOS::getVersionInfoFromFile can't read %s in %s",
                     updateos::file::version.c_str(),
                     updateFile.c_str());



@@ 542,7 542,7 @@ const json11::Json UpdatePureOS::getVersionInfoFromFile(const fs::path &updateFi
        std::string dataPackage  = std::string(static_cast<char *>(readBuf.get()), h.size);
        json11::Json versionInfo = json11::Json::parse(dataPackage, parserError);
        if (parserError != "") {
            LOG_INFO("UpdatePureOS::getVersionInfoFromFile can't parse %s as JSON error: \"%s\"",
            LOG_INFO("UpdateMuditaOS::getVersionInfoFromFile can't parse %s as JSON error: \"%s\"",
                     updateos::file::version.c_str(),
                     parserError.c_str());
            return json11::Json();


@@ 551,29 551,29 @@ const json11::Json UpdatePureOS::getVersionInfoFromFile(const fs::path &updateFi
        return versionInfo;
    }
    else {
        LOG_INFO("UpdatePureOS::getVersionInfoFromFile %s does not exist", updateFile.c_str());
        LOG_INFO("UpdateMuditaOS::getVersionInfoFromFile %s does not exist", updateFile.c_str());
    }

    return json11::Json();
}

bool UpdatePureOS::isUpgradeToCurrent(const std::string &versionToCompare)
bool UpdateMuditaOS::isUpgradeToCurrent(const std::string &versionToCompare)
{
    return true;
}

const fs::path UpdatePureOS::checkForUpdate()
const fs::path UpdateMuditaOS::checkForUpdate()
{
    std::vector<vfs::DirectoryEntry> fileList =
        vfs.listdir(purefs::dir::os_updates.c_str(), updateos::extension::update, true);
    for (auto &file : fileList) {

        json11::Json versionInfo = UpdatePureOS::getVersionInfoFromFile(purefs::dir::os_updates / file.fileName);
        json11::Json versionInfo = UpdateMuditaOS::getVersionInfoFromFile(purefs::dir::os_updates / file.fileName);
        if (versionInfo.is_null())
            continue;

        if (versionInfo[purefs::json::os_version][purefs::json::version_string].is_string()) {
            if (UpdatePureOS::isUpgradeToCurrent(
            if (UpdateMuditaOS::isUpgradeToCurrent(
                    versionInfo[purefs::json::os_version][purefs::json::version_string].string_value())) {
                return purefs::dir::os_updates / file.fileName;
            }


@@ 583,12 583,12 @@ const fs::path UpdatePureOS::checkForUpdate()
    return fs::path();
}

updateos::UpdateError UpdatePureOS::updateUserData()
updateos::UpdateError UpdateMuditaOS::updateUserData()
{
    return updateos::UpdateError::NoError;
}

void UpdatePureOS::informError(const char *format, ...)
void UpdateMuditaOS::informError(const char *format, ...)
{
    va_list argptr;
    std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);


@@ 604,7 604,7 @@ void UpdatePureOS::informError(const char *format, ...)
    sys::Bus::SendUnicast(msgToSend, app::name_desktop, owner);
}

void UpdatePureOS::informDebug(const char *format, ...)
void UpdateMuditaOS::informDebug(const char *format, ...)
{
    va_list argptr;
    std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);


@@ 615,7 615,7 @@ void UpdatePureOS::informDebug(const char *format, ...)
    LOG_DEBUG("UPDATE_DEBUG %s", readBuf.get());
}

void UpdatePureOS::informUpdate(const char *format, ...)
void UpdateMuditaOS::informUpdate(const char *format, ...)
{
    va_list argptr;
    std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);

R module-services/service-desktop/endpoints/update/UpdatePureOS.hpp => module-services/service-desktop/endpoints/update/UpdateMuditaOS.hpp +2 -2
@@ 104,10 104,10 @@ struct FileInfo
    unsigned long fileCRC32;
};

class UpdatePureOS : public updateos::UpdateStats
class UpdateMuditaOS : public updateos::UpdateStats
{
  public:
    UpdatePureOS(ServiceDesktop *ownerService);
    UpdateMuditaOS(ServiceDesktop *ownerService);

    updateos::UpdateError runUpdate();
    updateos::UpdateError prepareTempDirForUpdate();

M module-services/service-desktop/messages/DesktopMessages.hpp => module-services/service-desktop/messages/DesktopMessages.hpp +1 -1
@@ 5,7 5,7 @@

#include "Service/Message.hpp"
#include "MessageType.hpp"
#include "UpdatePureOS.hpp"
#include "UpdateMuditaOS.hpp"
#include <vfs.hpp>

namespace sdesktop

M module-services/service-desktop/tests/CMakeLists.txt => module-services/service-desktop/tests/CMakeLists.txt +2 -2
@@ 1,4 1,4 @@
file (COPY "${CMAKE_CURRENT_LIST_DIR}/pureos-unittest.tar" DESTINATION "${CMAKE_BINARY_DIR}/sys/updates")
file (COPY "${CMAKE_CURRENT_LIST_DIR}/muditaos-unittest.tar" DESTINATION "${CMAKE_BINARY_DIR}/sys/updates")
file (COPY "${CMAKE_CURRENT_LIST_DIR}/factory-test" DESTINATION "${CMAKE_BINARY_DIR}/sys")

add_catch2_executable(


@@ 7,7 7,7 @@ add_catch2_executable(
	SRCS
		"${CMAKE_CURRENT_LIST_DIR}/unittest.cpp"
		"${CMAKE_CURRENT_LIST_DIR}/tests-main.cpp"
		"../endpoints/update/UpdatePureOS.cpp"
		"../endpoints/update/UpdateMuditaOS.cpp"
		"../endpoints/factoryReset/FactoryReset.cpp"
		"${CMAKE_CURRENT_LIST_DIR}/../parser/MessageHandler.cpp"


R module-services/service-desktop/tests/pureos-unittest.tar => module-services/service-desktop/tests/muditaos-unittest.tar +0 -0
M module-services/service-desktop/tests/unittest.cpp => module-services/service-desktop/tests/unittest.cpp +3 -3
@@ 4,7 4,7 @@
#include "Common/Common.hpp"
#include "ContactRecord.hpp"
#include "ParserUtils.hpp"
#include "module-services/service-desktop/endpoints/update/UpdatePureOS.hpp"
#include "module-services/service-desktop/endpoints/update/UpdateMuditaOS.hpp"
#include "module-services/service-desktop/endpoints/factoryReset/FactoryReset.hpp"
#include "ParserFSM.hpp"
#include "contacts/ContactHelper.hpp"


@@ 29,12 29,12 @@ struct vfs_initializer

TEST_CASE("System Update Tests")
{
    UpdatePureOS updateOS(nullptr);
    UpdateMuditaOS updateOS(nullptr);

    updateos::UpdateError err = updateOS.prepareTempDirForUpdate();
    REQUIRE(err == updateos::UpdateError::NoError);

    updateOS.setUpdateFile("pureos-unittest.tar");
    updateOS.setUpdateFile("muditaos-unittest.tar");

    err = updateOS.unpackUpdate();
    REQUIRE(err == updateos::UpdateError::NoError);