/* app/builder/KMBuildExport.h
 *
 * Copyright (C) 2024 OpenKylin, Inc
 */

#ifndef __KMBUILDEXPORT_H__
#define __KMBUILDEXPORT_H__

#include "app/KMSubCommand.h"

#include "common/KMFile.h"

/**
 * @brief 	 将构建结果导出成ostree仓库
 * @note	 供kaiming-builder构建流程中调用
 */
class KMBuildExport : public KMSubCommand
{
    DECLARE_DYNCREATE(KMBuildExport);

public:
    KMBuildExport();
    virtual ~KMBuildExport();

    int despose(int argc, char **argv) override;

private:
    void init(int argc, char **argv);
    int run();

    void collectExtraData();

    void validateExports();
    void validateDesktopFile(std::string &icon, bool &activatable);
    void validateIcon(const std::string &icon);
    void validateExportedIcons();
    void validateServiceFile(bool activatable);

    void metadataGetArch();
    void addFileToMtree(KMFile &file, const std::string &name);

private:
    class Options;
    class Private;
    std::unique_ptr<Private> d;
};

#endif // !__KMBUILDEXPORT_H__
