mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-19 12:38:19 +00:00
Add an LVGL front end for browsing, installing, updating, and launching nxpkg entries. Keep network and install work off the UI path, and stop launched apps with SIGTERM. Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
164 lines
6.3 KiB
C
164 lines
6.3 KiB
C
/****************************************************************************
|
|
* apps/system/nxpkg/pkg.h
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#ifndef __APPS_SYSTEM_NXPKG_PKG_H
|
|
#define __APPS_SYSTEM_NXPKG_PKG_H
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <system/nxpkg.h>
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
/****************************************************************************
|
|
* Pre-processor Definitions
|
|
****************************************************************************/
|
|
|
|
#define PKG_REPO_DIR PKG_ROOT_DIR
|
|
#define PKG_REPO_INDEX PKG_ROOT_DIR "/index.jsn"
|
|
#define PKG_REPO_SOURCE PKG_ROOT_DIR "/repo.url"
|
|
#define PKG_REPO_INSTALLED PKG_ROOT_DIR "/instpkg.jsn"
|
|
#define PKG_STORE_DIR PKG_ROOT_DIR "/pkgs"
|
|
#define PKG_TMP_DIR PKG_ROOT_DIR "/tmp"
|
|
#define PKG_TMP_PKG_DIR PKG_ROOT_DIR "/tmp/pkg"
|
|
|
|
/* Bound metadata allocations and artifact downloads. */
|
|
|
|
#define PKG_TEXT_MAX_SIZE (256 * 1024)
|
|
#define PKG_DOWNLOAD_MAX_SIZE (32 * 1024 * 1024)
|
|
|
|
static inline void *pkg_malloc(size_t size)
|
|
{
|
|
return malloc(size);
|
|
}
|
|
|
|
static inline void *pkg_zalloc(size_t size)
|
|
{
|
|
return calloc(1, size);
|
|
}
|
|
|
|
static inline void *pkg_realloc(void *ptr, size_t size)
|
|
{
|
|
return realloc(ptr, size);
|
|
}
|
|
|
|
static inline void pkg_free(void *ptr)
|
|
{
|
|
free(ptr);
|
|
}
|
|
|
|
/****************************************************************************
|
|
* Public Types
|
|
****************************************************************************/
|
|
|
|
enum pkg_txn_state_e
|
|
{
|
|
PKG_TXN_IDLE = 0,
|
|
PKG_TXN_FETCHING,
|
|
PKG_TXN_VERIFIED,
|
|
PKG_TXN_STAGED,
|
|
PKG_TXN_COMPAT_OK,
|
|
PKG_TXN_ACTIVATED,
|
|
PKG_TXN_CLEANUP,
|
|
PKG_TXN_FAILED,
|
|
PKG_TXN_RESTORE
|
|
};
|
|
|
|
/****************************************************************************
|
|
* Public Function Prototypes
|
|
****************************************************************************/
|
|
|
|
const char *pkg_manifest_type_str(enum pkg_payload_type_e type);
|
|
int pkg_manifest_validate(FAR const struct pkg_manifest_s *manifest);
|
|
bool pkg_validate_path_component(FAR const char *value);
|
|
int pkg_manifest_parse_type(FAR const char *value,
|
|
FAR enum pkg_payload_type_e *type);
|
|
|
|
int pkg_store_prepare_layout(void);
|
|
int pkg_store_ensure_package_root(FAR const char *name);
|
|
int pkg_store_ensure_version_dir(FAR const char *name,
|
|
FAR const char *version);
|
|
int pkg_store_format_index_path(FAR char *buffer, size_t size);
|
|
int pkg_store_format_repo_source_path(FAR char *buffer, size_t size);
|
|
int pkg_store_format_installed_path(FAR char *buffer, size_t size);
|
|
int pkg_store_format_package_root(FAR char *buffer, size_t size,
|
|
FAR const char *name);
|
|
int pkg_store_format_version_path(FAR char *buffer, size_t size,
|
|
FAR const char *name,
|
|
FAR const char *version);
|
|
int pkg_store_format_current_path(FAR char *buffer, size_t size,
|
|
FAR const char *name);
|
|
int pkg_store_format_previous_path(FAR char *buffer, size_t size,
|
|
FAR const char *name);
|
|
int pkg_store_format_txn_path(FAR char *buffer, size_t size,
|
|
FAR const char *name);
|
|
int pkg_store_format_lock_path(FAR char *buffer, size_t size,
|
|
FAR const char *name);
|
|
int pkg_store_format_download_path(FAR char *buffer, size_t size,
|
|
FAR const char *name,
|
|
FAR const char *version);
|
|
int pkg_store_read_text(FAR const char *path, FAR char **buffer);
|
|
int pkg_store_write_text_atomic(FAR const char *path, FAR const char *text);
|
|
int pkg_store_copy_file(FAR const char *src, FAR const char *dest);
|
|
int pkg_store_remove_file(FAR const char *path);
|
|
int pkg_store_remove_version_dir(FAR const char *name,
|
|
FAR const char *version);
|
|
|
|
const char *pkg_runtime_arch(void);
|
|
const char *pkg_runtime_compat(void);
|
|
int pkg_compat_check(FAR const struct pkg_manifest_s *manifest);
|
|
|
|
int pkg_hash_file_sha256(FAR const char *path,
|
|
FAR char digest[PKG_HASH_HEX_LEN + 1]);
|
|
|
|
int pkg_metadata_load_index_path(FAR const char *path,
|
|
FAR struct pkg_index_s *index);
|
|
int pkg_metadata_save_installed(FAR const struct pkg_installed_db_s *db);
|
|
int pkg_metadata_write_manifest(FAR const char *path,
|
|
FAR const struct pkg_manifest_s *manifest);
|
|
int pkg_metadata_print_installed(FAR FILE *stream,
|
|
FAR const struct pkg_installed_db_s *db);
|
|
|
|
const char *pkg_txn_state_str(enum pkg_txn_state_e state);
|
|
int pkg_txn_write_state(FAR const char *name, enum pkg_txn_state_e state);
|
|
int pkg_txn_clear_state(FAR const char *name);
|
|
|
|
bool pkg_source_is_url(FAR const char *source);
|
|
int pkg_resolve_artifact_source(FAR char *buffer, size_t size,
|
|
FAR const struct pkg_manifest_s *manifest);
|
|
int pkg_lock_create(FAR const char *path);
|
|
void pkg_lock_remove(FAR const char *path);
|
|
void pkg_reclaim_stale_lock(FAR const char *path);
|
|
int pkg_rollback(FAR const char *name);
|
|
int pkg_available(FAR FILE *stream);
|
|
int pkg_list(FAR FILE *stream);
|
|
|
|
void pkg_error(FAR const char *fmt, ...);
|
|
void pkg_info(FAR const char *fmt, ...);
|
|
|
|
#endif /* __APPS_SYSTEM_NXPKG_PKG_H */
|