Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd08ad70c4 | ||
|
|
f0091943f2 | ||
|
|
c09f0481ab | ||
|
|
289688f727 | ||
|
|
533c25a2ac | ||
|
|
70863fb54e | ||
|
|
b115c0fd4b | ||
|
|
7ae09ce571 | ||
|
|
1739096aa1 | ||
|
|
25c2adc4bf | ||
|
|
36c7c02ebb | ||
|
|
4379ac3f59 | ||
|
|
91cfb2cd02 | ||
|
|
bc716339ba | ||
|
|
fbe984da87 | ||
|
|
f251e2aa98 | ||
|
|
f6b0bba49a | ||
|
|
0efa0312d5 | ||
|
|
ca5977f872 | ||
|
|
04d27a9fd5 | ||
|
|
9253235a0d | ||
|
|
664ad3d4fd | ||
|
|
9209408c40 | ||
|
|
3803b9e6eb | ||
|
|
a15f58fbf2 | ||
|
|
cb7a86551b | ||
|
|
ded0a4ddaa | ||
|
|
5cc430ec59 | ||
|
|
b727fd430f | ||
|
|
74ec23aa7e | ||
|
|
5dc5ee57b3 | ||
|
|
44ab1dd822 | ||
|
|
84f5051ba3 | ||
|
|
0510e3dc34 | ||
|
|
edb4c90978 | ||
|
|
ec94f0578b | ||
|
|
88368e3df3 | ||
|
|
c80be921c5 | ||
|
|
a371a67521 | ||
|
|
2bc15cbaa2 | ||
|
|
81d6f0e332 | ||
|
|
fcd43b54ae | ||
|
|
d0ca22d42d | ||
|
|
fb47730d70 | ||
|
|
a1d035313e | ||
|
|
bffa9b2a3f | ||
|
|
3f4c4a15f5 | ||
|
|
c9d721fea6 | ||
|
|
73c75ddd83 | ||
|
|
fcb0a5c3b0 | ||
|
|
a6d9f939b5 | ||
|
|
5ba72b850c | ||
|
|
2f3490f21a | ||
|
|
80c47d6777 | ||
|
|
970c7d8f1d | ||
|
|
983f39fa89 | ||
|
|
79e1c377ed | ||
|
|
fb9d06fb5b | ||
|
|
3d2ee430e1 | ||
|
|
986ff00c36 | ||
|
|
6024dbfc5d | ||
|
|
21f6bd61ad | ||
|
|
01eaef79f2 | ||
|
|
66e4912485 | ||
|
|
3f40dc1d7c | ||
|
|
5f0d1be078 | ||
|
|
ea1328de79 | ||
|
|
9006965a75 | ||
|
|
510f199b89 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
# Files included in the release archive.
|
||||
# One path per line, relative to the repository root.
|
||||
|
||||
patchdl-ps5.elf
|
||||
README.md
|
||||
LICENSE
|
||||
@@ -0,0 +1,148 @@
|
||||
name: PS5 Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "**/*.md"
|
||||
- "docs/**"
|
||||
- "photos/**"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**/*.md"
|
||||
- "docs/**"
|
||||
- "photos/**"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
outputs:
|
||||
archive_name: ${{ steps.package.outputs.archive_name }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout PatchDL
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout pacbrew-repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ps5-payload-dev/pacbrew-repo
|
||||
path: pacbrew-repo
|
||||
|
||||
- name: Checkout SDK stubs
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ps5-payload-dev/sdk
|
||||
path: ps5-sdk
|
||||
|
||||
- name: Setup build environment
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y \
|
||||
autoconf \
|
||||
automake \
|
||||
build-essential \
|
||||
clang-18 \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
libarchive-tools \
|
||||
libtool \
|
||||
lld-18 \
|
||||
makepkg \
|
||||
meson \
|
||||
ninja-build \
|
||||
pacman-package-manager \
|
||||
pkg-config \
|
||||
python3 \
|
||||
zip
|
||||
|
||||
- name: Build and install pacbrew packages
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
build_and_install() {
|
||||
local package_dir="$1"
|
||||
pushd "pacbrew-repo/${package_dir}"
|
||||
makepkg -c -f
|
||||
sudo pacman --noconfirm -U ./ps5-payload-*.pkg.tar.gz
|
||||
popd
|
||||
}
|
||||
|
||||
build_and_install sdk
|
||||
build_and_install libcxx
|
||||
build_and_install zlib
|
||||
build_and_install zstd
|
||||
build_and_install openssl
|
||||
build_and_install libpsl
|
||||
build_and_install curl
|
||||
|
||||
- name: Build payload
|
||||
env:
|
||||
PS5_PAYLOAD_SDK: /opt/ps5-payload-sdk
|
||||
PS5_SCE_STUBS_DIR: ${{ github.workspace }}/ps5-sdk/sce_stubs
|
||||
run: |
|
||||
scripts/build_ps5.sh clean all
|
||||
|
||||
- name: Create release archive
|
||||
id: package
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version_tag="$(git describe --abbrev=6 --dirty --always --tags 2>/dev/null || echo "${GITHUB_SHA::7}")"
|
||||
archive_name="PatchDL_${version_tag}.zip"
|
||||
manifest_file=".github/release-files.txt"
|
||||
|
||||
mapfile -t release_files < <(grep -Ev '^[[:space:]]*(#|$)' "${manifest_file}")
|
||||
|
||||
if [ "${#release_files[@]}" -eq 0 ]; then
|
||||
echo "Release manifest is empty: ${manifest_file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for release_file in "${release_files[@]}"; do
|
||||
if [ ! -f "${release_file}" ]; then
|
||||
echo "Missing release file: ${release_file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
zip -9 "${archive_name}" "${release_files[@]}"
|
||||
|
||||
echo "archive_name=${archive_name}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.package.outputs.archive_name }}
|
||||
path: ${{ steps.package.outputs.archive_name }}
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
needs: build
|
||||
permissions:
|
||||
contents: write
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ needs.build.outputs.archive_name }}
|
||||
path: dist
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
generate_release_notes: true
|
||||
files: dist/${{ needs.build.outputs.archive_name }}
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -20,10 +20,16 @@ SRCS := src/main.c \
|
||||
src/patchdl_scan.c \
|
||||
src/patchdl_appdb.c \
|
||||
src/patchdl_net.c \
|
||||
src/patchdl_prospero.c \
|
||||
src/patchdl_resolve.c \
|
||||
src/patchdl_verxml.c \
|
||||
src/patchdl_install.c \
|
||||
src/patchdl_notify.c
|
||||
src/patchdl_notify.c \
|
||||
src/patchdl_tile.c
|
||||
|
||||
# patchdl_tile.c uses .incbin to embed param.json + icon0.png; touching the
|
||||
# assets must trigger a rebuild.
|
||||
TILE_ASSETS := assets/param.json assets/icon0.png
|
||||
|
||||
WEB_ASSETS := web/index.html web/styles.css web/app.js
|
||||
GEN_SRCS := $(patsubst web/%,gen/web/%.c,$(WEB_ASSETS))
|
||||
@@ -56,8 +62,8 @@ gen/web/%.c: web/% scripts/gen_asset_module.py | gen/web
|
||||
$(SQLITE_OBJ): $(SQLITE_DIR)/sqlite3.c
|
||||
$(CC) $(SQLITE_CFLAGS) -c -o $@ $<
|
||||
|
||||
$(BIN): $(SRCS) $(GEN_SRCS) $(SQLITE_OBJ)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDADD)
|
||||
$(BIN): $(SRCS) $(GEN_SRCS) $(SQLITE_OBJ) $(TILE_ASSETS)
|
||||
$(CC) $(CFLAGS) -o $@ $(SRCS) $(GEN_SRCS) $(SQLITE_OBJ) $(LDADD)
|
||||
|
||||
test: $(BIN)
|
||||
$(PS5_DEPLOY) -h $(PS5_HOST) -p $(PS5_PORT) $^
|
||||
|
||||
@@ -1,77 +1,138 @@
|
||||
# PatchDL
|
||||
<h1 align="center">PatchDL</h1>
|
||||
|
||||
A standalone PlayStation 5 ELF payload that downloads and installs official game
|
||||
patches on your terms. It serves its own web UI and runs without etaHEN.
|
||||
<p align="center">
|
||||
<img src="docs/images/hero.jpg" alt="PatchDL in a desktop browser and on a phone, fetching a patch that runs on an older firmware" width="900">
|
||||
</p>
|
||||
|
||||
PatchDL is built for setups where nanoDNS blocks Sony's servers for the whole
|
||||
console. It resolves the Sony patch CDN on its own path, so the rest of the
|
||||
system stays offline and only the patches you pick get fetched.
|
||||
<p align="center">
|
||||
<b>Official game updates for your PS5, from any browser.</b><br>
|
||||
PatchDL finds the newest update for every game on your console, downloads it at full speed and installs it.<br>
|
||||
Run it from your phone, your laptop or the PS5 itself.
|
||||
</p>
|
||||
|
||||
by Knutwurst
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/github/v/release/knutwurst/ps5-patchdl?style=for-the-badge&label=release&color=22c55e" alt="Latest release">
|
||||
<img src="https://img.shields.io/github/downloads/knutwurst/ps5-patchdl/total?style=for-the-badge&color=22c55e" alt="Downloads">
|
||||
<img src="https://img.shields.io/badge/FW-1.00%E2%80%9313.60-22c55e?style=for-the-badge" alt="Firmware 1.00 to 13.60">
|
||||
<img src="https://img.shields.io/badge/UI-any%20browser-22c55e?style=for-the-badge" alt="Web UI in any browser">
|
||||
<img src="https://img.shields.io/github/license/knutwurst/ps5-patchdl?style=for-the-badge&color=3a3a3a" alt="License">
|
||||
</p>
|
||||
|
||||
## What it does
|
||||
<p align="center">
|
||||
<a href="https://github.com/knutwurst/ps5-patchdl/releases/latest">
|
||||
<img src="https://img.shields.io/badge/Download-latest%20release-22c55e?style=for-the-badge&logo=github&logoColor=white" alt="Download the latest release" height="42">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
- Scans installed titles and classifies each one: genuine install,
|
||||
ShadowMountPlus mount, preinstall, or unknown.
|
||||
- Reads the title name, installed version, and the Sony `version.xml` URL from
|
||||
the PS5 app database.
|
||||
- Fetches each title's `version.xml` from Sony's CDN past nanoDNS (a raw DNS
|
||||
query to 1.1.1.1) and verifies TLS against the pinned SCEI DNAS root.
|
||||
- Picks the newest patch compatible with the current firmware
|
||||
(`system_ver <= firmware`), so an update never forces a firmware upgrade.
|
||||
- Downloads the patch package and installs it through Sony's AppInstUtil
|
||||
service.
|
||||
---
|
||||
|
||||
## Safety model
|
||||
## Highlights
|
||||
|
||||
Deny-by-default. A patch is installed only for a genuine install, and only when
|
||||
the package's title id matches the installed game:
|
||||
- **Your whole library at a glance.** Every installed game shows up with its icon, its version and the newest update Sony offers for it, sorted A to Z. Install or remove a game and the list follows within seconds, no restart needed.
|
||||
- **Update all.** One click queues every game that has an update. PatchDL works through the queue and installs each update as soon as it lands.
|
||||
- **Fast downloads.** Up to 16 parallel connections per update. Change the number in Settings while a download runs.
|
||||
- **Survives reboots.** Pause, resume, or lose power: PatchDL saves progress after every finished piece and continues where it stopped.
|
||||
- **Made for your firmware.** You only see updates your console can run. When Sony's newest patch needs a newer firmware, PatchDL finds the newest one that still runs on yours and helps you get it: scan a QR code with your phone, copy one link, and the PS5 does the rest.
|
||||
- **Knows where each game came from.** PatchDL checks every game's package and recognizes disc and PlayStation Store installs. It only ever patches games Sony signed.
|
||||
- **Checked against Sony's checksums.** Turn on verification and PatchDL compares every piece with the SHA-256 Sony publishes for it.
|
||||
- **Reuses what's already there.** If the update package is already on the console, PatchDL checks it against Sony's checksums and downloads only the pieces that don't match.
|
||||
- **Keeps your storage tidy.** After an install, PatchDL confirms the game runs the new version and then deletes the package. Prefer to keep packages? Turn that off, and Settings lists every package on the console with its size and version, ready to delete.
|
||||
- **A tile on your home screen.** One toggle adds PatchDL to the PS5 home screen. Tap it and the UI opens in the console's browser.
|
||||
- **Live progress.** A banner at the top shows the current game, speed, time left and where you are in the queue. During an install, the game's card shows how much of the update the console has read.
|
||||
|
||||
| Source | Check | Download | Install |
|
||||
|-----------------------|-------|----------|---------|
|
||||
| official | yes | yes | yes |
|
||||
| shadowmount | yes | yes | no |
|
||||
| preinstall / unknown | yes | no | no |
|
||||
## Screenshots
|
||||
|
||||
Two independent guards stop the wrong package being installed: the patch's title
|
||||
id (read from its download URL) must match the game, and just before install the
|
||||
real title id is read back from the package
|
||||
(`sceAppInstUtilGetTitleIdFromPkg`) and checked again. A cross-region or
|
||||
cross-title package is refused instead of installed as a phantom title.
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="50%"><img src="docs/images/games.jpg" width="420" alt="Games view with a running download"><br><sub><b>Games</b> · every update waiting for you, one click away</sub></td>
|
||||
<td align="center" width="50%"><img src="docs/images/library.jpg" width="420" alt="Full library with game icons, sorted by name"><br><sub><b>Library</b> · icons, versions and firmware needs, A to Z</sub></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" width="50%"><img src="docs/images/oldfw.jpg" width="420" alt="QR code on the TV and the step-by-step guide on a phone"><br><sub><b>Older firmware</b> · scan on the TV, paste one link on your phone</sub></td>
|
||||
<td align="center" width="50%"><img src="docs/images/settings.jpg" width="420" alt="Settings view"><br><sub><b>Settings</b> · changes apply right away, no restart</sub></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="2"><img src="docs/images/tile-homescreen.jpg" width="420" alt="PatchDL tile on the PS5 home screen"><br><sub><b>Home screen</b> · the PatchDL tile on a real PS5</sub></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Build
|
||||
## Fits any screen
|
||||
|
||||
Requires `ps5-payload-dev/sdk`. The network and install features also need the
|
||||
prebuilt libcurl + OpenSSL from `ps5-payload-dev/pacbrew-repo` placed in the SDK
|
||||
sysroot (`target/user/homebrew`); `scripts/build_ps5.sh` enables them
|
||||
automatically when present. libmicrohttpd is vendored under `vendor/etahen`, and
|
||||
SQLite is vendored under `vendor/sqlite`.
|
||||
Start an update from the couch with your phone, check on it from your laptop, or open it on the TV. The UI adapts to whatever screen it's on.
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/images/phones.jpg" alt="PatchDL on a phone: game list and Settings" width="560">
|
||||
</p>
|
||||
|
||||
## Get started
|
||||
|
||||
1. Download `patchdl_<version>.elf` from the [latest release](https://github.com/knutwurst/ps5-patchdl/releases/latest).
|
||||
2. Send it to your PS5 with the ELF loader you already use.
|
||||
3. A notification on the TV shows the address, for example `http://192.168.0.42:12880/`. Open it in any browser on your network.
|
||||
4. Optional: switch on **Home-screen shortcut** in Settings to get the PatchDL tile.
|
||||
|
||||
**You need** a PS5 that can load ELF payloads. PatchDL runs on firmware 1.00 to 13.60 (tested on 11.60 and 13.60).
|
||||
|
||||
## Good to know
|
||||
|
||||
**Does PatchDL download games?**
|
||||
No. It fetches updates for games that are already installed on your console. Nothing else.
|
||||
|
||||
**Which games does PatchDL update?**
|
||||
PS5 games you installed from disc or from the PlayStation Store. PatchDL reads each game's package before it offers anything, and it leaves every other title alone. PS4 games are not supported.
|
||||
|
||||
**Where do the updates come from?**
|
||||
From Sony's official update servers, the same files your console downloads on its own. PatchDL downloads only from a short list of PlayStation CDN hosts. To find older patches it also asks [Prospero Patches](https://prosperopatches.com/) which versions exist for a game. That lookup sends the game's title ID and nothing else.
|
||||
|
||||
**Can I get an older patch that runs on my firmware?**
|
||||
Yes. Sony still hosts older patches, but its servers only tell your console about the newest one. When that one needs a newer firmware, PatchDL looks up the version history on [Prospero Patches](https://prosperopatches.com/) and lists the game under *Updates* with an **Old FW patch** button. Tap it and scan the QR code with your phone. Open the game on Prospero, pick the version PatchDL names (confirm the human check if one shows up) and copy the **SC** link. Paste it on your phone, and the PS5 downloads the patch from Sony and handles it like any other update.
|
||||
|
||||
**Does it change the updates?**
|
||||
No. Each package stays exactly as Sony published it, and the console's own installer applies it.
|
||||
|
||||
**Does it delete the package after installing?**
|
||||
Only once the install is confirmed: the game reports the new version and the console's installer recorded this exact package. If either check fails, the package stays. Switch off **Delete PKG after install** in Settings to keep every package.
|
||||
|
||||
**Will it touch my system software?**
|
||||
No. PatchDL never downloads system software, and it only offers game updates that run on the firmware you have.
|
||||
|
||||
**What about disc games?**
|
||||
Put the disc in, same as with any update.
|
||||
|
||||
**What happens if the power goes out?**
|
||||
Start PatchDL again and press Resume. Finished pieces stay on disk.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
PatchDL is an independent project. It is not affiliated with, endorsed by or sponsored by Sony Interactive Entertainment. "PlayStation" and "PS5" are trademarks of Sony Interactive Entertainment Inc. and appear here only to name the console PatchDL works with.
|
||||
|
||||
PatchDL downloads official, unmodified game updates that Sony publishes for games already installed on your console. It does not download games, does not contain or distribute Sony software, keys or game content, and does not install unsigned or modified packages. Use it with games you own, and follow the laws of your country and the terms that apply to you. This project does not support piracy, and issues about pirated content will be closed.
|
||||
|
||||
<details>
|
||||
<summary><b>Build from source</b></summary>
|
||||
|
||||
<br>
|
||||
|
||||
```sh
|
||||
scripts/build_ps5.sh # produces patchdl-ps5.elf
|
||||
```
|
||||
|
||||
## Deploy
|
||||
You need the [ps5-payload-dev SDK](https://github.com/ps5-payload-dev/sdk), version 0.44 or newer for firmware 1.00 to 13.60, with `libcurl` and `OpenSSL` from its [pacbrew-repo](https://github.com/ps5-payload-dev/pacbrew-repo). `libmicrohttpd` and SQLite are vendored. GitHub Actions builds every push; tagged builds become releases.
|
||||
|
||||
This console uses the BD-JB autoloader with itsPLK's Payload Manager on port
|
||||
8084 (not a 9021 elfldr). `scripts/deploy_ps5.sh` uploads the ELF named with its
|
||||
version and launches it; the payload replaces any running instance itself.
|
||||
To try a build on your own console:
|
||||
|
||||
```sh
|
||||
PS5_HOST=<console-ip> scripts/deploy_ps5.sh
|
||||
```
|
||||
|
||||
On start it shows an on-screen notification with the URL. Open the web UI at:
|
||||
</details>
|
||||
|
||||
```text
|
||||
http://<console-ip>:12880/
|
||||
```
|
||||
## Credits
|
||||
|
||||
## Status
|
||||
PatchDL is written in C and builds on [libmicrohttpd](https://www.gnu.org/software/libmicrohttpd/), [libcurl](https://curl.se/), [OpenSSL](https://www.openssl.org/), [SQLite](https://sqlite.org/) and the [ps5-payload-dev SDK](https://github.com/ps5-payload-dev/sdk). The version history behind older patches comes from [Prospero Patches](https://prosperopatches.com/). Thanks to everyone behind them.
|
||||
|
||||
0.0.1, early. Title scan, version resolution, firmware-compatibility filtering,
|
||||
download, and install work and have been verified on firmware 11.60. Open items:
|
||||
the web UI marks a title "Installing…" but reads progress from the PS5's own
|
||||
notifications rather than a percentage; config persistence and a download queue
|
||||
are not built yet; disc-based games need the disc inserted for their patch to
|
||||
apply (a normal Sony requirement).
|
||||
## License
|
||||
|
||||
PatchDL is free software under the **GNU General Public License v3.0 or later**. See [LICENSE](LICENSE). Use it, study it, change it, share it. Forks stay under the same license.
|
||||
|
||||
Copyright © 2026 Knutwurst.
|
||||
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,20 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#0f2a1e"/>
|
||||
<stop offset="1" stop-color="#0a1612"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="badge" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#21d07a"/>
|
||||
<stop offset="1" stop-color="#179a59"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="512" height="512" rx="72" fill="url(#bg)"/>
|
||||
<rect x="56" y="56" width="160" height="160" rx="36" fill="url(#badge)"/>
|
||||
<text x="136" y="178" font-family="Helvetica,Arial,sans-serif" font-size="116"
|
||||
font-weight="800" fill="#0a1612" text-anchor="middle">PD</text>
|
||||
<text x="256" y="346" font-family="Helvetica,Arial,sans-serif" font-size="80"
|
||||
font-weight="700" fill="#e7ecea" text-anchor="middle">PatchDL</text>
|
||||
<text x="256" y="404" font-family="Helvetica,Arial,sans-serif" font-size="32"
|
||||
font-weight="500" fill="#7a8f86" text-anchor="middle">PS5 Patch Tool</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"titleId": "PTDL00001",
|
||||
"deeplinkUri": "http://127.0.0.1:12880/",
|
||||
"localizedParameters": {
|
||||
"defaultLanguage": "en-US",
|
||||
"en-US": {
|
||||
"titleName": "PatchDL"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 196 KiB |
|
After Width: | Height: | Size: 144 KiB |
|
After Width: | Height: | Size: 173 KiB |
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 197 KiB |
|
After Width: | Height: | Size: 171 KiB |
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Deploy patchdl to the PS5 via the Payload Manager HTTP API (port 8084).
|
||||
# The uploaded filename carries the version so it is identifiable in the
|
||||
# Payload Manager UI. patchdl self-kills any running instance, so this is
|
||||
# an idempotent redeploy.
|
||||
# Payload Manager UI. Any running instance is killed first (the payload's own
|
||||
# self-kill is racy when the port is still held), so this is a clean redeploy.
|
||||
#
|
||||
# Usage: scripts/deploy_ps5.sh [PS5_HOST]
|
||||
# PS5_HOST defaults to $PS5_HOST or ps5-slim.fritz.box
|
||||
@@ -19,7 +19,7 @@ VERSION=$(sed -n 's/.*PATCHDL_VERSION[^"]*"\([^"]*\)".*/\1/p' "$ROOT_DIR/src/pat
|
||||
SRC_ELF="$ROOT_DIR/patchdl-ps5.elf"
|
||||
[ -f "$SRC_ELF" ] || { echo "build first: $SRC_ELF missing" >&2; exit 1; }
|
||||
|
||||
UP_NAME="patchdl-ps5-v${VERSION}.elf"
|
||||
UP_NAME="patchdl_${VERSION}.elf"
|
||||
TMP_ELF="$ROOT_DIR/$UP_NAME"
|
||||
cp "$SRC_ELF" "$TMP_ELF"
|
||||
|
||||
@@ -40,6 +40,30 @@ for p in paths:
|
||||
')
|
||||
[ -n "$PAYLOAD_PATH" ] || { echo "uploaded payload not found in list_payloads" >&2; exit 1; }
|
||||
|
||||
# Kill any running patchdl first so the new instance can bind the port
|
||||
# deterministically (the in-payload self-kill races on the held socket).
|
||||
echo "Stopping any running patchdl ..."
|
||||
curl -fsS -m15 "http://$HOST:$PM_PORT/processes_list" 2>/dev/null | \
|
||||
HOST="$HOST" PM_PORT="$PM_PORT" python3 -c '
|
||||
import os, sys, json, urllib.request
|
||||
obj = json.load(sys.stdin)
|
||||
procs = obj if isinstance(obj, list) else obj.get("processes", [])
|
||||
host, port = os.environ["HOST"], os.environ["PM_PORT"]
|
||||
for p in procs:
|
||||
if "patchdl" in str(p.get("name", "")).lower():
|
||||
try:
|
||||
urllib.request.urlopen("http://%s:%s/process_kill?pid=%d" % (host, port, int(p["pid"])), timeout=10).read()
|
||||
print(" killed pid %d" % int(p["pid"]))
|
||||
except Exception as e:
|
||||
print(" kill pid %s failed: %s" % (p.get("pid"), e))
|
||||
' || true
|
||||
i=0
|
||||
while [ "$i" -lt 8 ]; do
|
||||
curl -fsS -m4 "http://$HOST:$HTTP_PORT/api/status" >/dev/null 2>&1 || break
|
||||
sleep 1
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
echo "Launching $PAYLOAD_PATH ..."
|
||||
curl -fsS -m20 "http://$HOST:$PM_PORT/loadpayload:$PAYLOAD_PATH" >/dev/null
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,12 +1,76 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_appdb.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sqlite3.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define APP_DB_URI \
|
||||
"file:/system_data/priv/mms/app.db?immutable=1"
|
||||
/* A rescan can't open app.db by a relative path: SQLite turns it into an
|
||||
absolute one with getcwd(), which resolves inside our own root again. So
|
||||
it copies the file out through the working directory (the system root,
|
||||
see patchdl_scan) and opens the copy. */
|
||||
#define APP_DB_REL "system_data/priv/mms/app.db"
|
||||
#define APP_DB_SNAPSHOT "/data/patchdl/.appdb.snapshot"
|
||||
#define APP_DB_URI_SNAPSHOT "file:" APP_DB_SNAPSHOT "?immutable=1"
|
||||
|
||||
static char g_appdb_err[64];
|
||||
|
||||
const char *
|
||||
patchdl_appdb_error(void) {
|
||||
return g_appdb_err;
|
||||
}
|
||||
|
||||
static int
|
||||
snapshot_appdb(void) {
|
||||
char *buf;
|
||||
ssize_t n;
|
||||
int in, out, rc = 0;
|
||||
|
||||
if ((in = open(APP_DB_REL, O_RDONLY | O_CLOEXEC)) < 0) {
|
||||
snprintf(g_appdb_err, sizeof g_appdb_err, "open app.db errno %d", errno);
|
||||
return -1;
|
||||
}
|
||||
out = open(APP_DB_SNAPSHOT, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);
|
||||
if (out < 0) {
|
||||
snprintf(g_appdb_err, sizeof g_appdb_err, "open snapshot errno %d", errno);
|
||||
close(in);
|
||||
return -1;
|
||||
}
|
||||
if (!(buf = malloc(65536))) {
|
||||
close(in);
|
||||
close(out);
|
||||
return -1;
|
||||
}
|
||||
while ((n = read(in, buf, 65536)) > 0)
|
||||
if (write(out, buf, (size_t)n) != n) {
|
||||
snprintf(g_appdb_err, sizeof g_appdb_err, "write snapshot errno %d", errno);
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
if (n < 0) {
|
||||
snprintf(g_appdb_err, sizeof g_appdb_err, "read app.db errno %d", errno);
|
||||
rc = -1;
|
||||
}
|
||||
free(buf);
|
||||
close(in);
|
||||
close(out);
|
||||
if (rc) unlink(APP_DB_SNAPSHOT);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#define APPDB_MAX 1024
|
||||
|
||||
@@ -51,8 +115,9 @@ json_str(const char *json, const char *key, char *out, size_t out_sz) {
|
||||
out[--len] = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count) {
|
||||
static int
|
||||
load_db(const char *uri, patchdl_appinfo_t **out, size_t *count) {
|
||||
int step = SQLITE_DONE;
|
||||
sqlite3 *db = NULL;
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
patchdl_appinfo_t *arr;
|
||||
@@ -61,8 +126,12 @@ patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count) {
|
||||
*out = NULL;
|
||||
*count = 0;
|
||||
|
||||
if (sqlite3_open_v2(APP_DB_URI, &db,
|
||||
SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, NULL) != SQLITE_OK) {
|
||||
/* FULLMUTEX: today only the startup thread calls this, but future code
|
||||
paths (a manual rescan triggered from the HTTP thread) would otherwise
|
||||
race the SQLite handle. Cost is one mutex per call. */
|
||||
if (sqlite3_open_v2(uri, &db,
|
||||
SQLITE_OPEN_READONLY | SQLITE_OPEN_URI |
|
||||
SQLITE_OPEN_FULLMUTEX, NULL) != SQLITE_OK) {
|
||||
if (db) sqlite3_close(db);
|
||||
return -1;
|
||||
}
|
||||
@@ -81,7 +150,7 @@ patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW && n < APPDB_MAX) {
|
||||
while ((step = sqlite3_step(stmt)) == SQLITE_ROW && n < APPDB_MAX) {
|
||||
patchdl_appinfo_t *e = &arr[n];
|
||||
const char *tid = (const char *)sqlite3_column_text(stmt, 0);
|
||||
const char *name = (const char *)sqlite3_column_text(stmt, 1);
|
||||
@@ -100,8 +169,34 @@ patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count) {
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
/* Anything but the end of the table (or the row cap) means the read
|
||||
broke off, e.g. on a copy taken while the console wrote the file:
|
||||
report failure instead of a list that silently lacks titles. */
|
||||
if (step != SQLITE_DONE && step != SQLITE_ROW) {
|
||||
free(arr);
|
||||
sqlite3_close(db);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Icon paths in a separate query: if a firmware lacks the icon0Info
|
||||
column, only the icons go missing, not the whole title list. */
|
||||
if (sqlite3_prepare_v2(db,
|
||||
"SELECT titleId, icon0Info FROM tbl_contentinfo "
|
||||
"WHERE icon0Info IS NOT NULL AND icon0Info != '';",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
const char *tid = (const char *)sqlite3_column_text(stmt, 0);
|
||||
const char *icon = (const char *)sqlite3_column_text(stmt, 1);
|
||||
patchdl_appinfo_t *e;
|
||||
if (!tid || !icon) continue;
|
||||
e = (patchdl_appinfo_t *)patchdl_appdb_find(arr, n, tid);
|
||||
if (!e || e->icon_path[0]) continue;
|
||||
strncpy(e->icon_path, icon, sizeof(e->icon_path) - 1);
|
||||
e->icon_path[strcspn(e->icon_path, "?")] = '\0';
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
sqlite3_close(db);
|
||||
|
||||
*out = arr;
|
||||
@@ -109,6 +204,18 @@ patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count, int relative) {
|
||||
int rc;
|
||||
*out = NULL;
|
||||
*count = 0;
|
||||
if (!relative) return load_db(APP_DB_URI, out, count);
|
||||
if (snapshot_appdb()) return -2;
|
||||
rc = load_db(APP_DB_URI_SNAPSHOT, out, count);
|
||||
unlink(APP_DB_SNAPSHOT);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
patchdl_appdb_free(patchdl_appinfo_t *arr) {
|
||||
free(arr);
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -8,13 +17,17 @@ typedef struct {
|
||||
char content_id[64];
|
||||
char content_version[16];
|
||||
char version_file_uri[256]; /* Sony version.xml URL (UUID assigned) */
|
||||
char icon_path[256]; /* icon0Info without its "?ts=" suffix, or "" */
|
||||
} patchdl_appinfo_t;
|
||||
|
||||
/* Read the PS5 app database (tbl_contentinfo) for installed-title metadata.
|
||||
Returns 0 on success with a malloc'd array (caller frees with
|
||||
patchdl_appdb_free). Requires the root-vnode swap + elevated authid to be
|
||||
in effect (the caller arranges this). */
|
||||
int patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count);
|
||||
patchdl_appdb_free). Requires elevated authid plus either the root-vnode
|
||||
swap or, with `relative` set, the working directory at the system root
|
||||
(the caller arranges this). */
|
||||
int patchdl_appdb_load(patchdl_appinfo_t **out, size_t *count, int relative);
|
||||
/* Why the last relative load failed to copy app.db (errno text), or "". */
|
||||
const char *patchdl_appdb_error(void);
|
||||
void patchdl_appdb_free(patchdl_appinfo_t *arr);
|
||||
|
||||
const patchdl_appinfo_t *patchdl_appdb_find(const patchdl_appinfo_t *arr,
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_assets.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_fw.h"
|
||||
|
||||
#include <ps5/kernel.h>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_install.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <ps5/kernel.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* AppInstUtil structs/signatures, reverse-engineered by the PS5 homebrew
|
||||
@@ -32,6 +49,12 @@ typedef struct {
|
||||
const char *content_id;
|
||||
const char *content_name;
|
||||
const char *icon_url;
|
||||
/* Sony reads past the six pointers. The 8 bytes after icon_url select the
|
||||
install mode: 0 = plain install, other values take a patch/cancel path
|
||||
that refuses with 0x80B2116F. Left as stack garbage they caused our
|
||||
intermittent 0x80B2116F (measured by ps5upload on FW 13.60). */
|
||||
uint64_t unknown_30;
|
||||
uint64_t reserved[7];
|
||||
} ai_meta_info_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -41,6 +64,42 @@ typedef struct {
|
||||
long unknown[810];
|
||||
} ai_playgo_info_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t error_code;
|
||||
int32_t version;
|
||||
char description[512];
|
||||
char type[9];
|
||||
} ai_install_error_t;
|
||||
|
||||
typedef struct {
|
||||
char status[16];
|
||||
char src_type[8];
|
||||
uint32_t remain_time;
|
||||
uint64_t downloaded_size;
|
||||
uint64_t initial_chunk_size;
|
||||
uint64_t total_size;
|
||||
uint32_t promote_progress;
|
||||
ai_install_error_t error_info;
|
||||
int32_t local_copy_percent;
|
||||
bool is_copy_only;
|
||||
char _pad[2048]; /* safety margin — actual Sony struct may be larger */
|
||||
} ai_install_status_t;
|
||||
|
||||
/* Padded buffers for Sony output writes whose actual size is reverse-engineered.
|
||||
The visible content fits in 0x30 (content_id) / 16 (title_id) bytes, but the
|
||||
firmware may NUL-pad or write more. Used as caller-side temporaries that are
|
||||
then copy_bounded()-d into the right-sized destination. */
|
||||
#define AI_CONTENTID_OUT_SIZE 256
|
||||
#define AI_TITLEID_OUT_SIZE 128
|
||||
|
||||
#define STATIC_ASSERT(c, n) typedef char static_assert_##n[(c) ? 1 : -1]
|
||||
STATIC_ASSERT(sizeof(ai_pkg_info_t) == 0x38, pkg_info_size);
|
||||
STATIC_ASSERT(sizeof(ai_meta_info_t) == 0x70, meta_info_size);
|
||||
STATIC_ASSERT(sizeof(ai_playgo_info_t) == 0x2700, playgo_info_size);
|
||||
STATIC_ASSERT(offsetof(ai_meta_info_t, uri) == 0, meta_uri_offset);
|
||||
STATIC_ASSERT(offsetof(ai_meta_info_t, icon_url) == (5 * sizeof(void *)),
|
||||
meta_icon_offset);
|
||||
|
||||
/* Sysmodule IDs (from ps5-payload-dev/sdk crt/rtld_sprx.c). */
|
||||
#define SYSMOD_IPMI 0x8000001d
|
||||
#define SYSMOD_USERSERVICE 0x80000011
|
||||
@@ -53,11 +112,15 @@ typedef int (*ai_install_pkg_fn)(const char *path, ai_pkg_info_t *info);
|
||||
typedef int (*ai_install_by_pkg_fn)(ai_meta_info_t *meta, ai_pkg_info_t *info,
|
||||
ai_playgo_info_t *playgo);
|
||||
typedef int (*ai_title_from_pkg_fn)(const char *path, char *title_id, int *is_app);
|
||||
typedef int (*ai_content_from_pkg_fn)(const char *path, char *content_id, int *is_app);
|
||||
typedef int (*ai_get_status_fn)(char *content_id_out, ai_install_status_t *status);
|
||||
|
||||
static ai_init_fn ai_initialize;
|
||||
static ai_install_pkg_fn ai_install_pkg;
|
||||
static ai_install_by_pkg_fn ai_install_by_package;
|
||||
static ai_title_from_pkg_fn ai_title_from_pkg;
|
||||
static ai_init_fn ai_initialize;
|
||||
static ai_install_pkg_fn ai_install_pkg;
|
||||
static ai_install_by_pkg_fn ai_install_by_package;
|
||||
static ai_title_from_pkg_fn ai_title_from_pkg;
|
||||
static ai_content_from_pkg_fn ai_content_from_pkg;
|
||||
static ai_get_status_fn ai_get_status;
|
||||
|
||||
/* Resolve + initialize the AppInstUtil backend WITHOUT linking the sce libs
|
||||
(that makes the ELF unloadable by the elfldr) and WITHOUT raw
|
||||
@@ -66,10 +129,18 @@ static ai_title_from_pkg_fn ai_title_from_pkg;
|
||||
symbols via the kernel dynlib helpers. Runs in a detached thread; the HTTP
|
||||
handler reports the stage and never blocks.
|
||||
stage: 0 idle, 1 resolve loader, 2 load modules, 3 resolve symbols,
|
||||
4 initialize, 5 ready, negative = failure at that step. */
|
||||
static volatile int g_stage;
|
||||
static int g_err;
|
||||
4 initialize, 5 ready, negative = failure at that step.
|
||||
Stored as _Atomic so the worker's release-store and the request handlers'
|
||||
acquire-loads pair properly — the function pointers they read after
|
||||
stage==5 must not be reordered ahead of the stage check. */
|
||||
static _Atomic int g_stage;
|
||||
static _Atomic int g_err;
|
||||
static pthread_mutex_t g_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
static char g_probe_json[2048]; /* filled by the backend thread */
|
||||
static char g_last_content_id[AI_CONTENTID_SIZE];
|
||||
static char g_last_target_title_id[32];
|
||||
static char g_last_method[32];
|
||||
static int g_last_start_rc;
|
||||
|
||||
static intptr_t
|
||||
dynsym(const char *module, const char *sym) {
|
||||
@@ -79,6 +150,158 @@ dynsym(const char *module, const char *sym) {
|
||||
return kernel_dynlib_dlsym(-1, h, sym);
|
||||
}
|
||||
|
||||
static void
|
||||
local_ip(char *out, size_t n) {
|
||||
struct ifaddrs *ifa = NULL, *p;
|
||||
|
||||
out[0] = '\0';
|
||||
if (getifaddrs(&ifa))
|
||||
return;
|
||||
|
||||
for (p = ifa; p; p = p->ifa_next) {
|
||||
char ip[INET_ADDRSTRLEN];
|
||||
struct sockaddr_in *s;
|
||||
|
||||
if (!p->ifa_addr || p->ifa_addr->sa_family != AF_INET)
|
||||
continue;
|
||||
s = (struct sockaddr_in *)p->ifa_addr;
|
||||
if (!inet_ntop(AF_INET, &s->sin_addr, ip, sizeof(ip)))
|
||||
continue;
|
||||
if (strcmp(ip, "127.0.0.1") && strncmp(ip, "0.", 2)) {
|
||||
strncpy(out, ip, n - 1);
|
||||
out[n - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifa);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_bounded(char *dst, size_t dst_sz, const char *src, size_t src_sz) {
|
||||
size_t n;
|
||||
if (!dst || !dst_sz) return;
|
||||
dst[0] = '\0';
|
||||
if (!src || !src_sz) return;
|
||||
for (n = 0; n + 1 < dst_sz && n < src_sz && src[n]; n++)
|
||||
dst[n] = src[n];
|
||||
dst[n] = '\0';
|
||||
}
|
||||
|
||||
/* Conservative whitelist for ids/filenames that we extract from a local path
|
||||
and inject into URIs/log lines passed to AppInstUtil. Rejects CRLF, '/',
|
||||
'\\', NUL, control chars, anything that could change URI semantics. */
|
||||
static int
|
||||
install_id_safe(const char *s) {
|
||||
if (!s || !s[0]) return 0;
|
||||
for (const char *p = s; *p; p++) {
|
||||
if (!((*p >= 'A' && *p <= 'Z') ||
|
||||
(*p >= 'a' && *p <= 'z') ||
|
||||
(*p >= '0' && *p <= '9') ||
|
||||
*p == '_' || *p == '-' || *p == '.'))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Exact match for PS4/PS5 title ids (9 chars: 4 letters + 5 digits). A bare
|
||||
strncmp(...,9) would also match longer ids that share a 9-char prefix and
|
||||
could collide PPSA12345 with PPSA12345EVIL. */
|
||||
static int
|
||||
title_id_eq9(const char *a, const char *b) {
|
||||
if (!a || !b) return 0;
|
||||
if (strnlen(a, 16) != 9 || strnlen(b, 16) != 9) return 0;
|
||||
return strncmp(a, b, 9) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
remember_install(const char *target_title_id, const char *method,
|
||||
const ai_pkg_info_t *pkg, const char *fallback_content_id,
|
||||
int rc) {
|
||||
char cid[AI_CONTENTID_SIZE] = {0};
|
||||
|
||||
if (pkg)
|
||||
copy_bounded(cid, sizeof(cid), pkg->content_id, sizeof(pkg->content_id));
|
||||
if (!cid[0] && fallback_content_id)
|
||||
copy_bounded(cid, sizeof(cid), fallback_content_id, strlen(fallback_content_id));
|
||||
|
||||
pthread_mutex_lock(&g_mtx);
|
||||
snprintf(g_last_content_id, sizeof(g_last_content_id), "%s", cid);
|
||||
snprintf(g_last_target_title_id, sizeof(g_last_target_title_id), "%s",
|
||||
target_title_id ? target_title_id : "");
|
||||
snprintf(g_last_method, sizeof(g_last_method), "%s", method ? method : "");
|
||||
g_last_start_rc = rc;
|
||||
pthread_mutex_unlock(&g_mtx);
|
||||
}
|
||||
|
||||
/* Resolve (dlsym, never call) a list of candidate patch-install symbols and
|
||||
record which exist. Runs inside the backend thread, where the AppInstUtil
|
||||
module is already loaded — the same proven-safe context as the normal symbol
|
||||
resolution. No sysmod_load and no calls, so it is side-effect free. */
|
||||
static void
|
||||
fill_probe(void) {
|
||||
static const char *ai_syms[] = {
|
||||
"sceAppInstUtilInitialize",
|
||||
"sceAppInstUtilAppInstallPkg",
|
||||
"sceAppInstUtilAppInstallTitleDir", /* takes an explicit title id */
|
||||
"sceAppInstUtilAppInstallAll", /* tile fallback on 13.xx */
|
||||
"sceAppInstUtilInstallByPackage",
|
||||
"sceAppInstUtilInstallByPackageEx",
|
||||
"sceAppInstUtilGetTitleIdFromPkg",
|
||||
"sceAppInstUtilGetContentIdFromPkg",
|
||||
"sceAppInstUtilGetInstallStatus",
|
||||
"sceAppInstUtilAppExist",
|
||||
"sceAppInstUtilAppGetInstallStatus",
|
||||
"sceAppInstUtilAppInstallStatus",
|
||||
"sceAppInstUtilAppUnInstall",
|
||||
"sceAppInstUtilGetMetaInfoFromPkg",
|
||||
"sceAppInstUtilUpdateTitleByTitleId",
|
||||
"sceAppInstUtilInstallByChunk",
|
||||
NULL
|
||||
};
|
||||
static const char *bgft_syms[] = {
|
||||
"sceBgftInitialize",
|
||||
"sceBgftServiceIntInit",
|
||||
"sceBgftServiceDownloadRegisterTask",
|
||||
"sceBgftServiceDownloadRegisterTaskByStorage",
|
||||
"sceBgftServiceDownloadRegisterTaskByStorageEx",
|
||||
"sceBgftServiceIntDownloadRegisterTaskByStorageEx",
|
||||
"sceBgftServiceDownloadStartTask",
|
||||
"sceBgftServiceDownloadGetProgress",
|
||||
"sceBgftServiceInstallPackage",
|
||||
NULL
|
||||
};
|
||||
uint32_t h = 0;
|
||||
int ai_loaded = (kernel_dynlib_handle(-1, "libSceAppInstUtil.sprx", &h) >= 0);
|
||||
int bgft_loaded = (kernel_dynlib_handle(-1, "libSceBgft.sprx", &h) >= 0);
|
||||
char tmp[sizeof(g_probe_json)];
|
||||
size_t n = 0, sz = sizeof(tmp);
|
||||
char *out = tmp;
|
||||
int first = 1;
|
||||
|
||||
n += snprintf(out + n, sz - n,
|
||||
"{\"appinstutil_loaded\":%s,\"bgft_loaded\":%s,\"symbols\":{",
|
||||
ai_loaded ? "true" : "false", bgft_loaded ? "true" : "false");
|
||||
for (int i = 0; ai_syms[i] && n < sz - 80; i++) {
|
||||
intptr_t a = dynsym("libSceAppInstUtil.sprx", ai_syms[i]);
|
||||
n += snprintf(out + n, sz - n, "%s\"%s\":%s",
|
||||
first ? "" : ",", ai_syms[i], a ? "true" : "false");
|
||||
first = 0;
|
||||
}
|
||||
for (int i = 0; bgft_syms[i] && n < sz - 80; i++) {
|
||||
intptr_t a = bgft_loaded ? dynsym("libSceBgft.sprx", bgft_syms[i]) : 0;
|
||||
n += snprintf(out + n, sz - n, "%s\"%s\":%s",
|
||||
first ? "" : ",", bgft_syms[i], a ? "true" : "false");
|
||||
first = 0;
|
||||
}
|
||||
snprintf(out + n, sz - n, "}}");
|
||||
|
||||
/* Publish atomically: the getter runs on an MHD worker thread and reads
|
||||
g_probe_json under the same lock, so it never sees a half-built buffer. */
|
||||
pthread_mutex_lock(&g_mtx);
|
||||
memcpy(g_probe_json, tmp, sizeof(g_probe_json));
|
||||
pthread_mutex_unlock(&g_mtx);
|
||||
}
|
||||
|
||||
static void *
|
||||
backend_init_thread(void *arg) {
|
||||
(void)arg;
|
||||
@@ -107,6 +330,14 @@ backend_init_thread(void *arg) {
|
||||
"sceAppInstUtilInstallByPackage");
|
||||
ai_title_from_pkg = (ai_title_from_pkg_fn)dynsym("libSceAppInstUtil.sprx",
|
||||
"sceAppInstUtilGetTitleIdFromPkg");
|
||||
ai_content_from_pkg = (ai_content_from_pkg_fn)dynsym("libSceAppInstUtil.sprx",
|
||||
"sceAppInstUtilGetContentIdFromPkg");
|
||||
ai_get_status = (ai_get_status_fn)dynsym("libSceAppInstUtil.sprx",
|
||||
"sceAppInstUtilGetInstallStatus");
|
||||
|
||||
/* Read-only feasibility probe — module is loaded, safe context. */
|
||||
fill_probe();
|
||||
|
||||
if (!ai_initialize || !ai_install_pkg || !ai_install_by_package) {
|
||||
g_stage = -3;
|
||||
return NULL;
|
||||
@@ -135,6 +366,16 @@ backend_start(void) {
|
||||
pthread_mutex_unlock(&g_mtx);
|
||||
}
|
||||
|
||||
/* Start the backend if needed and give it up to 15 s to come up (it loads a
|
||||
system module and resolves symbols in its own thread), so an install
|
||||
request right after startup doesn't fail just because it was early. */
|
||||
static void
|
||||
backend_wait(void) {
|
||||
backend_start();
|
||||
for (int i = 0; i < 150 && g_stage > 0 && g_stage != 5; i++)
|
||||
usleep(100 * 1000);
|
||||
}
|
||||
|
||||
static const char *
|
||||
stage_str(int s) {
|
||||
switch (s) {
|
||||
@@ -161,12 +402,199 @@ patchdl_install_backend_check(char *msg, size_t msg_sz) {
|
||||
return (s == 5) ? 0 : -1;
|
||||
}
|
||||
|
||||
/* Public getter: trigger the backend (which fills the probe in its own thread)
|
||||
and return the cached result. Runs from the MHD worker thread, so it only
|
||||
reads the cached string — it never loads modules or resolves symbols here. */
|
||||
int
|
||||
patchdl_install_api_probe(char *out, size_t out_sz) {
|
||||
int ready;
|
||||
|
||||
backend_start();
|
||||
pthread_mutex_lock(&g_mtx);
|
||||
ready = (g_probe_json[0] != '\0');
|
||||
if (ready)
|
||||
snprintf(out, out_sz, "%s", g_probe_json);
|
||||
pthread_mutex_unlock(&g_mtx);
|
||||
if (ready)
|
||||
return 0;
|
||||
|
||||
snprintf(out, out_sz,
|
||||
"{\"pending\":true,\"stage\":\"%s\"}", stage_str(g_stage));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read-only: report the .pkg's embedded content id + title id (and whether it
|
||||
is a full app vs a patch). No install, no side effects. 0 if anything read. */
|
||||
int
|
||||
patchdl_install_pkg_meta(const char *local_path, char *content_id, size_t cid_sz,
|
||||
char *title_id, size_t tid_sz, int *is_app,
|
||||
char *msg, size_t msg_sz) {
|
||||
char sdk_path[1024];
|
||||
/* Padded output buffers — Sony's GetContentIdFromPkg / GetTitleIdFromPkg
|
||||
take no length hint; firmware may NUL-pad more than the visible id. */
|
||||
char cid[AI_CONTENTID_OUT_SIZE] = {0};
|
||||
char tid[AI_TITLEID_OUT_SIZE] = {0};
|
||||
int app_c = 0, app_t = 0, ok = 0;
|
||||
struct stat st;
|
||||
|
||||
if (content_id && cid_sz) content_id[0] = '\0';
|
||||
if (title_id && tid_sz) title_id[0] = '\0';
|
||||
if (is_app) *is_app = 0;
|
||||
|
||||
if (!local_path || !local_path[0] || stat(local_path, &st) != 0) {
|
||||
snprintf(msg, msg_sz, "package not on disk");
|
||||
return -1;
|
||||
}
|
||||
backend_wait();
|
||||
if (g_stage != 5) {
|
||||
snprintf(msg, msg_sz, "install backend not ready: %s", stage_str(g_stage));
|
||||
return -1;
|
||||
}
|
||||
if (!strncmp(local_path, "/data/", 6))
|
||||
snprintf(sdk_path, sizeof sdk_path, "/user%s", local_path);
|
||||
else
|
||||
snprintf(sdk_path, sizeof sdk_path, "%s", local_path);
|
||||
|
||||
if (ai_content_from_pkg &&
|
||||
ai_content_from_pkg(sdk_path, cid, &app_c) == 0 && cid[0]) {
|
||||
copy_bounded(content_id, cid_sz, cid, sizeof(cid));
|
||||
if (is_app) *is_app = app_c;
|
||||
ok = 1;
|
||||
}
|
||||
if (ai_title_from_pkg &&
|
||||
ai_title_from_pkg(sdk_path, tid, &app_t) == 0 && tid[0]) {
|
||||
copy_bounded(title_id, tid_sz, tid, sizeof(tid));
|
||||
ok = 1;
|
||||
}
|
||||
snprintf(msg, msg_sz, ok ? "ok" : "could not read pkg metadata");
|
||||
return ok ? 0 : -1;
|
||||
}
|
||||
|
||||
void
|
||||
patchdl_install_debug_state(char *out, size_t out_sz) {
|
||||
char cid[AI_CONTENTID_SIZE];
|
||||
char tid[32], method[32];
|
||||
int start_rc;
|
||||
int stage;
|
||||
|
||||
pthread_mutex_lock(&g_mtx);
|
||||
memcpy(cid, g_last_content_id, sizeof(cid));
|
||||
snprintf(tid, sizeof(tid), "%s", g_last_target_title_id);
|
||||
snprintf(method, sizeof(method), "%s", g_last_method);
|
||||
start_rc = g_last_start_rc;
|
||||
stage = g_stage;
|
||||
pthread_mutex_unlock(&g_mtx);
|
||||
|
||||
snprintf(out, out_sz,
|
||||
"{\"stage\":%d,\"cid_len\":%d,\"cid_hex\":\"%02x%02x%02x%02x\","
|
||||
"\"content_id\":\"%s\",\"target_title_id\":\"%s\","
|
||||
"\"method\":\"%s\",\"start_rc\":%d}",
|
||||
stage,
|
||||
(int)strnlen(cid, sizeof(cid)),
|
||||
(unsigned char)cid[0], (unsigned char)cid[1],
|
||||
(unsigned char)cid[2], (unsigned char)cid[3],
|
||||
cid, tid, method, start_rc);
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_install_status_json(char *out, size_t out_sz) {
|
||||
char cid[AI_CONTENTID_SIZE];
|
||||
char tid[32];
|
||||
char method[32];
|
||||
int start_rc;
|
||||
/* ai_install_status_t carries a 2 KB safety pad; live on the heap so
|
||||
a frequently-polled /api/installstatus doesn't keep committing pages
|
||||
on every MHD worker's stack. */
|
||||
ai_install_status_t *st = NULL;
|
||||
char status[17], src_type[9];
|
||||
int rc;
|
||||
int progress = 0;
|
||||
int terminal = 0;
|
||||
|
||||
if (!out || !out_sz)
|
||||
return -1;
|
||||
|
||||
backend_start();
|
||||
|
||||
pthread_mutex_lock(&g_mtx);
|
||||
snprintf(cid, sizeof(cid), "%s", g_last_content_id);
|
||||
snprintf(tid, sizeof(tid), "%s", g_last_target_title_id);
|
||||
snprintf(method, sizeof(method), "%s", g_last_method);
|
||||
start_rc = g_last_start_rc;
|
||||
pthread_mutex_unlock(&g_mtx);
|
||||
|
||||
if (!cid[0]) {
|
||||
snprintf(out, out_sz, "{\"active\":false}");
|
||||
return -1;
|
||||
}
|
||||
if (g_stage != 5) {
|
||||
snprintf(out, out_sz,
|
||||
"{\"active\":true,\"content_id\":\"%s\",\"target_title_id\":\"%s\","
|
||||
"\"method\":\"%s\",\"start_rc\":%d,\"status\":\"backend_not_ready\","
|
||||
"\"stage\":\"%s\"}",
|
||||
cid, tid, method, start_rc, stage_str(g_stage));
|
||||
return -1;
|
||||
}
|
||||
if (!ai_get_status) {
|
||||
snprintf(out, out_sz,
|
||||
"{\"active\":true,\"content_id\":\"%s\",\"target_title_id\":\"%s\","
|
||||
"\"method\":\"%s\",\"start_rc\":%d,\"status\":\"unavailable\","
|
||||
"\"message\":\"sceAppInstUtilGetInstallStatus not exported\"}",
|
||||
cid, tid, method, start_rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
st = calloc(1, sizeof(*st));
|
||||
if (!st) {
|
||||
snprintf(out, out_sz, "{\"error\":\"oom\"}");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* sceAppInstUtilGetInstallStatus(char *content_id_out, status_t *status):
|
||||
first arg is an OUTPUT buffer that receives the current install's content_id.
|
||||
Do NOT pass `cid` there — it would be overwritten. The visible id fits in
|
||||
0x30 bytes but Sony's NUL-pad length is unknown; use a padded buffer. */
|
||||
{
|
||||
char ai_cid_out[AI_CONTENTID_OUT_SIZE] = {0};
|
||||
rc = ai_get_status(ai_cid_out, st);
|
||||
(void)ai_cid_out; /* returned content_id for future use */
|
||||
}
|
||||
copy_bounded(status, sizeof(status), st->status, sizeof(st->status));
|
||||
copy_bounded(src_type, sizeof(src_type), st->src_type, sizeof(st->src_type));
|
||||
if (st->total_size > 0)
|
||||
progress = (int)((st->downloaded_size * 100) / st->total_size);
|
||||
if (progress < 0) progress = 0;
|
||||
if (progress > 100) progress = 100;
|
||||
terminal = (!strcmp(status, "playable") ||
|
||||
!strcmp(status, "error") ||
|
||||
!strcmp(status, "none"));
|
||||
|
||||
snprintf(out, out_sz,
|
||||
"{\"active\":true,\"terminal\":%s,\"content_id\":\"%s\","
|
||||
"\"target_title_id\":\"%s\",\"method\":\"%s\",\"start_rc\":%d,"
|
||||
"\"rc\":%d,\"status\":\"%s\",\"src_type\":\"%s\","
|
||||
"\"progress\":%d,\"downloaded_size\":%llu,\"total_size\":%llu,"
|
||||
"\"promote_progress\":%u,\"error_code\":%d}",
|
||||
terminal ? "true" : "false", cid, tid, method, start_rc, rc,
|
||||
status, src_type, progress,
|
||||
(unsigned long long)st->downloaded_size,
|
||||
(unsigned long long)st->total_size,
|
||||
(unsigned)st->promote_progress,
|
||||
(int)st->error_info.error_code);
|
||||
free(st);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_install_local_pkg(const char *local_path, const char *expected_title_id,
|
||||
const char *storage_title_id,
|
||||
const char *target_content_id,
|
||||
char *msg, size_t msg_sz) {
|
||||
char sdk_path[1024];
|
||||
char pkg_tid[48] = {0};
|
||||
struct stat st;
|
||||
int rc;
|
||||
int rc = -1;
|
||||
int pkg_tid_mismatch = 0;
|
||||
|
||||
if (!local_path || !local_path[0]) {
|
||||
snprintf(msg, msg_sz, "no package path");
|
||||
@@ -177,69 +605,225 @@ patchdl_install_local_pkg(const char *local_path, const char *expected_title_id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
backend_start();
|
||||
backend_wait();
|
||||
if (g_stage != 5) {
|
||||
snprintf(msg, msg_sz, "install backend not ready: %s", stage_str(g_stage));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The install service runs in its own sandbox that sees the user
|
||||
partition as /user/data, not /data — remap so it can read the file. */
|
||||
/* Sony's installer sees the user partition as /user/data, not /data, and
|
||||
PATH-ALLOWLISTS the URI passed to InstallByPackage: /user/data/ and
|
||||
/mnt/usb are accepted, but a bare /data/... path is REJECTED with
|
||||
0x80B2116F (empirically confirmed by the ps5upload project). So feed the
|
||||
/user/data view of the file to both InstallByPackage and AppInstallPkg. */
|
||||
if (!strncmp(local_path, "/data/", 6))
|
||||
snprintf(sdk_path, sizeof(sdk_path), "/user%s", local_path);
|
||||
else
|
||||
snprintf(sdk_path, sizeof(sdk_path), "%s", local_path);
|
||||
|
||||
/* GUARD: read the PKG's own title id and refuse if it does not match the
|
||||
installed game. A cross-title/region package (e.g. a US PPSA03098 patch
|
||||
on an EU PPSA03099 install) would otherwise be registered as a separate
|
||||
phantom title instead of patching the game. */
|
||||
/* Diagnostic guard: Sony sometimes stores one patch byte stream under a
|
||||
master title id while the version.xml targets a regional title id. That
|
||||
is valid only when the caller supplies target metadata, so do not feed
|
||||
such packages to the raw AppInstallPkg path. */
|
||||
if (storage_title_id && storage_title_id[0] &&
|
||||
expected_title_id && expected_title_id[0] &&
|
||||
!title_id_eq9(storage_title_id, expected_title_id)) {
|
||||
pkg_tid_mismatch = 1;
|
||||
strncpy(pkg_tid, storage_title_id, sizeof(pkg_tid) - 1);
|
||||
pkg_tid[sizeof(pkg_tid) - 1] = '\0';
|
||||
}
|
||||
if (ai_title_from_pkg && expected_title_id && expected_title_id[0]) {
|
||||
char pkg_tid[48] = {0};
|
||||
/* Sony's GetTitleIdFromPkg writes into the output buffer with no length
|
||||
hint — pad generously and copy the safe portion into pkg_tid. */
|
||||
char tid_out[AI_TITLEID_OUT_SIZE] = {0};
|
||||
int is_app = 0;
|
||||
if (ai_title_from_pkg(sdk_path, pkg_tid, &is_app) == 0 && pkg_tid[0] &&
|
||||
strncmp(pkg_tid, expected_title_id, 9) != 0) {
|
||||
snprintf(msg, msg_sz,
|
||||
"refused: package is for %.12s, installed game is %.12s "
|
||||
"(cross-title/region)", pkg_tid, expected_title_id);
|
||||
if (ai_title_from_pkg(sdk_path, tid_out, &is_app) == 0 && tid_out[0]) {
|
||||
if (!title_id_eq9(tid_out, expected_title_id))
|
||||
pkg_tid_mismatch = 1;
|
||||
copy_bounded(pkg_tid, sizeof(pkg_tid), tid_out, sizeof(tid_out));
|
||||
}
|
||||
}
|
||||
if (pkg_tid_mismatch && (!target_content_id || !target_content_id[0])) {
|
||||
snprintf(msg, msg_sz,
|
||||
"refused: package metadata is %.12s, target is %.12s",
|
||||
pkg_tid, expected_title_id);
|
||||
return -1;
|
||||
}
|
||||
/* Preferred path: etaHEN's DPI uses InstallByPackage with the installed
|
||||
game's content_id in MetaInfo so AppInstUtil binds the install to the
|
||||
right title slot. For shared-master cross-region packages the pkg bytes
|
||||
carry a different title id than the installed game; passing content_id
|
||||
is what etaHEN does to route the install correctly. */
|
||||
{
|
||||
char file_uri[1100];
|
||||
char http_loop_uri[1200] = {0};
|
||||
char http_lan_uri[1200] = {0};
|
||||
const char *uris[4];
|
||||
ai_meta_info_t meta = {0};
|
||||
ai_pkg_info_t pkg = {0};
|
||||
/* playgo is 0x2700 bytes — too big for the MHD worker stack alongside
|
||||
uris, meta, pkg, resp buffers, and Sony's own frame use. */
|
||||
ai_playgo_info_t *playgo = calloc(1, sizeof(*playgo));
|
||||
int rc2 = -1;
|
||||
const char *title_dir;
|
||||
const char *file_base;
|
||||
|
||||
if (!playgo) {
|
||||
snprintf(msg, msg_sz, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Primary: direct package install. */
|
||||
{
|
||||
ai_pkg_info_t pkg = {0};
|
||||
rc = ai_install_pkg(sdk_path, &pkg);
|
||||
if (rc == 0) {
|
||||
snprintf(msg, msg_sz, "install started (AppInstallPkg)");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fallback: InstallByPackage with a file:// URI. */
|
||||
{
|
||||
char file_uri[1100];
|
||||
ai_meta_info_t meta = {0};
|
||||
ai_pkg_info_t pkg = {0};
|
||||
ai_playgo_info_t playgo = {0};
|
||||
int rc2;
|
||||
|
||||
snprintf(file_uri, sizeof(file_uri), "file://%s", sdk_path);
|
||||
meta.uri = file_uri;
|
||||
title_dir = strstr(local_path, "/data/patchdl/");
|
||||
file_base = strrchr(local_path, '/');
|
||||
if (title_dir && file_base && file_base > title_dir + strlen("/data/patchdl/")) {
|
||||
char title_id[32] = {0};
|
||||
const char *t = title_dir + strlen("/data/patchdl/");
|
||||
size_t tlen = (size_t)(file_base - t);
|
||||
if (tlen > 0 && tlen < sizeof(title_id)) {
|
||||
char ip[INET_ADDRSTRLEN] = {0};
|
||||
memcpy(title_id, t, tlen);
|
||||
/* CRLF/path-injection guard: anything we splice into the loop /
|
||||
LAN URI lands inside Sony's HTTP request line. Reject ids
|
||||
or filenames carrying delimiters or control chars. */
|
||||
if (install_id_safe(title_id) && install_id_safe(file_base + 1)) {
|
||||
snprintf(http_loop_uri, sizeof(http_loop_uri),
|
||||
"http://127.0.0.1:%d/api/pkg/%s/%s",
|
||||
PATCHDL_HTTP_PORT, title_id, file_base + 1);
|
||||
local_ip(ip, sizeof(ip));
|
||||
if (ip[0])
|
||||
snprintf(http_lan_uri, sizeof(http_lan_uri),
|
||||
"http://%s:%d/api/pkg/%s/%s",
|
||||
ip, PATCHDL_HTTP_PORT, title_id, file_base + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Stream install first: Sony's installer pulls the package from our
|
||||
own /api/pkg over HTTP (ranges), the route that writes the content.
|
||||
The bare path forms come last. */
|
||||
uris[0] = http_loop_uri[0] ? http_loop_uri : NULL;
|
||||
uris[1] = http_lan_uri[0] ? http_lan_uri : NULL;
|
||||
uris[2] = sdk_path; /* /user/data/... */
|
||||
uris[3] = file_uri; /* file:///user/data/... */
|
||||
meta.ex_uri = "";
|
||||
meta.playgo_scenario_id = "";
|
||||
/* Empty: the installer takes the id from the package itself. */
|
||||
meta.content_id = "";
|
||||
meta.content_name = "PatchDL";
|
||||
meta.icon_url = "";
|
||||
|
||||
rc2 = ai_install_by_package(&meta, &pkg, &playgo);
|
||||
if (rc2 == 0) {
|
||||
snprintf(msg, msg_sz, "install started (InstallByPackage)");
|
||||
return 0;
|
||||
{
|
||||
char tries[260] = {0};
|
||||
const char *labels[4] = { "loop", "lan", "userdata", "file" };
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!uris[i]) continue;
|
||||
memset(&pkg, 0, sizeof(pkg));
|
||||
memset(playgo, 0, sizeof(*playgo));
|
||||
meta.uri = uris[i];
|
||||
rc2 = ai_install_by_package(&meta, &pkg, playgo);
|
||||
{
|
||||
size_t l = strlen(tries);
|
||||
snprintf(tries + l, sizeof(tries) - l, "%s%s=0x%08x",
|
||||
l ? "," : "", labels[i], (unsigned)rc2);
|
||||
}
|
||||
if (rc2 == 0) {
|
||||
remember_install(expected_title_id, "InstallByPackage",
|
||||
&pkg, target_content_id, rc2);
|
||||
snprintf(msg, msg_sz, "install started (InstallByPackage, content %.47s)",
|
||||
pkg.content_id[0] ? pkg.content_id :
|
||||
(target_content_id ? target_content_id : ""));
|
||||
free(playgo);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
rc = rc2;
|
||||
}
|
||||
snprintf(msg, msg_sz,
|
||||
"install rejected (AppInstallPkg=0x%08x, InstallByPackage=0x%08x)",
|
||||
(unsigned)rc, (unsigned)rc2);
|
||||
return rc2;
|
||||
free(playgo);
|
||||
}
|
||||
|
||||
/* No AppInstallPkg fallback: it returns 0 and writes only the app
|
||||
metadata (version, tile) without installing any content, which shows
|
||||
up as "updated" while the game still runs the old version. */
|
||||
snprintf(msg, msg_sz, "install rejected (InstallByPackage=0x%08x)", (unsigned)rc);
|
||||
return rc ? rc : -1;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_install_by_uri(const char *uri, const char *target_title_id,
|
||||
const char *target_content_id,
|
||||
char *msg, size_t msg_sz) {
|
||||
ai_meta_info_t meta = {0};
|
||||
ai_pkg_info_t pkg = {0};
|
||||
ai_playgo_info_t *playgo;
|
||||
int rc;
|
||||
|
||||
if (!uri || !uri[0]) {
|
||||
snprintf(msg, msg_sz, "no uri");
|
||||
return -1;
|
||||
}
|
||||
backend_wait();
|
||||
if (g_stage != 5) {
|
||||
snprintf(msg, msg_sz, "install backend not ready: %s", stage_str(g_stage));
|
||||
return -1;
|
||||
}
|
||||
playgo = calloc(1, sizeof(*playgo));
|
||||
if (!playgo) { snprintf(msg, msg_sz, "out of memory"); return -1; }
|
||||
|
||||
meta.uri = uri;
|
||||
meta.ex_uri = "";
|
||||
meta.playgo_scenario_id = "";
|
||||
meta.content_id = target_content_id ? target_content_id : "";
|
||||
meta.content_name = "PatchDL";
|
||||
meta.icon_url = "";
|
||||
|
||||
rc = ai_install_by_package(&meta, &pkg, playgo);
|
||||
remember_install(target_title_id, "InstallByURI", &pkg, target_content_id, rc);
|
||||
free(playgo);
|
||||
|
||||
if (rc == 0) {
|
||||
snprintf(msg, msg_sz, "install started (InstallByPackage/uri, content %.47s)",
|
||||
pkg.content_id[0] ? pkg.content_id :
|
||||
(target_content_id ? target_content_id : ""));
|
||||
} else {
|
||||
snprintf(msg, msg_sz, "install rejected rc=0x%08x", (unsigned)rc);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Direct AppInstallPkg call for a local path — bypasses MetaInfo, lets
|
||||
AppInstUtil read the PKG's own embedded metadata to determine the target. */
|
||||
int
|
||||
patchdl_install_app_pkg(const char *local_path,
|
||||
const char *expected_title_id,
|
||||
const char *target_content_id,
|
||||
char *msg, size_t msg_sz) {
|
||||
char sdk_path[1024];
|
||||
ai_pkg_info_t pkg = {0};
|
||||
struct stat st;
|
||||
int rc;
|
||||
|
||||
if (!local_path || !local_path[0]) { snprintf(msg, msg_sz, "no path"); return -1; }
|
||||
if (stat(local_path, &st) != 0) { snprintf(msg, msg_sz, "package not downloaded"); return -1; }
|
||||
|
||||
backend_wait();
|
||||
if (g_stage != 5) {
|
||||
snprintf(msg, msg_sz, "install backend not ready: %s", stage_str(g_stage));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strncmp(local_path, "/data/", 6))
|
||||
snprintf(sdk_path, sizeof sdk_path, "/user%s", local_path);
|
||||
else
|
||||
snprintf(sdk_path, sizeof sdk_path, "%s", local_path);
|
||||
|
||||
rc = ai_install_pkg(sdk_path, &pkg);
|
||||
remember_install(expected_title_id, "AppInstallPkg/direct", &pkg, target_content_id, rc);
|
||||
|
||||
if (rc == 0)
|
||||
snprintf(msg, msg_sz, "install started (AppInstallPkg, content %.47s)",
|
||||
pkg.content_id[0] ? pkg.content_id :
|
||||
(target_content_id ? target_content_id : ""));
|
||||
else
|
||||
snprintf(msg, msg_sz, "install rejected rc=0x%08x", (unsigned)rc);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -13,13 +22,54 @@
|
||||
* (official) titles and obtain explicit user intent before calling.
|
||||
*/
|
||||
/* `expected_title_id` is the title id of the installed game the patch is for.
|
||||
The PKG's own title id is read and must match, else the install is refused
|
||||
(prevents a cross-region/cross-title package being installed as a new
|
||||
phantom title). */
|
||||
`storage_title_id` is the title id embedded in the delta_url storage path.
|
||||
`target_content_id` is the installed game's content id from app.db; it is
|
||||
retained for diagnostics and status fallback. Normal same-title installs
|
||||
deliberately pass an empty MetaInfo.content_id, matching etaHEN's native DPI
|
||||
path and letting AppInstUtil bind the package to its signed metadata. */
|
||||
int patchdl_install_local_pkg(const char *local_path,
|
||||
const char *expected_title_id,
|
||||
const char *storage_title_id,
|
||||
const char *target_content_id,
|
||||
char *msg, size_t msg_sz);
|
||||
|
||||
/* Verify the AppInstUtil backend can be loaded + resolved + initialized,
|
||||
WITHOUT performing any install. Returns 0 if ready. Safe to call. */
|
||||
int patchdl_install_backend_check(char *msg, size_t msg_sz);
|
||||
|
||||
/* Read-only feasibility probe: resolve (dlsym, never call) a list of candidate
|
||||
AppInstUtil/Bgft patch-install symbols and report which exist on this
|
||||
firmware. Writes a JSON object into `out`. No install, no side effects. */
|
||||
int patchdl_install_api_probe(char *out, size_t out_sz);
|
||||
|
||||
/* Read-only: report the .pkg's embedded content id + title id (and whether it
|
||||
is a full app vs a patch, via *is_app). No install. 0 if anything was read. */
|
||||
int patchdl_install_pkg_meta(const char *local_path, char *content_id, size_t cid_sz,
|
||||
char *title_id, size_t tid_sz, int *is_app,
|
||||
char *msg, size_t msg_sz);
|
||||
|
||||
/* Read-only: report the last AppInstUtil install task PatchDL started, using
|
||||
sceAppInstUtilGetInstallStatus when present. No install, no mutation. */
|
||||
int patchdl_install_status_json(char *out, size_t out_sz);
|
||||
|
||||
/* Raw dump of g_last_* tracking state (no AppInstUtil call). For diagnosis. */
|
||||
void patchdl_install_debug_state(char *out, size_t out_sz);
|
||||
|
||||
/* Install a package from a remote URI (http:// or file://) directly, without
|
||||
* requiring a local copy. Used for shared-master delta packages where the
|
||||
* version.xml targets a different title id than the CDN storage path.
|
||||
* `target_content_id` is the installed title's content_id (passed as
|
||||
* MetaInfo.content_id so AppInstUtil binds the install to the right title).
|
||||
*/
|
||||
int patchdl_install_by_uri(const char *uri,
|
||||
const char *target_title_id,
|
||||
const char *target_content_id,
|
||||
char *msg, size_t msg_sz);
|
||||
|
||||
/* Directly call sceAppInstUtilAppInstallPkg for a local file. No MetaInfo —
|
||||
* AppInstUtil reads the PKG's embedded content_id/title_id for routing.
|
||||
* Use when InstallByPackage is unavailable (privilege). */
|
||||
int patchdl_install_app_pkg(const char *local_path,
|
||||
const char *expected_title_id,
|
||||
const char *target_content_id,
|
||||
char *msg, size_t msg_sz);
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -6,17 +15,102 @@ typedef struct {
|
||||
char *data;
|
||||
size_t size;
|
||||
size_t cap;
|
||||
size_t max; /* 0 = unbounded (legacy). Otherwise write_cb fails past this. */
|
||||
} patchdl_buf_t;
|
||||
|
||||
patchdl_buf_t *patchdl_buf_new(void);
|
||||
void patchdl_buf_free(patchdl_buf_t *b);
|
||||
|
||||
/* Call once, single-threaded, before any concurrent download worker starts /
|
||||
after they have all joined. curl's global/OpenSSL init is otherwise lazy and
|
||||
races across threads. */
|
||||
void patchdl_net_global_init(void);
|
||||
void patchdl_net_global_cleanup(void);
|
||||
|
||||
int patchdl_http_get(const char *url, patchdl_buf_t *out);
|
||||
|
||||
/* External-host variants: no Sony CA pinning, no Sony host allowlist.
|
||||
SSL peer verification is disabled (PS5 has no system CA store; these
|
||||
are used for public metadata only, never for sensitive data). */
|
||||
int patchdl_http_get_external(const char *url, patchdl_buf_t *out);
|
||||
int patchdl_http_post_external(const char *url, const char *content_type,
|
||||
const char *body, patchdl_buf_t *out);
|
||||
|
||||
/* ---- parallel piece download (used by the connection pool) ------------- */
|
||||
|
||||
/* One piece of a split manifest package. `url` is heap-allocated. */
|
||||
typedef struct {
|
||||
char *url;
|
||||
long long offset; /* byte offset of this piece in the assembled file */
|
||||
long long size; /* exact length of this piece */
|
||||
char hash[80]; /* manifest SHA-256 hex, or "" */
|
||||
} patchdl_piece_t;
|
||||
|
||||
typedef struct {
|
||||
patchdl_piece_t *pieces;
|
||||
int count;
|
||||
long long total; /* assembled file size = sum of piece sizes */
|
||||
char crc_url[768]; /* playgoChunkCrcUrl, or "" */
|
||||
} patchdl_manifest_t;
|
||||
|
||||
/* Fetch + parse a Sony JSON manifest into a validated, contiguously-tiled
|
||||
piece list. Returns 0 on success (caller frees with patchdl_manifest_free),
|
||||
-1 on fetch/parse/tiling failure. */
|
||||
int patchdl_fetch_manifest(const char *manifest_url, patchdl_manifest_t *out);
|
||||
void patchdl_manifest_free(patchdl_manifest_t *m);
|
||||
|
||||
|
||||
/* Live state shared with one in-flight piece download. The worker owns these;
|
||||
the curl callbacks read `abort` (set elsewhere) and publish progress into
|
||||
`bytes_slot` (single-writer per worker slot). */
|
||||
typedef struct {
|
||||
volatile long long *bytes_slot; /* bytes written so far for this piece */
|
||||
volatile int *abort; /* non-zero -> stop this transfer */
|
||||
} patchdl_piece_ctx_t;
|
||||
|
||||
/* Download one whole piece and pwrite it into `fd` at `file_offset`. Concurrent
|
||||
non-overlapping pieces of the same fd are safe. Returns 0 on success (and
|
||||
fdatasyncs fd), -1 on network/IO/abort, -2 on a SHA-256 mismatch.
|
||||
`curl_rc_out`/`http_code_out` (either may be NULL) receive the last libcurl
|
||||
CURLcode + HTTP status for failure diagnosis. */
|
||||
int patchdl_http_download_piece(const char *url, int fd,
|
||||
long long file_offset, long long file_size,
|
||||
const char *expected_sha256_or_null,
|
||||
patchdl_piece_ctx_t *ctx,
|
||||
int *curl_rc_out, long *http_code_out);
|
||||
|
||||
/* Read-only: SHA-256 a [offset, offset+size) region of fd into out_hex
|
||||
(caller provides >= 65 bytes). Returns 0 on success. */
|
||||
int patchdl_sha256_fd_region(int fd, long long offset, long long size,
|
||||
char *out_hex);
|
||||
|
||||
/* Progress callback. Return non-zero to ABORT the in-flight download (used to
|
||||
cancel large patch downloads); return 0 to continue. */
|
||||
typedef int (*patchdl_download_progress_cb)(void *ctx,
|
||||
long long downloaded,
|
||||
long long total);
|
||||
|
||||
/* Stream a URL to a file on disk (for large PKG downloads). Returns 0 on
|
||||
success and writes the byte count to *bytes_out. */
|
||||
int patchdl_http_download(const char *url, const char *dest_path,
|
||||
long long *bytes_out);
|
||||
int patchdl_http_download_progress(const char *url, const char *dest_path,
|
||||
long long *bytes_out,
|
||||
patchdl_download_progress_cb cb, void *ctx);
|
||||
|
||||
/* Download a Sony JSON package manifest by concatenating every entry in
|
||||
"pieces" into one installable PKG. When `verify` is non-zero each piece is
|
||||
checked against its manifest SHA-256 (a mismatch returns -2). When `resume`
|
||||
is non-zero an existing partial at dest_path is kept: fully-downloaded pieces
|
||||
are skipped and only the remainder is fetched (survives a reboot). On any
|
||||
failure the partial is left in place for a later resume. */
|
||||
int patchdl_http_download_manifest(const char *manifest_url, const char *dest_path,
|
||||
long long *bytes_out);
|
||||
int patchdl_http_download_manifest_progress(const char *manifest_url,
|
||||
const char *dest_path,
|
||||
long long *bytes_out,
|
||||
patchdl_download_progress_cb cb,
|
||||
void *ctx, int verify, int resume);
|
||||
|
||||
/* Diagnostic: run the GET pipeline for `url` and write a JSON report
|
||||
(dns result/ip, curl code, http status, bytes) into `out_json`. */
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_notify.h"
|
||||
#include "patchdl_version.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Send an on-screen PS5 notification at startup showing the web UI URL
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_proc.h"
|
||||
|
||||
#include <signal.h>
|
||||
@@ -34,16 +43,26 @@ find_pid(const char *name) {
|
||||
if (!(buf = malloc(buf_size))) return -1;
|
||||
if (sysctl(mib, 4, buf, &buf_size, 0, 0)) { free(buf); return -1; }
|
||||
|
||||
for (uint8_t *ptr = buf; ptr < buf + buf_size; ) {
|
||||
int ki_structsize = *(int *)(ptr + KINFO_OFF_STRUCTSIZE);
|
||||
pid_t ki_pid = *(pid_t *)(ptr + KINFO_OFF_PID);
|
||||
char *ki_tdname = (char *)(ptr + KINFO_OFF_TDNAME);
|
||||
/* The loop guard guarantees the structsize/pid/tdname fields are inside the
|
||||
buffer before we read them, and the per-record check below keeps the name
|
||||
compare within the record (and thus the buffer). */
|
||||
for (uint8_t *ptr = buf; ptr + KINFO_OFF_TDNAME < buf + buf_size; ) {
|
||||
int ki_structsize = *(int *)(ptr + KINFO_OFF_STRUCTSIZE);
|
||||
pid_t ki_pid;
|
||||
char *ki_tdname;
|
||||
size_t name_max;
|
||||
|
||||
if (ki_structsize <= 0) break; /* guard against malformed entries */
|
||||
ptr += ki_structsize;
|
||||
if (ki_structsize <= KINFO_OFF_TDNAME) break; /* malformed/truncated */
|
||||
if (ptr + ki_structsize > buf + buf_size) break; /* record past buffer */
|
||||
|
||||
if (!strcmp(name, ki_tdname) && ki_pid != mypid)
|
||||
ki_pid = *(pid_t *)(ptr + KINFO_OFF_PID);
|
||||
ki_tdname = (char *)(ptr + KINFO_OFF_TDNAME);
|
||||
name_max = (size_t)(ptr + ki_structsize - (uint8_t *)ki_tdname);
|
||||
|
||||
if (!strncmp(name, ki_tdname, name_max) && ki_pid != mypid)
|
||||
pid = ki_pid;
|
||||
|
||||
ptr += ki_structsize;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
@@ -55,7 +74,10 @@ patchdl_proc_kill_others(const char *name) {
|
||||
int killed = 0;
|
||||
pid_t pid;
|
||||
|
||||
while ((pid = find_pid(name)) > 0) {
|
||||
/* Bound the loop: at startup we expect 0-1 stale instance. A pathological
|
||||
proc table (or kill returning success but the process not exiting) would
|
||||
otherwise stall startup for sleep(1) × N. */
|
||||
while (killed < 8 && (pid = find_pid(name)) > 0) {
|
||||
if (kill(pid, SIGKILL))
|
||||
break;
|
||||
killed++;
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Set this process's (main thread) name as shown in the PS5 process list. */
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_prospero.h"
|
||||
#include "patchdl_net.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PROSPERO_BASE "https://prosperopatches.com"
|
||||
#define PROSPERO_API PROSPERO_BASE "/api/internal"
|
||||
#define BUF_MAX (512 * 1024)
|
||||
|
||||
/* Prospero firmware strings use the same hex-digits-as-decimal encoding
|
||||
as Sony's system_ver: "10.20.00.06" packs to 0x10200006. Parse with
|
||||
%x so the hex bytes compare correctly against g_fw.bin. */
|
||||
static uint32_t
|
||||
fw_str_to_bin(const char *s) {
|
||||
unsigned a = 0, b = 0, c = 0, d = 0;
|
||||
sscanf(s, "%x.%x.%x.%x", &a, &b, &c, &d);
|
||||
return (a << 24) | (b << 16) | (c << 8) | d;
|
||||
}
|
||||
|
||||
static void
|
||||
fw_bin_to_display(uint32_t bin, char *out, size_t sz) {
|
||||
snprintf(out, sz, "%x.%02x", (bin >> 24) & 0xff, (bin >> 16) & 0xff);
|
||||
}
|
||||
|
||||
/* Extract the first occurrence of `data-key="<hex>"` from HTML. */
|
||||
static int
|
||||
extract_data_key(const char *html, char *out, size_t out_sz) {
|
||||
const char *needle = "data-key=\"";
|
||||
const char *p = strstr(html, needle);
|
||||
if (!p) return -1;
|
||||
p += strlen(needle);
|
||||
size_t len = 0;
|
||||
while (p[len] && p[len] != '"' && len < out_sz - 1)
|
||||
len++;
|
||||
if (!len || p[len] != '"') return -1;
|
||||
memcpy(out, p, len);
|
||||
out[len] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the next JSON string value for a given key inside a JSON object
|
||||
fragment. Crude but sufficient for the predictable Prospero response. */
|
||||
static const char *
|
||||
json_str_val(const char *json, const char *key, char *out, size_t out_sz) {
|
||||
char needle[64];
|
||||
snprintf(needle, sizeof(needle), "\"%s\"", key);
|
||||
const char *p = strstr(json, needle);
|
||||
if (!p) return NULL;
|
||||
p += strlen(needle);
|
||||
while (*p == ' ' || *p == ':') p++;
|
||||
if (*p != '"') return NULL;
|
||||
p++;
|
||||
size_t len = 0;
|
||||
while (p[len] && p[len] != '"' && len < out_sz - 1)
|
||||
len++;
|
||||
memcpy(out, p, len);
|
||||
out[len] = '\0';
|
||||
return p + len + 1;
|
||||
}
|
||||
|
||||
/* Check if a JSON fragment contains "success":true */
|
||||
static int
|
||||
json_success(const char *json) {
|
||||
const char *p = strstr(json, "\"success\"");
|
||||
if (!p) return 0;
|
||||
p += 9;
|
||||
while (*p == ' ' || *p == ':') p++;
|
||||
return !strncmp(p, "true", 4);
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_prospero_query(const char *title_id, uint32_t fw_bin,
|
||||
patchdl_prospero_result_t *out) {
|
||||
patchdl_buf_t buf;
|
||||
char url[256], key[128], body[256];
|
||||
char best_ver[16] = {0}, best_size[16] = {0};
|
||||
uint32_t best_fw = 0;
|
||||
|
||||
if (!title_id || !out) return -1;
|
||||
memset(out, 0, sizeof(*out));
|
||||
|
||||
/* Step 1: fetch the title page to get the data-key. */
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
buf.max = BUF_MAX;
|
||||
snprintf(url, sizeof(url), "%s/%.16s", PROSPERO_BASE, title_id);
|
||||
if (patchdl_http_get_external(url, &buf)) return -1;
|
||||
if (!buf.data) return -1;
|
||||
|
||||
if (extract_data_key(buf.data, key, sizeof(key))) {
|
||||
free(buf.data);
|
||||
return -1;
|
||||
}
|
||||
free(buf.data);
|
||||
|
||||
/* Step 2: POST loadpatches. The API expects JSON in the body but
|
||||
application/x-www-form-urlencoded as Content-Type — this is how
|
||||
the website and every known third-party client calls it. */
|
||||
snprintf(body, sizeof(body),
|
||||
"{\"titleid\":\"%.16s\",\"key\":\"%s\"}", title_id, key);
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
buf.max = BUF_MAX;
|
||||
if (patchdl_http_post_external(
|
||||
PROSPERO_API "/loadpatches",
|
||||
"application/x-www-form-urlencoded; charset=UTF-8",
|
||||
body, &buf)) return -1;
|
||||
if (!buf.data) return -1;
|
||||
|
||||
if (!json_success(buf.data)) {
|
||||
free(buf.data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Walk the patches array. Each entry looks like:
|
||||
{"content_ver":"01.003.000","required_firmware":"07.01.01.00",...}
|
||||
Find the newest version whose firmware requirement is met. */
|
||||
const char *cursor = buf.data;
|
||||
while ((cursor = strstr(cursor, "\"content_ver\""))) {
|
||||
char ver[16] = {0}, fw[32] = {0}, size[16] = {0};
|
||||
|
||||
json_str_val(cursor, "content_ver", ver, sizeof(ver));
|
||||
json_str_val(cursor, "filesize", size, sizeof(size));
|
||||
json_str_val(cursor, "required_firmware", fw, sizeof(fw));
|
||||
|
||||
if (ver[0] && fw[0]) {
|
||||
uint32_t pkg_fw = fw_str_to_bin(fw);
|
||||
if (pkg_fw <= fw_bin) {
|
||||
if (!best_ver[0] || strcmp(ver, best_ver) > 0) {
|
||||
strncpy(best_ver, ver, sizeof(best_ver) - 1);
|
||||
memcpy(best_size, size, sizeof(best_size));
|
||||
best_fw = pkg_fw;
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor++;
|
||||
}
|
||||
free(buf.data);
|
||||
|
||||
if (best_ver[0]) {
|
||||
strncpy(out->version, best_ver, sizeof(out->version) - 1);
|
||||
fw_bin_to_display(best_fw, out->required_fw, sizeof(out->required_fw));
|
||||
memcpy(out->size, best_size, sizeof(out->size));
|
||||
out->found = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
char version[16]; /* e.g. "01.003.000" */
|
||||
char required_fw[16]; /* PatchDL display format, e.g. "7.01" */
|
||||
char size[16]; /* Prospero's label, e.g. "71.7 GB" (GiB, rounded up) */
|
||||
int found;
|
||||
} patchdl_prospero_result_t;
|
||||
|
||||
/* Query prosperopatches.com for the newest patch of `title_id` whose
|
||||
firmware requirement is <= fw_bin. Returns 0 on success (result may
|
||||
still have found==0 if no compatible patch exists), -1 on network or
|
||||
parse failure. Best-effort: a failure means the UI shows no Prospero
|
||||
data, nothing breaks. */
|
||||
int patchdl_prospero_query(const char *title_id, uint32_t fw_bin,
|
||||
patchdl_prospero_result_t *out);
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_resolve.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -27,6 +36,14 @@ lookup_tsv(const char *title_id, char *url_out, size_t url_sz) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
/* Defense in depth: the TSV file lives under /data/patchdl, writable
|
||||
by anyone with /data access. patchdl_http_get also enforces
|
||||
host_allowed, but rejecting non-https / non-Sony schemes here means
|
||||
a poisoned line can't even reach the network layer. */
|
||||
if (strncmp(url, "https://", 8) != 0) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
memcpy(url_out, url, len + 1);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
@@ -35,16 +52,6 @@ lookup_tsv(const char *title_id, char *url_out, size_t url_sz) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
lookup_prosperopatches(const char *title_id, char *url_out, size_t url_sz) {
|
||||
/* TODO: implement live lookup once API endpoint is confirmed on-device.
|
||||
prosperopatches.com serves Sony CDN index links for PS5 titles. */
|
||||
(void)title_id;
|
||||
(void)url_out;
|
||||
(void)url_sz;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_resolve_url(const char *title_id, char *url_out, size_t url_sz) {
|
||||
if (!title_id) return -1;
|
||||
@@ -57,8 +64,5 @@ patchdl_resolve_url(const char *title_id, char *url_out, size_t url_sz) {
|
||||
strncmp(title_id, "PPSC", 4))
|
||||
return -1;
|
||||
|
||||
if (!lookup_tsv(title_id, url_out, url_sz))
|
||||
return 0;
|
||||
|
||||
return lookup_prosperopatches(title_id, url_out, url_sz);
|
||||
return lookup_tsv(title_id, url_out, url_sz);
|
||||
}
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_scan.h"
|
||||
#include "patchdl_appdb.h"
|
||||
|
||||
#include <ps5/kernel.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -23,6 +34,26 @@ static const char *SCAN_DIRS[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* The first scan runs single-threaded with the process root swapped to the
|
||||
system root and keeps a handle to that root. Later scans (other threads are
|
||||
running, so the root must not move) change only the working directory to
|
||||
it and drop the leading '/' of every path, see sys_path. Nothing else in
|
||||
PatchDL opens relative paths. */
|
||||
static int g_sysroot_fd = -1;
|
||||
static int g_rel_paths;
|
||||
/* Step the running scan is in, for diagnosing slow rescans. */
|
||||
static const char *volatile g_scan_step = "idle";
|
||||
|
||||
const char *
|
||||
patchdl_scan_step(void) {
|
||||
return g_scan_step;
|
||||
}
|
||||
|
||||
static const char *
|
||||
sys_path(const char *p) {
|
||||
return (g_rel_paths && p[0] == '/') ? p + 1 : p;
|
||||
}
|
||||
|
||||
/* ---------- param.json -------------------------------------------------- */
|
||||
|
||||
static int
|
||||
@@ -80,7 +111,7 @@ try_param_json(const char *dir, patchdl_title_t *t) {
|
||||
size_t n;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/sce_sys/param.json", dir);
|
||||
fp = fopen(path, "r");
|
||||
fp = fopen(sys_path(path), "r");
|
||||
if (!fp) return -1;
|
||||
n = fread(buf, 1, sizeof(buf) - 1, fp);
|
||||
fclose(fp);
|
||||
@@ -140,13 +171,23 @@ sfo_get(const uint8_t *buf, size_t bufsz, const char *key,
|
||||
|
||||
entries = (const sfo_entry_t *)(buf + sizeof(*h));
|
||||
|
||||
/* The entry table itself must fit in the bytes we actually read; a crafted
|
||||
param.sfo (from a shadow-mounted game dir) could otherwise drive
|
||||
entries[i] past the buffer. */
|
||||
if (sizeof(*h) + (size_t)h->num_entries * sizeof(sfo_entry_t) > bufsz)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < h->num_entries; i++) {
|
||||
size_t key_off = h->key_table_start + entries[i].key_offset;
|
||||
size_t val_off = h->data_table_start + entries[i].data_offset;
|
||||
|
||||
if (key_off >= bufsz || val_off >= bufsz) continue;
|
||||
|
||||
const char *k = (const char *)(buf + key_off);
|
||||
const char *k = (const char *)(buf + key_off);
|
||||
size_t kmax = bufsz - key_off;
|
||||
/* Require the key to be NUL-terminated within the buffer before the
|
||||
strcmp, otherwise it would read past the end. */
|
||||
if (strnlen(k, kmax) == kmax) continue;
|
||||
if (strcmp(k, key)) continue;
|
||||
if (entries[i].data_fmt != SFO_FMT_STR) return -1;
|
||||
|
||||
@@ -169,7 +210,7 @@ try_param_sfo(const char *dir, patchdl_title_t *t) {
|
||||
struct stat st;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/sce_sys/param.sfo", dir);
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(sys_path(path), "rb");
|
||||
if (!fp) return -1;
|
||||
|
||||
if (fstat(fileno(fp), &st) || (size_t)st.st_size > sizeof(buf)) {
|
||||
@@ -198,7 +239,7 @@ path_exists(const char *dir, const char *rel) {
|
||||
char p[PATH_MAX];
|
||||
struct stat st;
|
||||
snprintf(p, sizeof(p), "%s/%s", dir, rel);
|
||||
return stat(p, &st) == 0;
|
||||
return stat(sys_path(p), &st) == 0;
|
||||
}
|
||||
|
||||
/* Read up to sz-1 bytes of dir/rel into buf (NUL-terminated). 0 on success. */
|
||||
@@ -209,7 +250,7 @@ read_small_file(const char *dir, const char *rel, char *buf, size_t sz) {
|
||||
size_t n;
|
||||
|
||||
snprintf(p, sizeof(p), "%s/%s", dir, rel);
|
||||
fp = fopen(p, "rb");
|
||||
fp = fopen(sys_path(p), "rb");
|
||||
if (!fp) return -1;
|
||||
n = fread(buf, 1, sz - 1, fp);
|
||||
fclose(fp);
|
||||
@@ -217,41 +258,92 @@ read_small_file(const char *dir, const char *rel, char *buf, size_t sz) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Keep only actual games. Skip PS5 system apps (NPXS), the Payload Manager
|
||||
fake app (PLDM) and ELF-loader homebrew (PSPS). */
|
||||
/* Tell a Sony-signed package from a debug/fake-signed one by its header.
|
||||
PS5 finalized image "\x7FFIH": byte 0x05 is 0x80 for retail, 0x00 for
|
||||
debug (matches Sony's CDN patches, which start 7F 46 49 48 01 80).
|
||||
PS4 container "\x7FCNT": bit 0 of byte 4 is set for retail, clear for a
|
||||
fake package (same test Itemzflow uses). */
|
||||
static patchdl_pkg_sign_t
|
||||
pkg_sign_state(const char *dir) {
|
||||
char p[PATH_MAX];
|
||||
unsigned char h[8];
|
||||
FILE *fp;
|
||||
size_t n;
|
||||
|
||||
snprintf(p, sizeof(p), "%s/app.pkg", dir);
|
||||
fp = fopen(sys_path(p), "rb");
|
||||
if (!fp) return PATCHDL_PKG_UNREAD;
|
||||
n = fread(h, 1, sizeof(h), fp);
|
||||
fclose(fp);
|
||||
if (n < sizeof(h)) return PATCHDL_PKG_UNREAD;
|
||||
|
||||
if (!memcmp(h, "\x7f" "FIH", 4))
|
||||
return (h[5] & 0x80) ? PATCHDL_PKG_RETAIL : PATCHDL_PKG_FAKE;
|
||||
if (!memcmp(h, "\x7f" "CNT", 4))
|
||||
return (h[4] & 0x01) ? PATCHDL_PKG_RETAIL : PATCHDL_PKG_FAKE;
|
||||
return PATCHDL_PKG_UNREAD;
|
||||
}
|
||||
|
||||
/* Keep only actual games: PS5 (PPSA) and PS4 (CUSA) title ids followed by
|
||||
five digits. System apps (NPXS) and homebrew with made-up ids (PatchDL's
|
||||
own tile PTDL00001, loaders, file managers) have no Sony updates. */
|
||||
static int
|
||||
is_game_title(const char *title_id) {
|
||||
if (!strncmp(title_id, "NPXS", 4)) return 0;
|
||||
if (!strncmp(title_id, "PLDM", 4)) return 0;
|
||||
if (!strncmp(title_id, "PSPS", 4)) return 0;
|
||||
if (strncmp(title_id, "PPSA", 4) && strncmp(title_id, "CUSA", 4))
|
||||
return 0;
|
||||
for (int i = 4; i < 9; i++)
|
||||
if (title_id[i] < '0' || title_id[i] > '9')
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------- directory scanner ------------------------------------------- */
|
||||
|
||||
/* Authoritative shadowmount test: ShadowMountPlus routes its images through
|
||||
/mnt/shadowmnt (a pfs from /dev/lvdN there, then a nullfs onto the app dir),
|
||||
so a title whose mount table references /mnt/shadowmnt is a shadowmount. The
|
||||
on-disk mount.lnk marker is unreliable across reboots/remounts; the live
|
||||
mount table is not. */
|
||||
static int
|
||||
mount_is_shadow(const char *title_id, const struct statfs *mounts, int nmounts) {
|
||||
for (int i = 0; i < nmounts; i++) {
|
||||
const char *from = mounts[i].f_mntfromname;
|
||||
const char *on = mounts[i].f_mntonname;
|
||||
if ((strstr(from, "/mnt/shadowmnt") || strstr(on, "/mnt/shadowmnt")) &&
|
||||
(strstr(from, title_id) || strstr(on, title_id)))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Distinguish genuine installs from ShadowMountPlus mounts by on-disk layout
|
||||
* under /user/app/<TID>/ (verified on fw 11.60):
|
||||
* - mount.lnk / mount_img.lnk + full sce_sys/ -> ShadowMountPlus mount
|
||||
* - app.pkg (no mount.lnk) -> genuine install; app.json
|
||||
* with CDN piece URLs means a not-downloaded preinstall stub, local
|
||||
* URLs mean a real install
|
||||
* - app.json with "fake":true -> homebrew fake (skip)
|
||||
* Classify each /user/app/<TID> (verified on fw 11.60):
|
||||
* - mount table references /mnt/shadowmnt for the title -> ShadowMountPlus
|
||||
* mount (authoritative; mount.lnk is only a fallback hint)
|
||||
* - app.pkg (no shadow mount) -> its header decides: Sony-signed is a
|
||||
* genuine install (store or disc), debug/fake-signed is a fake package
|
||||
* (listed, but never checked, downloaded or patched), unreadable is unknown
|
||||
* - app.json with "fake":true and no app.pkg -> homebrew (skip). With an
|
||||
* app.pkg the marker only says the package did not come from Sony's CDN
|
||||
* (PatchDL's own loopback install sets it too), so the header decides.
|
||||
*/
|
||||
static int
|
||||
scan_one(const char *base, const char *name, patchdl_title_t *t) {
|
||||
scan_one(const char *base, const char *name, patchdl_title_t *t,
|
||||
const struct statfs *mounts, int nmounts) {
|
||||
char dir[PATH_MAX];
|
||||
char appjson[4096];
|
||||
int has_mountlnk, has_app_pkg, has_paramjson, is_fake = 0, is_cdn = 0;
|
||||
int has_mountlnk, has_app_pkg, has_paramjson, is_shadow, is_fake = 0;
|
||||
|
||||
snprintf(dir, sizeof(dir), "%s/%s", base, name);
|
||||
memset(t, 0, sizeof(*t));
|
||||
t->icon_fd = -1;
|
||||
strncpy(t->source_path, dir, sizeof(t->source_path) - 1);
|
||||
strncpy(t->title_id, name, sizeof(t->title_id) - 1);
|
||||
|
||||
if (!is_game_title(t->title_id))
|
||||
return -1;
|
||||
|
||||
is_shadow = mount_is_shadow(t->title_id, mounts, nmounts);
|
||||
has_mountlnk = path_exists(dir, "mount.lnk") ||
|
||||
path_exists(dir, "mount_img.lnk");
|
||||
has_app_pkg = path_exists(dir, "app.pkg");
|
||||
@@ -260,25 +352,32 @@ scan_one(const char *base, const char *name, patchdl_title_t *t) {
|
||||
if (!read_small_file(dir, "app.json", appjson, sizeof(appjson))) {
|
||||
if (strstr(appjson, "\"fake\"") && strstr(appjson, "true"))
|
||||
is_fake = 1;
|
||||
if (strstr(appjson, "http"))
|
||||
is_cdn = 1; /* piece URLs point at the Sony CDN -> preinstall */
|
||||
}
|
||||
if (is_fake)
|
||||
/* "fake": true marks both homebrew and installed fake packages. Only
|
||||
homebrew (no app.pkg) drops out; a fake package stays in the list. */
|
||||
if (is_fake && !has_app_pkg)
|
||||
return -1;
|
||||
|
||||
if (has_mountlnk) {
|
||||
/* metadata lives in the mounted sce_sys (param.json, or param.sfo
|
||||
for PS4 titles) */
|
||||
if (try_param_json(dir, t))
|
||||
/* app.pkg is the on-disk package of a genuine install; ShadowMountPlus
|
||||
titles never have it (they have mounted/leftover sce_sys content). So
|
||||
app.pkg is the reliable genuine-vs-shadow discriminator — independent of
|
||||
whether the shadow image is currently mounted. */
|
||||
if (has_app_pkg) {
|
||||
/* app.json piece URLs are no signal: disc and store installs carry
|
||||
CDN URLs there too. The package header is. */
|
||||
t->pkg_sign = pkg_sign_state(dir);
|
||||
/* The header wins over the installer's fake marker: a retail package
|
||||
installed from a local URL is marked fake but is still Sony's. The
|
||||
marker only decides when the header can't be read. */
|
||||
t->source_type = t->pkg_sign == PATCHDL_PKG_RETAIL ? PATCHDL_SOURCE_OFFICIAL
|
||||
: (is_fake || t->pkg_sign == PATCHDL_PKG_FAKE)
|
||||
? PATCHDL_SOURCE_FAKE
|
||||
: PATCHDL_SOURCE_UNKNOWN;
|
||||
} else if (is_shadow || has_mountlnk || has_paramjson ||
|
||||
path_exists(dir, "sce_sys/param.sfo")) {
|
||||
if (try_param_json(dir, t)) /* metadata from the mounted sce_sys */
|
||||
try_param_sfo(dir, t);
|
||||
t->source_type = PATCHDL_SOURCE_SHADOWMOUNT;
|
||||
} else if (has_app_pkg) {
|
||||
t->source_type = is_cdn ? PATCHDL_SOURCE_UNKNOWN
|
||||
: PATCHDL_SOURCE_OFFICIAL;
|
||||
} else if (has_paramjson || path_exists(dir, "sce_sys/param.sfo")) {
|
||||
if (try_param_json(dir, t)) /* genuine game currently mounted */
|
||||
try_param_sfo(dir, t);
|
||||
t->source_type = PATCHDL_SOURCE_OFFICIAL;
|
||||
} else {
|
||||
return -1; /* empty / leftover directory */
|
||||
}
|
||||
@@ -300,17 +399,18 @@ already_seen(const patchdl_title_t *arr, size_t cnt, const char *title_id) {
|
||||
}
|
||||
|
||||
static void
|
||||
scan_base(const char *base, patchdl_title_t *arr, size_t *cnt, size_t cap) {
|
||||
scan_base(const char *base, patchdl_title_t *arr, size_t *cnt, size_t cap,
|
||||
const struct statfs *mounts, int nmounts) {
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
|
||||
d = opendir(base);
|
||||
d = opendir(sys_path(base));
|
||||
if (!d) return;
|
||||
|
||||
while ((de = readdir(d))) {
|
||||
if (de->d_name[0] == '.') continue;
|
||||
if (*cnt >= cap) break;
|
||||
if (scan_one(base, de->d_name, &arr[*cnt]) != 0)
|
||||
if (scan_one(base, de->d_name, &arr[*cnt], mounts, nmounts) != 0)
|
||||
continue;
|
||||
if (already_seen(arr, *cnt, arr[*cnt].title_id))
|
||||
continue; /* dedupe a title already found in an earlier base */
|
||||
@@ -327,20 +427,90 @@ patchdl_source_str(patchdl_source_t src) {
|
||||
case PATCHDL_SOURCE_OFFICIAL: return "official";
|
||||
case PATCHDL_SOURCE_EXTERNAL: return "external";
|
||||
case PATCHDL_SOURCE_SHADOWMOUNT: return "shadowmount";
|
||||
case PATCHDL_SOURCE_FAKE: return "fake";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/* Open a title's icon0.png while the scan still sees the whole filesystem.
|
||||
The web server can't reach these paths later, but an fd opened now stays
|
||||
readable. Tries the app.db path first, then the usual install locations.
|
||||
Returns an fd to a non-empty PNG of sane size, or -1. */
|
||||
#define ICON_MAX_BYTES (4 * 1024 * 1024)
|
||||
|
||||
static int
|
||||
open_png(const char *path) {
|
||||
unsigned char magic[8];
|
||||
struct stat st;
|
||||
int fd;
|
||||
|
||||
if (!path || path[0] != '/') return -1;
|
||||
fd = open(sys_path(path), O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) return -1;
|
||||
if (fstat(fd, &st) || !S_ISREG(st.st_mode) ||
|
||||
st.st_size < 8 || st.st_size > ICON_MAX_BYTES ||
|
||||
pread(fd, magic, 8, 0) != 8 ||
|
||||
memcmp(magic, "\x89PNG\r\n\x1a\n", 8)) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int
|
||||
open_icon(const patchdl_title_t *t, const char *db_path) {
|
||||
static const char *const candidates[] = {
|
||||
"/user/appmeta/%s/icon0.png",
|
||||
"/user/appmeta/external/%s/icon0.png",
|
||||
"%s/sce_sys/icon0.png", /* source_path, e.g. a shadowmount */
|
||||
NULL,
|
||||
};
|
||||
char path[PATH_MAX];
|
||||
int fd = open_png(db_path);
|
||||
|
||||
for (int i = 0; fd < 0 && candidates[i]; i++) {
|
||||
snprintf(path, sizeof(path), candidates[i],
|
||||
i < 2 ? t->title_id : t->source_path);
|
||||
fd = open_png(path);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* After an install the console rewrites /user/appmeta/<id>/param.json at
|
||||
once, while app.db keeps the old CONTENT_VERSION until later (seen: until
|
||||
the game was started). Take the newer of the two so a finished update
|
||||
doesn't look pending. */
|
||||
static void
|
||||
newer_appmeta_version(patchdl_title_t *t) {
|
||||
char path[PATH_MAX], buf[8192], ver[16] = {0};
|
||||
FILE *fp;
|
||||
size_t n;
|
||||
|
||||
snprintf(path, sizeof(path), "/user/appmeta/%s/param.json", t->title_id);
|
||||
if (!(fp = fopen(sys_path(path), "r"))) return;
|
||||
n = fread(buf, 1, sizeof(buf) - 1, fp);
|
||||
fclose(fp);
|
||||
buf[n] = '\0';
|
||||
if (json_str(buf, "contentVersion", ver, sizeof(ver)) == 0 &&
|
||||
strcmp(ver, t->installed_version) > 0)
|
||||
snprintf(t->installed_version, sizeof(t->installed_version), "%s", ver);
|
||||
}
|
||||
|
||||
/* Overlay app.db metadata (real title name, installed version, version.xml
|
||||
URL) onto the scanned titles. Genuine installs have no readable param.json,
|
||||
so this is the only source of their name/version. */
|
||||
static void
|
||||
static int
|
||||
merge_appdb(patchdl_title_t *arr, size_t cnt) {
|
||||
patchdl_appinfo_t *info = NULL;
|
||||
size_t n = 0;
|
||||
|
||||
if (patchdl_appdb_load(&info, &n))
|
||||
return;
|
||||
{
|
||||
int rc = patchdl_appdb_load(&info, &n, g_rel_paths);
|
||||
if (rc) {
|
||||
g_scan_step = rc == -2 ? patchdl_appdb_error() : "fail: appdb read";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < cnt; i++) {
|
||||
const patchdl_appinfo_t *a = patchdl_appdb_find(info, n, arr[i].title_id);
|
||||
@@ -358,47 +528,170 @@ merge_appdb(patchdl_title_t *arr, size_t cnt) {
|
||||
sizeof(arr[i].version_file_uri) - 1);
|
||||
}
|
||||
|
||||
patchdl_appdb_free(info);
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_scan(patchdl_title_t **titles_out, size_t *count_out) {
|
||||
patchdl_title_t *arr;
|
||||
size_t cnt = 0;
|
||||
pid_t pid = getpid();
|
||||
intptr_t saved_root = 0, root_vnode;
|
||||
int using_vswap = 0;
|
||||
|
||||
arr = calloc(MAX_TITLES, sizeof(*arr));
|
||||
if (!arr) return -1;
|
||||
|
||||
/* Elevate so privileged paths (the app.db under /system_data) are
|
||||
readable; same authid ftpsrv uses. No-op without kernel R/W. */
|
||||
kernel_set_ucred_authid(pid, 0x4801000000000013L);
|
||||
|
||||
root_vnode = kernel_get_root_vnode();
|
||||
if (root_vnode) {
|
||||
saved_root = kernel_get_proc_rootdir(pid);
|
||||
kernel_set_proc_rootdir(pid, root_vnode);
|
||||
using_vswap = 1;
|
||||
g_scan_step = "icons";
|
||||
for (size_t i = 0; i < cnt; i++) {
|
||||
const patchdl_appinfo_t *a = patchdl_appdb_find(info, n, arr[i].title_id);
|
||||
arr[i].icon_fd = open_icon(&arr[i], a ? a->icon_path : NULL);
|
||||
if (arr[i].pkg_sign != PATCHDL_PKG_NONE)
|
||||
newer_appmeta_version(&arr[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; SCAN_DIRS[i]; i++)
|
||||
scan_base(SCAN_DIRS[i], arr, &cnt, MAX_TITLES);
|
||||
patchdl_appdb_free(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
merge_appdb(arr, cnt);
|
||||
/* See patchdl_scan_lock — once set, patchdl_scan no longer swaps the root
|
||||
(it rescans via the kept system root handle) and the debug dump returns
|
||||
NULL, so neither can race the running MHD threads. */
|
||||
static _Atomic int g_scan_locked = 0;
|
||||
|
||||
if (using_vswap)
|
||||
kernel_set_proc_rootdir(pid, saved_root);
|
||||
void
|
||||
patchdl_scan_lock(void) {
|
||||
atomic_store(&g_scan_locked, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
scan_all(patchdl_title_t **titles_out, size_t *count_out) {
|
||||
patchdl_title_t *arr;
|
||||
size_t cnt = 0;
|
||||
struct statfs *mounts = NULL;
|
||||
int nmounts;
|
||||
|
||||
arr = calloc(MAX_TITLES, sizeof(*arr));
|
||||
if (!arr) { g_scan_step = "fail: oom"; return -1; }
|
||||
|
||||
/* Global mount table for shadowmount detection. getmntinfo's buffer is
|
||||
libc-managed — must NOT be freed. */
|
||||
g_scan_step = "mounts";
|
||||
nmounts = getmntinfo(&mounts, MNT_NOWAIT);
|
||||
if (nmounts < 0) { nmounts = 0; mounts = NULL; }
|
||||
|
||||
for (int i = 0; SCAN_DIRS[i]; i++) {
|
||||
g_scan_step = SCAN_DIRS[i];
|
||||
scan_base(SCAN_DIRS[i], arr, &cnt, MAX_TITLES, mounts, nmounts);
|
||||
}
|
||||
g_scan_step = "appdb";
|
||||
|
||||
/* At startup a list without app.db data still beats none. A rescan
|
||||
without it would wipe names and versions of a good list: fail instead
|
||||
and keep the old one. */
|
||||
if (merge_appdb(arr, cnt) && g_rel_paths) {
|
||||
free(arr);
|
||||
return -1;
|
||||
}
|
||||
g_scan_step = "idle";
|
||||
|
||||
*titles_out = arr;
|
||||
*count_out = cnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* A rescan while other threads run: resolve every path from the system root
|
||||
kept by the first scan, without touching the process root. */
|
||||
static int
|
||||
rescan_relative(patchdl_title_t **titles_out, size_t *count_out) {
|
||||
int cwd, rc;
|
||||
|
||||
if (g_sysroot_fd < 0) { g_scan_step = "fail: no system root handle"; return -1; }
|
||||
cwd = open(".", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (cwd < 0) { g_scan_step = "fail: open cwd"; return -1; }
|
||||
if (fchdir(g_sysroot_fd)) { g_scan_step = "fail: fchdir"; close(cwd); return -1; }
|
||||
g_rel_paths = 1;
|
||||
rc = scan_all(titles_out, count_out);
|
||||
g_rel_paths = 0;
|
||||
(void)fchdir(cwd); /* best effort: nothing else uses the cwd */
|
||||
close(cwd);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_scan(patchdl_title_t **titles_out, size_t *count_out) {
|
||||
pid_t pid = getpid();
|
||||
intptr_t saved_root = 0, root_vnode;
|
||||
int using_vswap = 0, rc;
|
||||
|
||||
/* Elevate so privileged paths (the app.db under /system_data) are
|
||||
readable; same authid ftpsrv uses. No-op without kernel R/W. */
|
||||
kernel_set_ucred_authid(pid, 0x4801000000000013L);
|
||||
|
||||
if (atomic_load(&g_scan_locked))
|
||||
return rescan_relative(titles_out, count_out);
|
||||
|
||||
root_vnode = kernel_get_root_vnode();
|
||||
if (root_vnode) {
|
||||
saved_root = kernel_get_proc_rootdir(pid);
|
||||
/* Only swap if we captured the current root, so we can always restore
|
||||
it. Leaving the process rooted at the system root would make later
|
||||
absolute-path writes land in the wrong place. */
|
||||
if (saved_root) {
|
||||
kernel_set_proc_rootdir(pid, root_vnode);
|
||||
using_vswap = 1;
|
||||
if (g_sysroot_fd < 0)
|
||||
g_sysroot_fd = open("/", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
}
|
||||
}
|
||||
|
||||
rc = scan_all(titles_out, count_out);
|
||||
|
||||
if (using_vswap)
|
||||
kernel_set_proc_rootdir(pid, saved_root);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_scan_read_app_file(const char *title_id, const char *name,
|
||||
char *buf, size_t sz) {
|
||||
char path[PATH_MAX];
|
||||
if (g_sysroot_fd < 0 || !sz) return -1;
|
||||
for (int i = 0; SCAN_DIRS[i]; i++) {
|
||||
int fd;
|
||||
ssize_t n;
|
||||
snprintf(path, sizeof(path), "%s/%s/%s", SCAN_DIRS[i] + 1, title_id, name);
|
||||
fd = openat(g_sysroot_fd, path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) continue;
|
||||
n = read(fd, buf, sz - 1);
|
||||
close(fd);
|
||||
if (n < 0) return -1;
|
||||
buf[n] = '\0';
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Fold one stat result into an FNV-1a hash. */
|
||||
static unsigned long long
|
||||
sig_add(unsigned long long h, const char *rel) {
|
||||
struct stat st;
|
||||
long long v[4] = {0};
|
||||
if (fstatat(g_sysroot_fd, rel, &st, 0) == 0) {
|
||||
v[0] = (long long)st.st_mtim.tv_sec;
|
||||
v[1] = (long long)st.st_mtim.tv_nsec;
|
||||
v[2] = (long long)st.st_size;
|
||||
v[3] = (long long)st.st_ino;
|
||||
}
|
||||
for (size_t i = 0; i < sizeof v; i++) {
|
||||
h ^= ((const unsigned char *)v)[i];
|
||||
h *= 1099511628211ULL;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned long long
|
||||
patchdl_scan_signature(void) {
|
||||
unsigned long long h = 14695981039346656037ULL;
|
||||
if (g_sysroot_fd < 0) return 0;
|
||||
for (int i = 0; SCAN_DIRS[i]; i++)
|
||||
h = sig_add(h, SCAN_DIRS[i] + 1);
|
||||
h = sig_add(h, "system_data/priv/mms/app.db");
|
||||
h = sig_add(h, "system_data/priv/mms/app.db-wal");
|
||||
return h ? h : 1;
|
||||
}
|
||||
|
||||
void
|
||||
patchdl_scan_free(patchdl_title_t *titles, size_t count) {
|
||||
(void)count;
|
||||
for (size_t i = 0; titles && i < count; i++)
|
||||
if (titles[i].icon_fd >= 0)
|
||||
close(titles[i].icon_fd);
|
||||
free(titles);
|
||||
}
|
||||
|
||||
@@ -426,6 +719,8 @@ patchdl_scan_debug_json(void) {
|
||||
char tmp[2048];
|
||||
pid_t pid = getpid();
|
||||
intptr_t saved_root = 0, root_vnode;
|
||||
|
||||
if (atomic_load(&g_scan_locked)) return NULL;
|
||||
int using_vswap = 0;
|
||||
struct statfs *mounts = NULL;
|
||||
int nmounts;
|
||||
@@ -450,8 +745,11 @@ patchdl_scan_debug_json(void) {
|
||||
root_vnode = kernel_get_root_vnode();
|
||||
if (root_vnode) {
|
||||
saved_root = kernel_get_proc_rootdir(pid);
|
||||
kernel_set_proc_rootdir(pid, root_vnode);
|
||||
using_vswap = 1;
|
||||
/* Only swap if we can restore it afterwards (see patchdl_scan). */
|
||||
if (saved_root) {
|
||||
kernel_set_proc_rootdir(pid, root_vnode);
|
||||
using_vswap = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; SCAN_DIRS[i]; i++) {
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -8,8 +17,17 @@ typedef enum {
|
||||
PATCHDL_SOURCE_EXTERNAL = 1,
|
||||
PATCHDL_SOURCE_SHADOWMOUNT = 2,
|
||||
PATCHDL_SOURCE_UNKNOWN = 3,
|
||||
PATCHDL_SOURCE_FAKE = 4, /* debug/fake-signed package: not supported */
|
||||
} patchdl_source_t;
|
||||
|
||||
/* Signing state read from the installed app.pkg header. */
|
||||
typedef enum {
|
||||
PATCHDL_PKG_NONE = 0, /* no app.pkg */
|
||||
PATCHDL_PKG_RETAIL = 1,
|
||||
PATCHDL_PKG_FAKE = 2,
|
||||
PATCHDL_PKG_UNREAD = 3, /* app.pkg present but header unreadable/unknown */
|
||||
} patchdl_pkg_sign_t;
|
||||
|
||||
typedef struct {
|
||||
char title_id[32];
|
||||
char content_id[64];
|
||||
@@ -19,13 +37,30 @@ typedef struct {
|
||||
char mount_from[256];
|
||||
char version_file_uri[256]; /* from app.db, for version.xml */
|
||||
patchdl_source_t source_type;
|
||||
patchdl_pkg_sign_t pkg_sign; /* app.pkg header verdict, for diagnostics */
|
||||
int icon_fd; /* open icon0.png, or -1; see patchdl_scan */
|
||||
/* populated by background verxml fetch — guarded by websrv mutex */
|
||||
char compatible_version[16];
|
||||
char latest_version[16];
|
||||
char latest_required_fw[16];
|
||||
char patch_url[512]; /* delta_url of the compatible patch */
|
||||
char patch_title_id[16]; /* title id embedded in patch_url */
|
||||
char patch_url[512]; /* manifest_url if present, otherwise pkg URL */
|
||||
char delta_url[512]; /* DP.pkg bootstrap URL (always a PKG) */
|
||||
char patch_title_id[16]; /* target title id from version.xml */
|
||||
char patch_storage_title_id[16]; /* title id embedded in delta_url */
|
||||
int verxml_done;
|
||||
/* Prospero Patches lookup (best compatible patch from version history) */
|
||||
char prospero_version[16];
|
||||
char prospero_required_fw[16];
|
||||
char prospero_size[16];
|
||||
int prospero_done;
|
||||
/* Manifest URL derived from a link the user pasted from Prospero. When
|
||||
set it replaces patch_url for download and install. */
|
||||
char manual_url[512];
|
||||
char manual_version[16];
|
||||
int enabled; /* user policy, persisted in config.json */
|
||||
int resumable; /* a partial download is on disk */
|
||||
int downloaded; /* a finished download is on disk */
|
||||
long long partial_bytes; /* size of that partial, for the UI */
|
||||
} patchdl_title_t;
|
||||
|
||||
int patchdl_scan(patchdl_title_t **titles_out, size_t *count_out);
|
||||
@@ -35,3 +70,25 @@ const char *patchdl_source_str(patchdl_source_t src);
|
||||
/* Diagnostic: malloc'd JSON dump of the mount table + scan-base directory
|
||||
listings. Caller frees. */
|
||||
char *patchdl_scan_debug_json(void);
|
||||
|
||||
/* Cheap change check for the automatic rescan: a hash over the title
|
||||
directories and Sony's app.db. 0 when it can't be computed (no system root
|
||||
handle), so callers never rescan on it. */
|
||||
unsigned long long patchdl_scan_signature(void);
|
||||
|
||||
/* Name of the step the running scan is in ("idle" when none). */
|
||||
const char *patchdl_scan_step(void);
|
||||
|
||||
/* Read <title dir>/<name> of an installed title (e.g. app.json) through the
|
||||
kept system root handle; thread-safe, no working-directory change.
|
||||
0 on success with a NUL-terminated buf. */
|
||||
int patchdl_scan_read_app_file(const char *title_id, const char *name,
|
||||
char *buf, size_t sz);
|
||||
|
||||
/* Mark scan/debug as no longer safe to call (must be set after MHD worker
|
||||
threads come up — patchdl_scan performs a process-wide vnode swap that
|
||||
would race any concurrent thread). After this is set, patchdl_scan rescans
|
||||
through the system root handle kept by the first scan (working directory
|
||||
only, one caller at a time) and the debug dump returns NULL. Call once
|
||||
during startup, after MHD_start_daemon. */
|
||||
void patchdl_scan_lock(void);
|
||||
@@ -0,0 +1,231 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_tile.h"
|
||||
#include "patchdl_install.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ps5/kernel.h>
|
||||
|
||||
/* Embed the tile assets into .rodata directly via .incbin — no codegen step,
|
||||
no Python helper, no second translation unit. */
|
||||
#define INCASSET(name, file) \
|
||||
__asm__(".section .rodata\n" \
|
||||
".global " #name "\n" \
|
||||
".global " #name "_end\n" \
|
||||
".global " #name "_size\n" \
|
||||
".align 16\n" #name ":\n" \
|
||||
".incbin \"" file "\"\n" #name "_end:\n" #name "_size:\n" \
|
||||
".quad " #name "_end - " #name "\n" \
|
||||
".previous\n"); \
|
||||
extern const uint8_t name[]; \
|
||||
extern const size_t name##_size;
|
||||
|
||||
INCASSET(tile_param_json, "assets/param.json");
|
||||
INCASSET(tile_icon0_png, "assets/icon0.png");
|
||||
|
||||
#define TILE_TITLE_ID "PTDL00001"
|
||||
|
||||
/* Forward decls — we resolve sceAppInstUtilInitialize/AppInstallTitleDir at
|
||||
runtime via the kernel dynlib helpers so the ELF stays loader-friendly. */
|
||||
typedef int (*ai_init_fn)(void);
|
||||
typedef int (*ai_install_dir_fn)(const char *title_id, const char *parent_dir,
|
||||
void *opts);
|
||||
typedef int (*ai_install_all_fn)(void *opts);
|
||||
|
||||
static intptr_t
|
||||
dynsym_by_name(const char *sym) {
|
||||
uint32_t h = 0;
|
||||
if (kernel_dynlib_handle(-1, "libSceAppInstUtil.sprx", &h) < 0) return 0;
|
||||
return kernel_dynlib_dlsym(-1, h, sym);
|
||||
}
|
||||
|
||||
static intptr_t
|
||||
dynsym_by_nid(const char *nid) {
|
||||
uint32_t h = 0;
|
||||
if (kernel_dynlib_handle(-1, "libSceAppInstUtil.sprx", &h) < 0) return 0;
|
||||
return kernel_dynlib_resolve(-1, h, nid);
|
||||
}
|
||||
|
||||
static int
|
||||
write_all(const char *path, const uint8_t *data, size_t size) {
|
||||
int fd;
|
||||
ssize_t w;
|
||||
size_t off = 0;
|
||||
|
||||
/* O_NOFOLLOW + 0600: don't follow a symlink at the destination, and don't
|
||||
create the file with the libc default 0666 mode. Same pattern as the
|
||||
net layer's fopen_safe. */
|
||||
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, 0600);
|
||||
if (fd < 0) return -1;
|
||||
while (off < size) {
|
||||
w = write(fd, data + off, size - off);
|
||||
if (w < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
off += (size_t)w;
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
file_matches(const char *path, const uint8_t *expected, size_t expected_size) {
|
||||
struct stat st;
|
||||
uint8_t *buf;
|
||||
int fd;
|
||||
ssize_t n;
|
||||
int match = 0;
|
||||
|
||||
if (stat(path, &st) != 0) return 0;
|
||||
if ((size_t)st.st_size != expected_size) return 0;
|
||||
|
||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) return 0;
|
||||
|
||||
buf = malloc(expected_size);
|
||||
if (!buf) { close(fd); return 0; }
|
||||
|
||||
n = read(fd, buf, expected_size);
|
||||
close(fd);
|
||||
if (n == (ssize_t)expected_size && memcmp(buf, expected, expected_size) == 0)
|
||||
match = 1;
|
||||
|
||||
free(buf);
|
||||
return match;
|
||||
}
|
||||
|
||||
int
|
||||
patchdl_tile_install_if_needed(char *msg, size_t msg_sz) {
|
||||
char base_dir[128];
|
||||
char sce_sys_dir[160];
|
||||
char param_path[192];
|
||||
char icon_path[192];
|
||||
char receipt_path[192];
|
||||
|
||||
ai_init_fn ai_initialize = NULL;
|
||||
ai_install_dir_fn ai_install_title = NULL;
|
||||
ai_install_all_fn ai_install_all = NULL;
|
||||
int rc;
|
||||
|
||||
snprintf(base_dir, sizeof base_dir, "/user/app/%s", TILE_TITLE_ID);
|
||||
snprintf(sce_sys_dir, sizeof sce_sys_dir, "/user/app/%s/sce_sys", TILE_TITLE_ID);
|
||||
snprintf(param_path, sizeof param_path, "/user/app/%s/sce_sys/param.json", TILE_TITLE_ID);
|
||||
snprintf(icon_path, sizeof icon_path, "/user/app/%s/sce_sys/icon0.png", TILE_TITLE_ID);
|
||||
/* Written only after the installer accepted the tile. Without it, files
|
||||
left behind by a failed registration would pass the stat-guard below
|
||||
and the tile would never be retried. */
|
||||
snprintf(receipt_path, sizeof receipt_path, "/user/app/%s/.patchdl_registered", TILE_TITLE_ID);
|
||||
|
||||
/* stat-guard: if everything on disk already matches, do nothing. Re-running
|
||||
the install API every payload start would be wasted work and burns the
|
||||
only safe path through Sony's installer state machine. */
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(receipt_path, &st) == 0 &&
|
||||
file_matches(param_path, tile_param_json, tile_param_json_size) &&
|
||||
file_matches(icon_path, tile_icon0_png, tile_icon0_png_size)) {
|
||||
snprintf(msg, msg_sz, "tile already installed and up to date");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* AppInstUtil is loaded lazily by the install backend thread. Poke it +
|
||||
poll briefly so libSceAppInstUtil.sprx is mapped before we try to
|
||||
resolve symbols out of it. Bounded to a few seconds so a stuck init
|
||||
doesn't wedge an MHD worker forever. */
|
||||
{
|
||||
char ready_msg[128];
|
||||
int ready = -1;
|
||||
for (int i = 0; i < 60 && ready != 0; i++) {
|
||||
ready = patchdl_install_backend_check(ready_msg, sizeof ready_msg);
|
||||
if (ready != 0) usleep(250 * 1000);
|
||||
}
|
||||
if (ready != 0) {
|
||||
snprintf(msg, msg_sz,
|
||||
"install backend not ready: %s", ready_msg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Resolve the install API now so we can fail fast before touching disk.
|
||||
The symbol export is Sony-private, so the NID resolver is the more
|
||||
reliable lookup — try NID first, fall back to the by-name dlsym. */
|
||||
ai_install_title = (ai_install_dir_fn)dynsym_by_nid("Wudg3Xe3heE");
|
||||
if (!ai_install_title)
|
||||
ai_install_title = (ai_install_dir_fn)dynsym_by_name(
|
||||
"sceAppInstUtilAppInstallTitleDir");
|
||||
/* Firmware 13.xx no longer exports AppInstallTitleDir. AppInstallAll
|
||||
rescans /user/app and registers the tile directory the same way. */
|
||||
if (!ai_install_title)
|
||||
ai_install_all = (ai_install_all_fn)dynsym_by_name(
|
||||
"sceAppInstUtilAppInstallAll");
|
||||
if (!ai_install_title && !ai_install_all) {
|
||||
snprintf(msg, msg_sz,
|
||||
"neither AppInstallTitleDir nor AppInstallAll resolved");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ai_initialize = (ai_init_fn)dynsym_by_name("sceAppInstUtilInitialize");
|
||||
if (ai_initialize) {
|
||||
rc = ai_initialize();
|
||||
/* SCE_OK == 0; a non-zero rc here usually means "already initialised"
|
||||
in this process, which is fine. We only bail on a clearly fatal
|
||||
code (anything that isn't already the success case). */
|
||||
if (rc != 0 && rc != 0x80B21161 /* ALREADY_INITIALIZED */) {
|
||||
snprintf(msg, msg_sz,
|
||||
"sceAppInstUtilInitialize failed 0x%08x", (unsigned)rc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mkdir(base_dir, 0755) && errno != EEXIST) {
|
||||
snprintf(msg, msg_sz, "mkdir %s failed errno=%d", base_dir, errno);
|
||||
return -1;
|
||||
}
|
||||
if (mkdir(sce_sys_dir, 0755) && errno != EEXIST) {
|
||||
snprintf(msg, msg_sz, "mkdir %s failed errno=%d", sce_sys_dir, errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
unlink(receipt_path);
|
||||
if (write_all(param_path, tile_param_json, tile_param_json_size)) {
|
||||
snprintf(msg, msg_sz, "write param.json failed errno=%d", errno);
|
||||
return -1;
|
||||
}
|
||||
if (write_all(icon_path, tile_icon0_png, tile_icon0_png_size)) {
|
||||
snprintf(msg, msg_sz, "write icon0.png failed errno=%d", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = ai_install_title ? ai_install_title(TILE_TITLE_ID, "/user/app/", NULL)
|
||||
: ai_install_all(NULL);
|
||||
if (rc != 0) {
|
||||
snprintf(msg, msg_sz, "%s(%s) returned 0x%08x",
|
||||
ai_install_title ? "AppInstallTitleDir" : "AppInstallAll",
|
||||
TILE_TITLE_ID, (unsigned)rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)write_all(receipt_path, (const uint8_t *)"1", 1);
|
||||
snprintf(msg, msg_sz, "tile installed (%s via %s)", TILE_TITLE_ID,
|
||||
ai_install_title ? "AppInstallTitleDir" : "AppInstallAll");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Install / refresh the PatchDL home-screen tile.
|
||||
*
|
||||
* Writes param.json + icon0.png into /user/app/<TITLE_ID>/sce_sys/ and asks
|
||||
* the on-console installer to register the directory as an app. The tile's
|
||||
* deeplinkUri opens the on-console browser at http://127.0.0.1:12880/, i.e.
|
||||
* PatchDL's own UI — only useful while the ELF is running.
|
||||
*
|
||||
* No package, no code signing — files only; the installer reads the
|
||||
* directory directly.
|
||||
*
|
||||
* stat-guard: the asset bytes are diffed against the on-disk copy first;
|
||||
* if nothing changed the install call isn't made at all (avoids a costly
|
||||
* re-register every payload start). Returns 0 on success or when nothing
|
||||
* needed doing.
|
||||
*/
|
||||
int patchdl_tile_install_if_needed(char *msg, size_t msg_sz);
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define PATCHDL_VERSION "0.0.1"
|
||||
#define PATCHDL_VERSION "0.1.0"
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#include "patchdl_verxml.h"
|
||||
#include "patchdl_net.h"
|
||||
|
||||
@@ -44,6 +53,11 @@ attr_val(const char *tag_start, const char *tag_end, const char *attr,
|
||||
p += strlen(needle);
|
||||
for (len = 0; p + len < tag_end && p[len] != '"' && len < out_sz - 1; len++)
|
||||
;
|
||||
/* The value must actually end on its closing quote inside the tag —
|
||||
otherwise we hit tag_end or the buffer limit and would return a
|
||||
silently truncated URL/title as if it were valid. */
|
||||
if (p + len >= tag_end || p[len] != '"')
|
||||
return -1;
|
||||
memcpy(out, p, len);
|
||||
out[len] = '\0';
|
||||
return 0;
|
||||
@@ -57,18 +71,24 @@ ver_gt(const char *a, const char *b) {
|
||||
return strcmp(a, b) > 0;
|
||||
}
|
||||
|
||||
/* Extract the first PS4/PS5 title id token ([A-Z]{4}[0-9]{5}, e.g. PPSA03098)
|
||||
from a string such as a delta_url. Used to detect cross-title patches. */
|
||||
/* Extract the first PS4/PS5 title id token ([A-Z]{4}[0-9]{5}, e.g. PPSA03099)
|
||||
from a string such as nptitleid, manifest_url, or delta_url. */
|
||||
static void
|
||||
extract_title_id(const char *s, char *out, size_t sz) {
|
||||
size_t len;
|
||||
out[0] = '\0';
|
||||
if (sz < 10 || !s) return;
|
||||
for (const char *p = s; p[0] && p[8]; p++) {
|
||||
len = strlen(s);
|
||||
if (len < 9) return;
|
||||
/* `len - 9` is the last position where a 9-char id can still fit; this
|
||||
avoids reading p[8] past the NUL terminator. */
|
||||
for (size_t i = 0; i <= len - 9; i++) {
|
||||
const char *p = s + i;
|
||||
int ok = 1;
|
||||
for (int i = 0; i < 4 && ok; i++)
|
||||
if (p[i] < 'A' || p[i] > 'Z') ok = 0;
|
||||
for (int i = 4; i < 9 && ok; i++)
|
||||
if (p[i] < '0' || p[i] > '9') ok = 0;
|
||||
for (int k = 0; k < 4 && ok; k++)
|
||||
if (p[k] < 'A' || p[k] > 'Z') ok = 0;
|
||||
for (int k = 4; k < 9 && ok; k++)
|
||||
if (p[k] < '0' || p[k] > '9') ok = 0;
|
||||
if (ok) {
|
||||
memcpy(out, p, 9);
|
||||
out[9] = '\0';
|
||||
@@ -77,9 +97,31 @@ extract_title_id(const char *s, char *out, size_t sz) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parse_root_title_id(const char *xml, char *out, size_t sz) {
|
||||
const char *p;
|
||||
const char *tag_end;
|
||||
char nptitleid[64] = {0};
|
||||
|
||||
out[0] = '\0';
|
||||
if (!xml || sz < 10) return;
|
||||
|
||||
p = strstr(xml, "<title_patch");
|
||||
if (!p) return;
|
||||
tag_end = strchr(p, '>');
|
||||
if (!tag_end) return;
|
||||
tag_end++;
|
||||
|
||||
if (!attr_val(p, tag_end, "nptitleid", nptitleid, sizeof(nptitleid)))
|
||||
extract_title_id(nptitleid, out, sz);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_packages(const char *xml, uint32_t fw_bin, patchdl_verinfo_t *out) {
|
||||
const char *p = xml;
|
||||
char root_title[16] = {0};
|
||||
|
||||
parse_root_title_id(xml, root_title, sizeof(root_title));
|
||||
|
||||
while ((p = strstr(p, "<package "))) {
|
||||
const char *tag_end = strchr(p, '>');
|
||||
@@ -89,12 +131,14 @@ parse_packages(const char *xml, uint32_t fw_bin, patchdl_verinfo_t *out) {
|
||||
char ver[16] = {0};
|
||||
char sver[16] = {0};
|
||||
char durl[512] = {0};
|
||||
char murl[512] = {0};
|
||||
|
||||
/* PS5 version.xml uses content_ver; PS4 uses version. */
|
||||
if (attr_val(p, tag_end, "content_ver", ver, sizeof(ver)))
|
||||
attr_val(p, tag_end, "version", ver, sizeof(ver));
|
||||
attr_val(p, tag_end, "system_ver", sver, sizeof(sver));
|
||||
attr_val(p, tag_end, "delta_url", durl, sizeof(durl));
|
||||
attr_val(p, tag_end, "manifest_url", murl, sizeof(murl));
|
||||
|
||||
if (ver[0] && sver[0]) {
|
||||
uint32_t pkg_sver = parse_hex(sver);
|
||||
@@ -106,16 +150,33 @@ parse_packages(const char *xml, uint32_t fw_bin, patchdl_verinfo_t *out) {
|
||||
sizeof(out->latest_required_fw));
|
||||
}
|
||||
|
||||
/* Track latest compatible + its patch URL */
|
||||
/* Track latest compatible + its installable patch source. PS5
|
||||
updates expose a small delta_url (DP.pkg) plus a manifest_url
|
||||
containing the actual split package pieces. Feeding the DP
|
||||
bootstrap directly can make the system download the full patch
|
||||
under the storage/master title id, so prefer the target-title
|
||||
manifest whenever present. */
|
||||
if (pkg_sver <= fw_bin) {
|
||||
if (!out->compatible_version[0] ||
|
||||
ver_gt(ver, out->compatible_version)) {
|
||||
strncpy(out->compatible_version, ver,
|
||||
sizeof(out->compatible_version) - 1);
|
||||
strncpy(out->compatible_url, durl,
|
||||
strncpy(out->compatible_url, murl[0] ? murl : durl,
|
||||
sizeof(out->compatible_url) - 1);
|
||||
extract_title_id(durl, out->compatible_title,
|
||||
sizeof(out->compatible_title));
|
||||
if (durl[0])
|
||||
strncpy(out->delta_url, durl, sizeof(out->delta_url) - 1);
|
||||
extract_title_id(durl, out->compatible_storage_title,
|
||||
sizeof(out->compatible_storage_title));
|
||||
if (root_title[0]) {
|
||||
strncpy(out->compatible_title, root_title,
|
||||
sizeof(out->compatible_title) - 1);
|
||||
} else {
|
||||
extract_title_id(murl, out->compatible_title,
|
||||
sizeof(out->compatible_title));
|
||||
if (!out->compatible_title[0])
|
||||
extract_title_id(durl, out->compatible_title,
|
||||
sizeof(out->compatible_title));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,6 +192,10 @@ patchdl_verxml_query(const char *url, uint32_t fw_bin, patchdl_verinfo_t *out) {
|
||||
if (!url || !out) return -1;
|
||||
memset(out, 0, sizeof(*out));
|
||||
|
||||
/* version.xml is a few KB in practice; cap so a misbehaving CDN can't
|
||||
slurp unbounded RAM into the buffer. */
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
buf.max = 4 * 1024 * 1024;
|
||||
if (patchdl_http_get(url, &buf)) return -1;
|
||||
if (!buf.data || !buf.size) { free(buf.data); return -1; }
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -6,8 +15,10 @@ typedef struct {
|
||||
char compatible_version[16]; /* highest pkg with system_ver <= fw_bin, or "" */
|
||||
char latest_version[16]; /* highest pkg overall, or "" */
|
||||
char latest_required_fw[16]; /* fw str for latest pkg, e.g. "11.60", or "" */
|
||||
char compatible_url[512]; /* delta_url of the chosen compatible pkg */
|
||||
char compatible_title[16]; /* title id embedded in that delta_url */
|
||||
char compatible_url[512]; /* manifest_url if present, otherwise pkg URL */
|
||||
char delta_url[512]; /* DP.pkg bootstrap URL (always a PKG, never JSON) */
|
||||
char compatible_title[16]; /* target title id from version.xml/manifest_url */
|
||||
char compatible_storage_title[16]; /* title id embedded in delta_url storage path */
|
||||
} patchdl_verinfo_t;
|
||||
|
||||
int patchdl_verxml_query(const char *url, uint32_t fw_bin, patchdl_verinfo_t *out);
|
||||
@@ -1,3 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright (C) 2026 Knutwurst
|
||||
*
|
||||
* PatchDL is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. See the LICENSE file in the project root for details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
int patchdl_websrv_start(unsigned short port);
|
||||
|
||||
@@ -16,8 +16,14 @@ GET /api/config
|
||||
POST /api/config
|
||||
GET /api/titles
|
||||
GET /api/downloads
|
||||
GET /api/installstatus
|
||||
GET /api/pkgmeta/:title_id
|
||||
GET /api/pkgverify/:title_id
|
||||
POST /api/titles/:title_id/check
|
||||
POST /api/titles/:title_id/download
|
||||
POST /api/titles/:title_id/install
|
||||
POST /api/titles/:title_id/enable
|
||||
POST /api/titles/:title_id/disable
|
||||
```
|
||||
|
||||
## Policy Model
|
||||
@@ -27,14 +33,15 @@ The UI assumes deny-by-default behavior:
|
||||
```json
|
||||
{
|
||||
"default_policy": "deny",
|
||||
"download_dir": "/mnt/usb0/patches",
|
||||
"download_dir": "/data/patchdl (internal)",
|
||||
"install_after_download": false,
|
||||
"delete_pkg_after_install": false,
|
||||
"delete_pkg_after_install": true,
|
||||
"source_policy": {
|
||||
"official": { "allow_check": true, "allow_download": true, "allow_install": true },
|
||||
"external": { "allow_check": true, "allow_download": true, "allow_install": true },
|
||||
"shadowmount": { "allow_check": true, "allow_download": true, "allow_install": false },
|
||||
"unknown": { "allow_check": true, "allow_download": false, "allow_install": false }
|
||||
"shadowmount": { "allow_check": true, "allow_download": false, "allow_install": false },
|
||||
"unknown": { "allow_check": true, "allow_download": false, "allow_install": false },
|
||||
"fake": { "allow_check": true, "allow_download": false, "allow_install": false }
|
||||
},
|
||||
"cdn_allowlist": [
|
||||
"sgst.prod.dl.playstation.net",
|
||||
@@ -64,7 +71,7 @@ Per-title source fields:
|
||||
"source_path": "/system_ex/app/PPSA90001_00",
|
||||
"mount_from": "/mnt/usb0/itemzflow/Shadowmounted Test Title",
|
||||
"enabled": true,
|
||||
"mode": "download_only"
|
||||
"mode": "disabled"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -77,6 +84,17 @@ shadowmount
|
||||
unknown
|
||||
```
|
||||
|
||||
The frontend treats `shadowmount` as download-only and `unknown` as blocked for
|
||||
downloads and installs. Backend code should enforce the same policy even if a
|
||||
client sends a forged request.
|
||||
The frontend lists `shadowmount`, `unknown` and `fake` titles under *Not
|
||||
supported* and offers neither download nor install for them. The backend refuses
|
||||
both as well, even if a client sends a forged request.
|
||||
|
||||
For PS5 game updates, the backend may turn a Sony `manifest_url` into a merged
|
||||
local `.pkg` by downloading all manifest pieces. The `delta_url` `*-DP.pkg` is
|
||||
not shown as a separate user action because it can bootstrap the storage/master
|
||||
title instead of the installed regional target.
|
||||
|
||||
If `patch_storage_match` is false, the CDN stores the patch pieces under another
|
||||
regional (master) title id. That is fine: the merged `.pkg` assembled from the
|
||||
manifest carries the installed title's own content id, and AppInstUtil
|
||||
`AppInstallPkg` installs it onto that title. The UI only adds a "Shared master"
|
||||
label.
|
||||
@@ -2,48 +2,34 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||
<title>PatchDL</title>
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<svg class="icon-sprite" aria-hidden="true">
|
||||
<symbol id="icon-shield" viewBox="0 0 24 24">
|
||||
<path d="M12 3l7 3v5c0 5-3 8-7 10-4-2-7-5-7-10V6l7-3z" />
|
||||
<path d="M9 12l2 2 4-5" />
|
||||
</symbol>
|
||||
<symbol id="icon-download" viewBox="0 0 24 24">
|
||||
<path d="M12 3v11" />
|
||||
<path d="M7 10l5 5 5-5" />
|
||||
<path d="M5 20h14" />
|
||||
<path d="M12 3v11" /><path d="M7 10l5 5 5-5" /><path d="M5 20h14" />
|
||||
</symbol>
|
||||
<symbol id="icon-refresh" viewBox="0 0 24 24">
|
||||
<path d="M20 6v6h-6" />
|
||||
<path d="M4 18v-6h6" />
|
||||
<path d="M19 12A7 7 0 0 0 7 7" />
|
||||
<path d="M5 12a7 7 0 0 0 12 5" />
|
||||
<path d="M20 6v6h-6" /><path d="M4 18v-6h6" />
|
||||
<path d="M19 12A7 7 0 0 0 7 7" /><path d="M5 12a7 7 0 0 0 12 5" />
|
||||
</symbol>
|
||||
<symbol id="icon-settings" viewBox="0 0 24 24">
|
||||
<path d="M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" />
|
||||
<path d="M4 12h2M18 12h2M12 4v2M12 18v2M6.5 6.5 8 8M16 16l1.5 1.5M17.5 6.5 16 8M8 16l-1.5 1.5" />
|
||||
</symbol>
|
||||
<symbol id="icon-search" viewBox="0 0 24 24">
|
||||
<path d="M10.5 18a7.5 7.5 0 1 1 0-15 7.5 7.5 0 0 1 0 15z" />
|
||||
<path d="M16 16l5 5" />
|
||||
<path d="M10.5 18a7.5 7.5 0 1 1 0-15 7.5 7.5 0 0 1 0 15z" /><path d="M16 16l5 5" />
|
||||
</symbol>
|
||||
<symbol id="icon-save" viewBox="0 0 24 24">
|
||||
<path d="M5 4h12l2 2v14H5V4z" />
|
||||
<path d="M8 4v6h8V4" />
|
||||
<path d="M8 20v-6h8v6" />
|
||||
</symbol>
|
||||
<symbol id="icon-pause" viewBox="0 0 24 24">
|
||||
<path d="M8 5v14" />
|
||||
<path d="M16 5v14" />
|
||||
<path d="M5 4h12l2 2v14H5V4z" /><path d="M8 4v6h8V4" /><path d="M8 20v-6h8v6" />
|
||||
</symbol>
|
||||
<symbol id="icon-log" viewBox="0 0 24 24">
|
||||
<path d="M7 4h10l3 3v13H7V4z" />
|
||||
<path d="M17 4v4h4" />
|
||||
<path d="M10 12h7M10 16h5" />
|
||||
<path d="M7 4h10l3 3v13H7V4z" /><path d="M17 4v4h4" /><path d="M10 12h7M10 16h5" />
|
||||
</symbol>
|
||||
<symbol id="icon-grid" viewBox="0 0 24 24">
|
||||
<path d="M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z" />
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
@@ -53,111 +39,125 @@
|
||||
<div class="brand-mark">PD</div>
|
||||
<div>
|
||||
<strong>PatchDL</strong>
|
||||
<span>by Knutwurst · v0.0.1</span>
|
||||
<span>by Knutwurst · <span id="brandVersion">--</span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="nav-list">
|
||||
<a class="nav-link is-active" href="#games">
|
||||
<svg><use href="#icon-download"></use></svg>
|
||||
Games
|
||||
</a>
|
||||
<a class="nav-link" href="#downloads">
|
||||
<svg><use href="#icon-refresh"></use></svg>
|
||||
Queue
|
||||
</a>
|
||||
<a class="nav-link" href="#settings">
|
||||
<svg><use href="#icon-settings"></use></svg>
|
||||
Settings
|
||||
</a>
|
||||
<a class="nav-link" href="#logs">
|
||||
<svg><use href="#icon-log"></use></svg>
|
||||
Logs
|
||||
</a>
|
||||
<nav class="nav-list" aria-label="Sections">
|
||||
<button class="nav-link is-active" data-view="games" aria-label="Games" aria-current="page">
|
||||
<svg><use href="#icon-grid"></use></svg><span>Games</span>
|
||||
</button>
|
||||
<button class="nav-link" data-view="settings" aria-label="Settings">
|
||||
<svg><use href="#icon-settings"></use></svg><span>Settings</span>
|
||||
</button>
|
||||
<button class="nav-link" data-view="logs" aria-label="Logs">
|
||||
<svg><use href="#icon-log"></use></svg><span>Logs</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="rail-foot">
|
||||
<span id="railFw">FW --</span>
|
||||
<span id="railSpace">-- free</span>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="main">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow">Standalone ELF Web UI</p>
|
||||
<h1>Controlled game patch downloads</h1>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<button class="icon-button" id="refreshBtn" title="Refresh status and games">
|
||||
<svg><use href="#icon-refresh"></use></svg>
|
||||
</button>
|
||||
<button class="primary-button" id="saveBtn">
|
||||
<svg><use href="#icon-save"></use></svg>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="status-strip" aria-label="System status">
|
||||
<article class="metric">
|
||||
<span>Firmware</span>
|
||||
<strong id="firmwareValue">--</strong>
|
||||
<em id="firmwareBuild">System version</em>
|
||||
</article>
|
||||
<article class="metric">
|
||||
<span>DNS Guard</span>
|
||||
<strong id="dnsValue">--</strong>
|
||||
<em>Sony blocked by nanoDNS</em>
|
||||
</article>
|
||||
<article class="metric">
|
||||
<span>CDN Access</span>
|
||||
<strong id="resolverValue">--</strong>
|
||||
<em>PatchDL resolver only</em>
|
||||
</article>
|
||||
<article class="metric">
|
||||
<span>Storage</span>
|
||||
<strong id="spaceValue">--</strong>
|
||||
<em id="downloadDirValue">Download target</em>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="toolbar" id="games">
|
||||
<div class="search-box">
|
||||
<svg><use href="#icon-search"></use></svg>
|
||||
<input id="searchInput" type="search" placeholder="Search title, Title ID, or Content ID" />
|
||||
</div>
|
||||
|
||||
<div class="segmented" role="tablist" aria-label="Filter">
|
||||
<button class="is-selected" data-filter="all">All</button>
|
||||
<button data-filter="updatable">Updatable</button>
|
||||
<button data-filter="uptodate">Up to date</button>
|
||||
<button data-filter="needsfw">Needs FW</button>
|
||||
<button data-filter="blocked">Can't update</button>
|
||||
<button data-filter="queued">Queue</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="game-grid" id="gameGrid" aria-live="polite"></section>
|
||||
|
||||
<section class="split-band">
|
||||
<div class="panel" id="downloads">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Downloads</p>
|
||||
<h2>Active Queue</h2>
|
||||
</div>
|
||||
<button class="ghost-button" id="pauseAllBtn">
|
||||
<svg><use href="#icon-pause"></use></svg>
|
||||
Pause
|
||||
<!-- ============ GAMES ============ -->
|
||||
<section class="view is-active" data-view="games">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow">PS5 update manager</p>
|
||||
<h1>Games</h1>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<button class="primary-button" id="updateAllBtn" title="Download (and optionally install) every game that has an available, allowed update">
|
||||
<svg><use href="#icon-download"></use></svg>
|
||||
Update all
|
||||
</button>
|
||||
<button class="icon-button" id="refreshBtn" title="Refresh status and games" aria-label="Refresh">
|
||||
<svg><use href="#icon-refresh"></use></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="queue-list" id="queueList"></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="panel" id="settings">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<p class="eyebrow">Policy</p>
|
||||
<h2>Update Rules</h2>
|
||||
<aside id="globalDl" class="global-dl" hidden aria-live="polite">
|
||||
<div class="global-dl-row">
|
||||
<span class="global-dl-pulse" aria-hidden="true"></span>
|
||||
<div class="global-dl-text">
|
||||
<div class="global-dl-line1">
|
||||
<span class="global-dl-eyebrow" id="globalDlState">Downloading</span>
|
||||
<strong class="global-dl-name" id="globalDlName">—</strong>
|
||||
<span class="global-dl-position" id="globalDlPosition" hidden></span>
|
||||
</div>
|
||||
<div class="global-dl-line2">
|
||||
<span id="globalDlPct">0%</span>
|
||||
<span class="global-dl-sep" aria-hidden="true">·</span>
|
||||
<span id="globalDlSpeed">—</span>
|
||||
<span class="global-dl-sep" aria-hidden="true">·</span>
|
||||
<span id="globalDlEta">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="global-dl-track">
|
||||
<i class="global-dl-bar" id="globalDlBar" style="width:0%"></i>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="status-strip" aria-label="System status">
|
||||
<article class="metric">
|
||||
<span>Firmware</span>
|
||||
<strong id="firmwareValue">--</strong>
|
||||
<em id="firmwareBuild">System version</em>
|
||||
</article>
|
||||
<article class="metric">
|
||||
<span>DNS Guard</span>
|
||||
<strong id="dnsValue">--</strong>
|
||||
<em>System DNS left untouched</em>
|
||||
</article>
|
||||
<article class="metric">
|
||||
<span>CDN Access</span>
|
||||
<strong id="resolverValue">--</strong>
|
||||
<em>PatchDL resolver only</em>
|
||||
</article>
|
||||
<article class="metric">
|
||||
<span>Storage</span>
|
||||
<strong id="spaceValue">--</strong>
|
||||
<em id="downloadDirValue">Download target</em>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="search-box">
|
||||
<svg><use href="#icon-search"></use></svg>
|
||||
<input id="searchInput" type="search" placeholder="Search title, Title ID, or Content ID" />
|
||||
</div>
|
||||
<div class="segmented" role="group" aria-label="Filter">
|
||||
<button class="is-selected" data-filter="updates" aria-pressed="true">Updates <span class="chip-count"></span></button>
|
||||
<button data-filter="uptodate" aria-pressed="false">Up to date <span class="chip-count"></span></button>
|
||||
<button data-filter="blocked" aria-pressed="false">Not supported <span class="chip-count"></span></button>
|
||||
<button data-filter="all" aria-pressed="false">All <span class="chip-count"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="game-grid" id="gameGrid"></section>
|
||||
</section>
|
||||
|
||||
<!-- ============ SETTINGS ============ -->
|
||||
<section class="view" data-view="settings">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow">Policy</p>
|
||||
<h1>Settings</h1>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<button class="primary-button" id="saveBtn">
|
||||
<svg><use href="#icon-save"></use></svg>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="panel">
|
||||
<div class="settings-grid">
|
||||
<label class="field">
|
||||
<span>Default Policy</span>
|
||||
@@ -168,22 +168,61 @@
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Download Folder</span>
|
||||
<input id="downloadDir" type="text" spellcheck="false" />
|
||||
<input id="downloadDir" type="text" spellcheck="false" readonly
|
||||
title="Patches always download to the console's internal storage" />
|
||||
</label>
|
||||
|
||||
<label class="switch-row">
|
||||
<input id="installAfterDownload" type="checkbox" />
|
||||
<span>
|
||||
<strong>Install after download</strong>
|
||||
<em>Global default, overridable per game</em>
|
||||
</span>
|
||||
<span class="toggle">
|
||||
<input id="installAfterDownload" type="checkbox" aria-label="Install after download" />
|
||||
<span class="track"></span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="switch-row">
|
||||
<input id="deleteAfterInstall" type="checkbox" />
|
||||
<span>
|
||||
<strong>Delete PKG after install</strong>
|
||||
<em>Only after a successful install</em>
|
||||
</span>
|
||||
<span class="toggle">
|
||||
<input id="deleteAfterInstall" type="checkbox" aria-label="Delete package after install" />
|
||||
<span class="track"></span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="switch-row">
|
||||
<span>
|
||||
<strong>Verify downloaded pieces (SHA-256)</strong>
|
||||
<em>Checks each manifest piece; off by default, verify on-device first</em>
|
||||
</span>
|
||||
<span class="toggle">
|
||||
<input id="verifyDownloads" type="checkbox" aria-label="Verify downloaded pieces" />
|
||||
<span class="track"></span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="switch-row">
|
||||
<span>
|
||||
<strong>Home-screen shortcut</strong>
|
||||
<em id="shortcutHint">Add a PS5 home-screen icon that opens this UI in the browser</em>
|
||||
</span>
|
||||
<span class="toggle">
|
||||
<input id="homeShortcut" type="checkbox" aria-label="Install home-screen shortcut" />
|
||||
<span class="track"></span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="switch-row">
|
||||
<span>
|
||||
<strong>Parallel download connections</strong>
|
||||
<em>1–16 · applies live, no payload restart</em>
|
||||
</span>
|
||||
<div class="stepper" role="group" aria-label="Parallel download connections">
|
||||
<button type="button" class="stepper-btn" id="connMinus" aria-label="Fewer connections">−</button>
|
||||
<output class="stepper-value" id="connValue" aria-live="polite">4</output>
|
||||
<button type="button" class="stepper-btn" id="connPlus" aria-label="More connections">+</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="allowlist">
|
||||
@@ -195,16 +234,27 @@
|
||||
<span>Install Protection</span>
|
||||
<div id="sourcePolicyList"></div>
|
||||
</div>
|
||||
|
||||
<div class="storage-list">
|
||||
<span>Downloads on console <em id="storageTotal"></em></span>
|
||||
<div id="storageList"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="log-panel" id="logs">
|
||||
<div class="panel-heading">
|
||||
<!-- ============ LOGS ============ -->
|
||||
<section class="view" data-view="logs">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow">Runtime</p>
|
||||
<h2>Recent Events</h2>
|
||||
<h1>Logs</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<button class="icon-button" id="clearLogBtn" title="Clear log" aria-label="Clear log">
|
||||
<svg><use href="#icon-log"></use></svg>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<pre id="logOutput" tabindex="0"></pre>
|
||||
</section>
|
||||
</main>
|
||||
|
||||