Skip to content

Commit 6bfcb1e

Browse files
committed
pkg_install: initial commit
1 parent 4f9b94c commit 6bfcb1e

4 files changed

Lines changed: 166 additions & 2 deletions

File tree

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ endif
2626
CFLAGS := -Wall -g -O0
2727

2828
SUBDIRS := bundles/core bundles/http2_get bundles/suspend \
29-
bundles/launch bundles/hbldr
29+
bundles/launch bundles/hbldr bundles/pkg_install
3030

3131
TOPTARGETS := all clean
3232

@@ -51,7 +51,8 @@ sh.elf: sh.o builtin.o elfldr.o pt.o libtelnet.o
5151
-Wl,--whole-archive bundles/http2_get/lib.a \
5252
-Wl,--whole-archive bundles/launch/lib.a \
5353
-Wl,--whole-archive bundles/suspend/lib.a \
54-
-Wl,--whole-archive bundles/hbldr/lib.a
54+
-Wl,--whole-archive bundles/hbldr/lib.a \
55+
-Wl,--whole-archive bundles/pkg_install/lib.a
5556

5657
sh.elf.inc: sh.elf
5758
xxd -i $^ > $@

bundles/pkg_install/Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (C) 2025 John Törnblom
2+
#
3+
# This file is free software; you can redistribute it and/or modify it
4+
# under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful, but
9+
# WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program; see the file COPYING. If not see
15+
# <http://www.gnu.org/licenses/>.
16+
17+
ifdef PS5_PAYLOAD_SDK
18+
include $(PS5_PAYLOAD_SDK)/toolchain/prospero.mk
19+
else
20+
$(error PS5_PAYLOAD_SDK is undefined)
21+
endif
22+
23+
CFLAGS := -g -O0 -Wall -Werror
24+
LDADD := -lSceIpmi -lSceAppInstUtil
25+
26+
all: lib.a
27+
28+
main.o: pkg_install.elf.inc
29+
30+
pkg_install.elf.inc: pkg_install.elf
31+
xxd -i $^ > $@
32+
33+
pkg_install.elf: pkg_install.o
34+
$(CC) $(LDADD) -o $@ $^
35+
36+
lib.a: main.o
37+
$(AR) -rsc $@ $^
38+
39+
clean:
40+
rm -f *.o *.elf *.a *.inc
41+
42+
test:

bundles/pkg_install/main.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Copyright (C) 2025 John Törnblom
2+
3+
This program is free software; you can redistribute it and/or modify it
4+
under the terms of the GNU General Public License as published by the
5+
Free Software Foundation; either version 3, or (at your option) any
6+
later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; see the file COPYING. If not, see
15+
<http://www.gnu.org/licenses/>. */
16+
17+
#include "../../builtin.h"
18+
#include "../../elfldr.h"
19+
20+
#include "pkg_install.elf.inc"
21+
22+
23+
/**
24+
*
25+
**/
26+
static int
27+
pkg_install_main(int argc, char **argv) {
28+
return elfldr_spawn(STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO,
29+
pkg_install_elf, argv);
30+
}
31+
32+
33+
/**
34+
*
35+
**/
36+
__attribute__((constructor)) static void
37+
pkg_install_constructor(void) {
38+
builtin_cmd_define("pkg_install", "install an SCE package",
39+
pkg_install_main, false);
40+
}
41+

bundles/pkg_install/pkg_install.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* Copyright (C) 2025 John Törnblom
2+
3+
This program is free software; you can redistribute it and/or modify it
4+
under the terms of the GNU General Public License as published by the
5+
Free Software Foundation; either version 3, or (at your option) any
6+
later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; see the file COPYING. If not, see
15+
<http://www.gnu.org/licenses/>. */
16+
17+
#include <stdio.h>
18+
19+
20+
typedef struct pkg_metadata {
21+
const char* uri;
22+
const char* ex_uri;
23+
const char* playgo_scenario_id;
24+
const char* content_id;
25+
const char* content_name;
26+
const char* icon_url;
27+
} pkg_metadata_t;
28+
29+
30+
typedef struct pkg_info {
31+
char content_id[48];
32+
int type;
33+
int platform;
34+
} pkg_info_t;
35+
36+
37+
typedef struct playgo_info {
38+
char lang[8][30];
39+
char scenario_ids[3][64];
40+
char content_ids[64];
41+
long unknown[810];
42+
} playgo_info_t;
43+
44+
45+
int sceAppInstUtilInitialize(void);
46+
int sceAppInstUtilInstallByPackage(const pkg_metadata_t*, pkg_info_t*, playgo_info_t*);
47+
48+
49+
int
50+
main(int argc, char** argv) {
51+
playgo_info_t playgoinfo = {0};
52+
pkg_info_t pkginfo = {0};
53+
pkg_metadata_t metainfo = {
54+
.playgo_scenario_id = "",
55+
.content_name = "",
56+
.content_id = "",
57+
.icon_url = "",
58+
.ex_uri = "",
59+
.uri = ""
60+
};
61+
62+
if(argc < 2) {
63+
printf("Usage: %s URL\n", argv[0]);
64+
return -1;
65+
}
66+
67+
if(sceAppInstUtilInitialize()) {
68+
return -1;
69+
}
70+
71+
metainfo.uri = argv[1];
72+
for(int i=0; metainfo.uri[i]; i++) {
73+
if(metainfo.uri[i] == '/') {
74+
metainfo.content_name = metainfo.uri + i + 1;
75+
}
76+
}
77+
78+
return sceAppInstUtilInstallByPackage(&metainfo, &pkginfo, &playgoinfo);
79+
}
80+

0 commit comments

Comments
 (0)