Skip to content

Commit fd54a7c

Browse files
core+helper/Update to v2 manifest + gzip kpkgs
1 parent 6449354 commit fd54a7c

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

kpm-helper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import json
1010
import os
1111

12-
KPM_MANIFEST_VERSION=1
12+
KPM_MANIFEST_VERSION=2
1313
valid_supported_platforms = [
1414
"kindle",
1515
"kindle5",
@@ -101,7 +101,12 @@ def pack(args):
101101
print("Packing...")
102102

103103
packageFilename = os.path.join(args.output_path, f"{manifest['id']}_{'.'.join(str(x) for x in manifest['version'])}_{'-'.join(manifest.get('supported_platforms', ['kindleany']))}.kpkg")
104-
with tarfile.open(packageFilename, "w|xz", preset=args.compression) as file:
104+
if (args.compression != 0):
105+
file = tarfile.open(packageFilename, "w:gz", compresslevel=args.compression)
106+
else:
107+
file = tarfile.open(packageFilename, "w:")
108+
109+
with file:
105110
for source_item_name in os.listdir(args.pkg_path):
106111
if (source_item_name in ['rootfs', 'startup.sh']):
107112
print(f"[ERR] A file or folder with the name '{source_item_name}' was detected in the package - This is currently reserved for future use")

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project('kpm', 'c', version : '1.0.0', license : 'GPL', default_options: ['b_ndebug=if-release', 'c_std=gnu23'])
1+
project('kpm', 'c', version : '0.2.0', license : 'GPL', default_options: ['b_ndebug=if-release', 'c_std=gnu23'])
22

33
KPM_PLATFORM = meson.get_external_property('kindle_platform', get_option('kindle_platform'))
44
if KPM_PLATFORM == ''

src/include/kpm/kpm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
#include "semver.h"
1919

20-
#define KPM_MANIFEST_VERSION 1
20+
#define KPM_MANIFEST_VERSION 2
2121

2222
#define KPM_VERSION_MAJOR 0
23-
#define KPM_VERSION_MINOR 1
23+
#define KPM_VERSION_MINOR 2
2424
#define KPM_VERSION_PATCH 0
2525

2626
enum KPMResult
@@ -100,7 +100,7 @@ struct InstalledPackage
100100
char* author; /**< The package author */
101101
char* description; /**< The package description */
102102
struct SemVer version; /**< The package version */
103-
bool installed_as_dependency;
103+
bool installed_as_dependency; /**< Whether or not this package was installed as a dependency of another package */
104104
};
105105

106106
/**

src/index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ enum KPMResult KPM_UpdateIndex(struct KPM *kpm, struct KPMIO* kpmIO)
209209
if (cJSON_GetNumberValue(cJSON_GetObjectItem(json, "manifest_version")) > KPM_MANIFEST_VERSION)
210210
{
211211
kpmIO->log(KPM_VERBOSITY_ERROR, "Invalid manifest version, got %.0f, expected %i", cJSON_GetNumberValue(cJSON_GetObjectItem(json, "manifest_version")), KPM_MANIFEST_VERSION);
212+
kpmIO->log(KPM_VERBOSITY_ERROR, "You may need to update KPM, run: kpm install kpm or kpm upgrade");
212213
SimpleGET_Cleanup(&request);
213214
cJSON_Delete(json);
214215
continue;

src/kpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ enum KPMResult KPM_Initialise(struct KPM *kpm)
8686
) STRICT;
8787
)", NULL, NULL, NULL);
8888

89-
sqlite3_exec(kpm->db, "INSERT INTO repositories (id, url, name, description) VALUES ('kindlemodding', 'https://repo.kindlemodding.org/manifest.json', 'Official KMC Repo', 'The official KMC repo')", NULL, NULL, NULL);
89+
sqlite3_exec(kpm->db, "INSERT INTO repositories (id, url, name, description) VALUES ('kindlemodding', 'https://repo.kindlemodding.org/manifest.v2.json', 'Official KMC Repo', 'The official KMC repo') ON CONFLICT(id) DO UPDATE SET url='https://repo.kindlemodding.org/manifest.v2.json'", NULL, NULL, NULL);
9090

9191
char* query = asprintf_hd("INSERT OR REPLACE INTO installed_packages (id, repository, name, author, description, version_major, version_minor, version_patch, installed_as_dependency) VALUES ('kpm', 'kindlemodding', 'KPM', 'Hackerdude', 'The Kindle Package Manager allows you to install and uninstall apps and programs easily on your Kindle', %i, %i, %i, 0)", KPM_VERSION_MAJOR, KPM_VERSION_MINOR, KPM_VERSION_PATCH);
9292
sqlite3_exec(kpm->db, query, NULL, NULL, NULL);

0 commit comments

Comments
 (0)