Release fwupd 1.8.2

-----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEEFj61ARkiXbPfj0nqF6y6jfqXDhcFAmLMCgIUHHJpY2hhcmRA
 aHVnaHNpZS5jb20ACgkQF6y6jfqXDheaiwgApGQwq9pzhjyg+Vgd9B37o7V3qoHS
 TfSy4ZC7c+9bCNmFs35pV1TPVuNBtFi9VvV3F2QzcNV423lhzZM5nI0PNGNaE2uS
 eHA7T1oIqL32Ig/m89FFkHu4kk3Uq0SMCJcDYbC3wjEFrh0afN/F2FZgZ6l7bzDW
 w62Cf/iQMvg5OT30Clb4RRAayrKlR0uioAUD06nkGN+sh2py2FU6c76JywW8TVMW
 HfJd4UpFkMfNZAKuOmRNx7gYGk6BpRST2hPC+5JTo0Rul/6gsd0541CFYD9TwA6T
 7iBjM0NkJtXMJoE773wpKzh51sQz6C125gyn5DZUkhoS6bytd/TgrMALGA==
 =EBuB
 -----END PGP SIGNATURE-----

Merge tag '1.8.2' into debian

Release fwupd 1.8.2
This commit is contained in:
Mario Limonciello 2022-07-11 13:36:13 -05:00
commit cee7155af0
732 changed files with 29636 additions and 15974 deletions

View File

@ -2,7 +2,7 @@ version: 2
jobs: jobs:
build-ubuntu-x86_64: build-ubuntu-x86_64:
machine: machine:
image: circleci/classic:latest image: ubuntu-2204:edge
steps: steps:
- checkout - checkout
- run: - run:
@ -60,7 +60,7 @@ jobs:
publish-docs: publish-docs:
machine: machine:
image: circleci/classic:latest image: ubuntu-2204:edge
steps: steps:
- attach_workspace: - attach_workspace:
at: . at: .

6
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View File

@ -9,7 +9,7 @@ on:
jobs: jobs:
analyze: analyze:
name: Analyze name: Analyze
runs-on: ubuntu-latest runs-on: ubuntu-20.04
permissions: permissions:
actions: read actions: read
contents: read contents: read
@ -39,7 +39,7 @@ jobs:
run: | run: |
mkdir -p $GITHUB_WORKSPACE/build mkdir -p $GITHUB_WORKSPACE/build
cd $GITHUB_WORKSPACE/build cd $GITHUB_WORKSPACE/build
meson .. -Dman=false -Ddocs=none -Defi_binary=false -Dplugin_uefi_capsule_splash=false --prefix=$GITHUB_WORKSPACE/dist meson .. -Dman=false -Defi_binary=false -Dplugin_uefi_capsule_splash=false --prefix=$GITHUB_WORKSPACE/dist
ninja ninja
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis

View File

@ -19,11 +19,18 @@ jobs:
env: env:
OS: ${{ matrix.os }} OS: ${{ matrix.os }}
run: ./contrib/ci/generate_docker.py run: ./contrib/ci/generate_docker.py
- name: Push to GitHub Packages -
uses: docker/build-push-action@v1 name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with: with:
registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com - name: Push to GitHub Packages
repository: fwupd/fwupd/fwupd-${{matrix.os}} uses: docker/build-push-action@v3
tags: latest with:
context: .
push: true
tags: ghcr.io/fwupd/fwupd/fwupd-${{matrix.os}}:latest

View File

@ -13,10 +13,10 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Find tag - name: Find tag
id: tagger id: tagger
uses: jimschubert/query-tag-action@v1 uses: jimschubert/query-tag-action@v2
- name: Build - name: Build
id: test id: test
uses: vmactions/freebsd-vm@v0.1.5 uses: vmactions/freebsd-vm@v0.1.6
with: with:
usesh: true usesh: true
mem: 8192 mem: 8192
@ -32,7 +32,7 @@ jobs:
--GITHUB_REPOSITORY=${GITHUB_REPOSITORY} --GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
--GITHUB_TAG=${{steps.tagger.outputs.tag}} --GITHUB_TAG=${{steps.tagger.outputs.tag}}
- name: Upload fwupd binary artifact - name: Upload fwupd binary artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: Binary package name: Binary package
path: | path: |

View File

@ -102,7 +102,7 @@ jobs:
fuzz-seconds: 300 fuzz-seconds: 300
dry-run: false dry-run: false
- name: Upload Crash - name: Upload Crash
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success' if: failure() && steps.build.outcome == 'success'
with: with:
name: artifacts name: artifacts

View File

@ -41,6 +41,10 @@ repos:
name: check for null / false return mistmatch name: check for null / false return mistmatch
language: script language: script
entry: ./contrib/ci/check-null-false-returns.py entry: ./contrib/ci/check-null-false-returns.py
- id: check-finalizers
name: check for missing GObject parent finalize
language: script
entry: ./contrib/ci/check-finalizers.py
- id: check-headers - id: check-headers
name: check for superfluous includes name: check for superfluous includes
language: script language: script

View File

@ -10,7 +10,7 @@ To make sure it's done right, you can reference commit 433e809318c68c9ab6d4ae50e
Write release entries: Write release entries:
git log --format="%s" --cherry-pick --right-only 1.8.0... | grep -i -v trivial | grep -v Merge | sort | uniq git log --format="%s" --cherry-pick --right-only 1.8.1... | grep -i -v trivial | grep -v Merge | sort | uniq
Add any user visible changes into ../data/org.freedesktop.fwupd.metainfo.xml Add any user visible changes into ../data/org.freedesktop.fwupd.metainfo.xml
appstream-util appdata-to-news ../data/org.freedesktop.fwupd.metainfo.xml > NEWS appstream-util appdata-to-news ../data/org.freedesktop.fwupd.metainfo.xml > NEWS
@ -25,7 +25,7 @@ git add ../po/*.po
2. Commit changes to git: 2. Commit changes to git:
# MAKE SURE THIS IS CORRECT # MAKE SURE THIS IS CORRECT
export release_ver="1.8.1" export release_ver="1.8.2"
git commit -a -m "Release fwupd ${release_ver}" --no-verify git commit -a -m "Release fwupd ${release_ver}" --no-verify
git tag -s -f -m "Release fwupd ${release_ver}" "${release_ver}" git tag -s -f -m "Release fwupd ${release_ver}" "${release_ver}"

View File

@ -9,7 +9,7 @@ arch=('i686' 'x86_64')
url='https://github.com/fwupd/fwupd' url='https://github.com/fwupd/fwupd'
license=('GPL2') license=('GPL2')
depends=('libgusb' 'modemmanager' 'tpm2-tss') depends=('libgusb' 'modemmanager' 'tpm2-tss')
makedepends=('meson' 'valgrind' 'gobject-introspection' 'gtk-doc' 'git' makedepends=('meson' 'valgrind' 'gobject-introspection' 'gi-docgen' 'git'
'python-cairo' 'noto-fonts' 'noto-fonts-cjk' 'python-gobject' 'vala' 'python-cairo' 'noto-fonts' 'noto-fonts-cjk' 'python-gobject' 'vala'
'curl' 'polkit' 'gcab' 'xz') 'curl' 'polkit' 'gcab' 'xz')
@ -30,7 +30,8 @@ build() {
arch-meson -D b_lto=false $CI ../build \ arch-meson -D b_lto=false $CI ../build \
-Dplugin_intel_spi=true \ -Dplugin_intel_spi=true \
-Dplugin_powerd=disabled \ -Dplugin_powerd=disabled \
-Ddocs=gtkdoc \ -Dgresource_quirks=disabled \
-Ddocs=enabled \
-Defi_binary=false \ -Defi_binary=false \
-Dsupported_build=enabled -Dsupported_build=enabled

View File

@ -4,7 +4,6 @@ meson ../ \
-Dauto_features=disabled \ -Dauto_features=disabled \
-Dbash_completion=false \ -Dbash_completion=false \
-Dcompat_cli=false \ -Dcompat_cli=false \
-Ddocs=none \
-Dfish_completion=false \ -Dfish_completion=false \
-Dfirmware-packager=false \ -Dfirmware-packager=false \
-Dhsi=false \ -Dhsi=false \

View File

@ -20,7 +20,6 @@ meson .. \
--libexecdir="bin" \ --libexecdir="bin" \
--bindir="bin" \ --bindir="bin" \
-Dbuild=all \ -Dbuild=all \
-Ddocs=none \
-Dhsi=false \ -Dhsi=false \
-Dman=false \ -Dman=false \
-Dfish_completion=false \ -Dfish_completion=false \

View File

@ -4,6 +4,9 @@ ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8 ENV LC_ALL en_US.UTF-8
ENV CI_NETWORK true ENV CI_NETWORK true
RUN echo fubar > /etc/machine-id RUN echo fubar > /etc/machine-id
RUN sed "s,#en_US.UTF-8,en_US.UTF-8," /etc/locale.gen -i
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
RUN locale-gen
RUN pacman -Syu --noconfirm archlinux-keyring RUN pacman -Syu --noconfirm archlinux-keyring
%%%INSTALL_DEPENDENCIES_COMMAND%%% %%%INSTALL_DEPENDENCIES_COMMAND%%%
WORKDIR /github/workspace WORKDIR /github/workspace

View File

@ -2,8 +2,9 @@ FROM ubuntu:rolling
%%%OS%%% %%%OS%%%
ENV CI_NETWORK true ENV CI_NETWORK true
ENV CC clang ENV CC clang
ENV DEBIAN_FRONTEND noninteractive
RUN echo fubar > /etc/machine-id RUN echo fubar > /etc/machine-id
%%%ARCH_SPECIFIC_COMMAND%%% %%%ARCH_SPECIFIC_COMMAND%%%
%%%INSTALL_DEPENDENCIES_COMMAND%%% RUN apt update -qq && apt install -yq --no-install-recommends python3-apt
WORKDIR /github/workspace WORKDIR /github/workspace
CMD ["./contrib/ci/ubuntu.sh"] CMD ["./contrib/ci/ubuntu.sh"]

View File

@ -5,7 +5,6 @@ set -x
mkdir -p build-macos && cd build-macos mkdir -p build-macos && cd build-macos
meson .. \ meson .. \
-Dbuild=standalone \ -Dbuild=standalone \
-Ddocs=none \
-Dhsi=false \ -Dhsi=false \
-Dsoup_session_compat=false \ -Dsoup_session_compat=false \
-Dgusb:docs=false \ -Dgusb:docs=false \

View File

@ -10,11 +10,10 @@ fi
# install deps # install deps
./contrib/ci/fwupd_setup_helpers.py --yes -o fedora -v mingw64 install-dependencies ./contrib/ci/fwupd_setup_helpers.py --yes -o fedora -v mingw64 install-dependencies
# update things that are not yet in Fedora updates-testing # update to latest version of meson
if [ "$(id -u)" -eq 0 ]; then if [ "$(id -u)" -eq 0 ]; then
dnf install -y \ dnf install -y python-pip
https://kojipkgs.fedoraproject.org//packages/msitools/0.101.32/5.fc36/x86_64/msitools-0.101.32-5.fc36.x86_64.rpm \ pip install meson --force-reinstall
https://kojipkgs.fedoraproject.org//packages/msitools/0.101.32/5.fc36/x86_64/libmsi1-0.101.32-5.fc36.x86_64.rpm
fi fi
#prep #prep
@ -42,7 +41,6 @@ meson .. \
--libexecdir="bin" \ --libexecdir="bin" \
--bindir="bin" \ --bindir="bin" \
-Dbuild=all \ -Dbuild=all \
-Ddocs=none \
-Dhsi=false \ -Dhsi=false \
-Dman=false \ -Dman=false \
-Dfish_completion=false \ -Dfish_completion=false \
@ -162,10 +160,10 @@ wixl -v \
-o "${MSI_FILENAME}" -o "${MSI_FILENAME}"
# check the msi archive can be installed and removed (use "wine uninstaller" to do manually) # check the msi archive can be installed and removed (use "wine uninstaller" to do manually)
wine msiexec /i "${MSI_FILENAME}" # wine msiexec /i "${MSI_FILENAME}"
ls -R ~/.wine/drive_c/Program\ Files/fwupd/ # ls -R ~/.wine/drive_c/Program\ Files/fwupd/
wine ~/.wine/drive_c/Program\ Files/fwupd/bin/fwupdtool get-plugins --json # wine ~/.wine/drive_c/Program\ Files/fwupd/bin/fwupdtool get-plugins --json
wine msiexec /x "${MSI_FILENAME}" # wine msiexec /x "${MSI_FILENAME}"
#generate news release #generate news release
contrib/ci/generate_news.py $VERSION > $DESTDIR/news.txt contrib/ci/generate_news.py $VERSION > $DESTDIR/news.txt

View File

@ -17,7 +17,6 @@ meson .. \
-Dplugin_synaptics_mst=enabled \ -Dplugin_synaptics_mst=enabled \
-Dplugin_flashrom=enabled \ -Dplugin_flashrom=enabled \
-Dintrospection=true \ -Dintrospection=true \
-Ddocs=gtkdoc \
-Dpkcs7=false \ -Dpkcs7=false \
-Dman=true -Dman=true
ninja-build -v ninja-build -v

View File

@ -87,8 +87,8 @@ def build_install(revision):
"--prefix=/usr", "--prefix=/usr",
"--libdir=lib", "--libdir=lib",
"-Dauto_features=disabled", "-Dauto_features=disabled",
"-Db_coverage=false",
"-Ddocs=none", "-Ddocs=none",
"-Db_coverage=false",
"-Dgusb:docs=false", "-Dgusb:docs=false",
"-Dtests=false", "-Dtests=false",
] ]

63
contrib/ci/check-finalizers.py Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/python3
# pylint: disable=invalid-name,missing-docstring,consider-using-f-string
# pylint: disable=too-few-public-methods
#
# Copyright (C) 2022 Richard Hughes <richard@hughsie.com>
#
# SPDX-License-Identifier: LGPL-2.1+
import glob
import sys
from typing import List
class ReturnValidator:
def __init__(self):
self.warnings: List[str] = []
def parse(self, fn: str) -> None:
with open(fn, "rb") as f:
infunc = False
has_parent_finalize = False
for line in f.read().decode().split("\n"):
# found the function, but ignore the prototype
if line.find("_finalize(") != -1:
if line.endswith(";"):
continue
infunc = True
continue
# got it
if line.find("->finalize(") != -1:
has_parent_finalize = True
continue
# finalize is done
if infunc and line.startswith("}"):
if not has_parent_finalize:
self.warnings.append(
"{} did not have parent ->finalize()".format(fn)
)
break
def test_files():
# test all C source files
validator = ReturnValidator()
for fn in glob.glob("**/*.c", recursive=True):
if fn.startswith("dist/") or fn.startswith("subprojects/"):
continue
validator.parse(fn)
for warning in validator.warnings:
print(warning)
return 1 if validator.warnings else 0
if __name__ == "__main__":
# all done!
sys.exit(test_files())

View File

@ -32,17 +32,37 @@ def test_files() -> int:
rc: int = 0 rc: int = 0
lib_headers1 = glob.glob("libfwupd/*.h")
lib_headers1.remove("libfwupd/fwupd.h")
lib_headers2 = glob.glob("libfwupdplugin/*.h")
lib_headers2.remove("libfwupdplugin/fwupdplugin.h")
toplevel_headers = ["libfwupd/fwupd.h", "libfwupdplugin/fwupdplugin.h"] toplevel_headers = ["libfwupd/fwupd.h", "libfwupdplugin/fwupdplugin.h"]
toplevel_headers_nopath = [os.path.basename(fn) for fn in toplevel_headers] toplevel_headers_nopath = [os.path.basename(fn) for fn in toplevel_headers]
lib_headers = glob.glob("libfwupd*/*.h") lib_headers = lib_headers1 + lib_headers2
lib_headers.remove("libfwupd/fwupd.h")
lib_headers.remove("libfwupdplugin/fwupdplugin.h")
lib_headers_nopath = [os.path.basename(fn) for fn in lib_headers] lib_headers_nopath = [os.path.basename(fn) for fn in lib_headers]
# test all C and H files # test all C and H files
for fn in glob.glob("**/*.[c|h]", recursive=True): for fn in glob.glob("**/*.[c|h]", recursive=True):
includes = __get_includes(fn) includes = __get_includes(fn)
# we do not care
if fn.startswith("subprojects"):
continue
if fn.startswith("build"):
continue
if fn.startswith("dist"):
continue
if fn.startswith("contrib/ci"):
continue
if fn in [
"libfwupd/fwupd-context-test.c",
"libfwupd/fwupd-thread-test.c",
"libfwupdplugin/fu-fuzzer-main.c",
]:
continue
if ( if (
fn.startswith("plugins") fn.startswith("plugins")
and not fn.endswith("self-test.c") and not fn.endswith("self-test.c")
@ -93,6 +113,35 @@ def test_files() -> int:
) )
rc = 1 rc = 1
# check for missing config.h
if fn.endswith(".c") and "config.h" not in includes:
print("{} does not include config.h".format(fn))
rc = 1
# check for one header implying the other
implied_headers = {
"fu-common.h": ["xmlb.h"],
"fwupdplugin.h": [
"gio/gio.h",
"glib.h",
"glib-object.h",
"xmlb.h",
"fwupd.h",
]
+ lib_headers1,
"gio/gio.h": ["glib.h", "glib-object.h"],
"glib-object.h": ["glib.h"],
"json-glib/json-glib.h": ["glib.h", "glib-object.h"],
"xmlb.h": ["gio/gio.h"],
}
for key, values in implied_headers.items():
for value in values:
if key in includes and value in includes:
print(
"{} contains {} which is implied by {}".format(fn, value, key)
)
rc = 1
return rc return rc

View File

@ -34,6 +34,7 @@ sed s/quilt/native/ debian/source/format -i
#check if we have all deps available #check if we have all deps available
#if some are missing, we're going to use subproject instead and #if some are missing, we're going to use subproject instead and
#packaging CI will fail #packaging CI will fail
apt update -qq && apt install python3-apt -y
./contrib/ci/fwupd_setup_helpers.py install-dependencies -o debian --yes || true ./contrib/ci/fwupd_setup_helpers.py install-dependencies -o debian --yes || true
if ! dpkg-checkbuilddeps; then if ! dpkg-checkbuilddeps; then
./contrib/ci/ubuntu.sh ./contrib/ci/ubuntu.sh

View File

@ -25,7 +25,6 @@ meson .. \
-Dplugin_mtd=false \ -Dplugin_mtd=false \
-Dplugin_powerd=disabled \ -Dplugin_powerd=disabled \
-Dintrospection=false \ -Dintrospection=false \
-Ddocs=none \
-Dlibxmlb:introspection=false \ -Dlibxmlb:introspection=false \
-Dlibxmlb:gtkdoc=false \ -Dlibxmlb:gtkdoc=false \
-Dman=false -Dman=false

View File

@ -23,6 +23,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="ubuntu"> <distro id="ubuntu">
<package variant="x86_64" /> <package variant="x86_64" />
@ -36,6 +37,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="ubuntu"> <distro id="ubuntu">
<package variant="x86_64" /> <package variant="x86_64" />
@ -63,6 +65,7 @@
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="mingw64" /> <package variant="mingw64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
<package variant="x86_64" /> <package variant="x86_64" />
@ -112,6 +115,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">cairo-devel</package> <package variant="x86_64">cairo-devel</package>
<package variant="aarch64">cairo-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">cairo-devel</package> <package variant="x86_64">cairo-devel</package>
@ -133,6 +137,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">cairo-gobject-devel</package> <package variant="x86_64">cairo-gobject-devel</package>
<package variant="aarch64">cairo-gobject-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -154,6 +159,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">json-glib-devel</package> <package variant="x86_64">json-glib-devel</package>
<package variant="aarch64">json-glib-devel</package>
<package variant="mingw64">mingw64-json-glib</package> <package variant="mingw64">mingw64-json-glib</package>
</distro> </distro>
<distro id="void"> <distro id="void">
@ -183,6 +189,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libftdi-devel</package> <package variant="x86_64">libftdi-devel</package>
<package variant="aarch64">libftdi-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<package variant="x86_64" /> <package variant="x86_64" />
@ -201,6 +208,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">pciutils-devel</package> <package variant="x86_64">pciutils-devel</package>
<package variant="aarch64">pciutils-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -221,6 +229,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">google-noto-sans-cjk-ttc-fonts</package> <package variant="x86_64">google-noto-sans-cjk-ttc-fonts</package>
<package variant="aarch64">google-noto-sans-cjk-ttc-fonts</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">noto-fonts-cjk</package> <package variant="x86_64">noto-fonts-cjk</package>
@ -265,6 +274,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
<package variant="x86_64" /> <package variant="x86_64" />
@ -280,6 +290,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="dh-strip-nondeterminism"> <dependency type="build" id="dh-strip-nondeterminism">
@ -313,6 +324,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">freetype</package> <package variant="x86_64">freetype</package>
<package variant="aarch64">freetype</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -331,6 +343,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -345,6 +358,7 @@
<dependency type="build" id="libflashrom-dev"> <dependency type="build" id="libflashrom-dev">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">flashrom-devel</package> <package variant="x86_64">flashrom-devel</package>
<package variant="aarch64">flashrom-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control> <control>
@ -366,6 +380,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
<!-- need native until meson includes https://github.com/mesonbuild/meson/pull/10291 --> <!-- need native until meson includes https://github.com/mesonbuild/meson/pull/10291 -->
<package variant="mingw64">gcab</package> <package variant="mingw64">gcab</package>
</distro> </distro>
@ -389,6 +404,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
<!-- need native too until meson fixes https://github.com/mesonbuild/meson/issues/10376 --> <!-- need native too until meson fixes https://github.com/mesonbuild/meson/issues/10376 -->
<package variant="mingw64">gettext</package> <package variant="mingw64">gettext</package>
<package variant="mingw64">mingw64-gettext</package> <package variant="mingw64">mingw64-gettext</package>
@ -417,6 +433,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="gnu-efi-devel"> <dependency type="build" id="gnu-efi-devel">
@ -428,6 +445,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">gnu-efi-libs</package> <package variant="x86_64">gnu-efi-libs</package>
@ -462,6 +480,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
<package variant="mingw64" /> <package variant="mingw64" />
</distro> </distro>
<distro id="void"> <distro id="void">
@ -491,6 +510,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">glib2-devel</package> <package variant="x86_64">glib2-devel</package>
<package variant="aarch64">glib2-devel</package>
<!-- need native too until meson fixes https://github.com/mesonbuild/meson/issues/10376 --> <!-- need native too until meson fixes https://github.com/mesonbuild/meson/issues/10376 -->
<package variant="mingw64">glib2-devel</package> <package variant="mingw64">glib2-devel</package>
<package variant="mingw64">mingw64-glib2</package> <package variant="mingw64">mingw64-glib2</package>
@ -516,6 +536,7 @@
<dependency type="build" id="glibc-langpack-en"> <dependency type="build" id="glibc-langpack-en">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">glibc-langpack-en</package> <package variant="x86_64">glibc-langpack-en</package>
<package variant="aarch64">glibc-langpack-en</package>
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="gobject-introspection"> <dependency type="build" id="gobject-introspection">
@ -527,6 +548,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">gobject-introspection-devel</package> <package variant="x86_64">gobject-introspection-devel</package>
<package variant="aarch64">gobject-introspection-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64" /> <package variant="x86_64" />
@ -559,6 +581,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">gnutls-devel</package> <package variant="x86_64">gnutls-devel</package>
<package variant="aarch64">gnutls-devel</package>
<package variant="mingw64">mingw64-gnutls</package> <package variant="mingw64">mingw64-gnutls</package>
</distro> </distro>
<distro id="void"> <distro id="void">
@ -581,6 +604,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">gnutls-utils</package> <package variant="x86_64">gnutls-utils</package>
<package variant="aarch64">gnutls-utils</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">gnutls-tools</package> <package variant="x86_64">gnutls-tools</package>
@ -596,33 +620,13 @@
<package variant="x86_64" /> <package variant="x86_64" />
</distro> </distro>
</dependency> </dependency>
<!-- TODO: Drop build dependency after switching to gidoc-gen -->
<dependency type="build" id="gtk-doc-tools">
<distro id="arch">
<package variant="x86_64">gtk-doc</package>
</distro>
<distro id="centos">
<package variant="x86_64">gtk-doc</package>
</distro>
<distro id="fedora">
<package variant="x86_64">gtk-doc</package>
</distro>
<distro id="debian">
<control />
<package variant="x86_64" />
<package variant="i386" />
</distro>
<distro id="ubuntu">
<control />
<package variant="x86_64" />
</distro>
</dependency>
<dependency type="build" id="jq"> <dependency type="build" id="jq">
<distro id="centos"> <distro id="centos">
<package variant="x86_64" /> <package variant="x86_64" />
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
<package variant="mingw64" /> <package variant="mingw64" />
</distro> </distro>
<distro id="ubuntu"> <distro id="ubuntu">
@ -641,6 +645,7 @@
--> -->
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libxmlb-devel</package> <package variant="x86_64">libxmlb-devel</package>
<package variant="aarch64">libxmlb-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">libxmlb-devel</package> <package variant="x86_64">libxmlb-devel</package>
@ -663,6 +668,7 @@
<dependency type="build" id="libjcat-dev"> <dependency type="build" id="libjcat-dev">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libjcat-devel</package> <package variant="x86_64">libjcat-devel</package>
<package variant="aarch64">libjcat-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -681,6 +687,7 @@
<dependency type="build" id="liblzma-dev"> <dependency type="build" id="liblzma-dev">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">xz-devel</package> <package variant="x86_64">xz-devel</package>
<package variant="aarch64">xz-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -699,6 +706,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libarchive-devel</package> <package variant="x86_64">libarchive-devel</package>
<package variant="aarch64">libarchive-devel</package>
<package variant="mingw64">mingw64-libarchive</package> <package variant="mingw64">mingw64-libarchive</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
@ -724,6 +732,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libcbor-devel</package> <package variant="x86_64">libcbor-devel</package>
<package variant="aarch64">libcbor-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -748,6 +757,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">efivar-devel</package> <package variant="x86_64">efivar-devel</package>
<package variant="aarch64">efivar-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">libefivar-devel</package> <package variant="x86_64">libefivar-devel</package>
@ -802,6 +812,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libgcab1-devel</package> <package variant="x86_64">libgcab1-devel</package>
<package variant="aarch64">libgcab1-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -835,6 +846,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libgudev1-devel</package> <package variant="x86_64">libgudev1-devel</package>
<package variant="aarch64">libgudev1-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -856,6 +868,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libgusb-devel</package> <package variant="x86_64">libgusb-devel</package>
<package variant="aarch64">libgusb-devel</package>
<package variant="mingw64">mingw64-libgusb</package> <package variant="mingw64">mingw64-libgusb</package>
</distro> </distro>
<distro id="void"> <distro id="void">
@ -935,6 +948,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libcurl-devel</package> <package variant="x86_64">libcurl-devel</package>
<package variant="aarch64">libcurl-devel</package>
<package variant="mingw64">mingw64-curl</package> <package variant="mingw64">mingw64-curl</package>
</distro> </distro>
<distro id="void"> <distro id="void">
@ -1011,6 +1025,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
<package variant="mingw64" /> <package variant="mingw64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
@ -1057,6 +1072,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">pango-devel</package> <package variant="x86_64">pango-devel</package>
<package variant="aarch64">pango-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">pango-devel</package> <package variant="x86_64">pango-devel</package>
@ -1097,6 +1113,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">polkit</package> <package variant="x86_64">polkit</package>
<package variant="aarch64">polkit</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">polkit</package> <package variant="x86_64">polkit</package>
@ -1122,6 +1139,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">ModemManager-glib-devel</package> <package variant="x86_64">ModemManager-glib-devel</package>
<package variant="aarch64">ModemManager-glib-devel</package>
</distro> </distro>
<distro id="arch"> <distro id="arch">
<package variant="x86_64">modemmanager</package> <package variant="x86_64">modemmanager</package>
@ -1143,6 +1161,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libqmi-devel</package> <package variant="x86_64">libqmi-devel</package>
<package variant="aarch64">libqmi-devel</package>
</distro> </distro>
<distro id="arch"> <distro id="arch">
<package variant="x86_64">libqmi</package> <package variant="x86_64">libqmi</package>
@ -1164,6 +1183,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">libmbim-devel</package> <package variant="x86_64">libmbim-devel</package>
<package variant="aarch64">libmbim-devel</package>
</distro> </distro>
<distro id="arch"> <distro id="arch">
<package variant="x86_64">libmbim</package> <package variant="x86_64">libmbim</package>
@ -1193,6 +1213,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">polkit-devel</package> <package variant="x86_64">polkit-devel</package>
<package variant="aarch64">polkit-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">polkit-devel</package> <package variant="x86_64">polkit-devel</package>
@ -1219,6 +1240,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64" /> <package variant="x86_64" />
@ -1230,6 +1252,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">python3-cairo</package> <package variant="x86_64">python3-cairo</package>
<package variant="aarch64">python3-cairo</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -1248,6 +1271,22 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro>
<distro id="arch">
<package variant="x86_64" />
</distro>
<distro id="centos">
<package variant="x86_64" />
</distro>
<distro id="debian">
<control />
<package variant="x86_64" />
<package variant="i386" />
</distro>
<distro id="ubuntu">
<control />
<package variant="x86_64" />
</distro> </distro>
</dependency> </dependency>
<!-- These are needed for gi-docgen --> <!-- These are needed for gi-docgen -->
@ -1268,6 +1307,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="python3-toml"> <dependency type="build" id="python3-toml">
@ -1278,6 +1318,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="ubuntu"> <distro id="ubuntu">
<package variant="x86_64" /> <package variant="x86_64" />
@ -1286,6 +1327,7 @@
<dependency type="build" id="python3-markdown"> <dependency type="build" id="python3-markdown">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="ubuntu"> <distro id="ubuntu">
<package variant="x86_64" /> <package variant="x86_64" />
@ -1299,6 +1341,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="ubuntu"> <distro id="ubuntu">
<package variant="x86_64" /> <package variant="x86_64" />
@ -1310,6 +1353,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64" /> <package variant="x86_64" />
@ -1318,6 +1362,7 @@
<dependency type="build" id="python3-requests"> <dependency type="build" id="python3-requests">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -1340,6 +1385,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="redhat-rpm-config"> <dependency type="build" id="redhat-rpm-config">
@ -1348,6 +1394,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="libsqlite3-dev"> <dependency type="build" id="libsqlite3-dev">
@ -1356,6 +1403,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">sqlite-devel</package> <package variant="x86_64">sqlite-devel</package>
<package variant="aarch64">sqlite-devel</package>
<package variant="mingw64">mingw64-sqlite</package> <package variant="mingw64">mingw64-sqlite</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
@ -1383,6 +1431,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control> <control>
@ -1405,6 +1454,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">systemd-devel</package> <package variant="x86_64">systemd-devel</package>
<package variant="aarch64">systemd-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -1426,6 +1476,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -1468,6 +1519,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">umockdev-devel</package> <package variant="x86_64">umockdev-devel</package>
<package variant="aarch64">umockdev-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -1488,6 +1540,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">vala</package> <package variant="x86_64">vala</package>
<package variant="aarch64">vala</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">vala</package> <package variant="x86_64">vala</package>
@ -1512,6 +1565,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">valgrind-devel</package> <package variant="x86_64">valgrind-devel</package>
<package variant="aarch64">valgrind-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control> <control>
@ -1566,6 +1620,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="libtss2-dev"> <dependency type="build" id="libtss2-dev">
@ -1577,6 +1632,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">tpm2-tss-devel</package> <package variant="x86_64">tpm2-tss-devel</package>
<package variant="aarch64">tpm2-tss-devel</package>
</distro> </distro>
<distro id="debian"> <distro id="debian">
<control /> <control />
@ -1600,6 +1656,7 @@
<dependency type="build" id="libgcrypt-devel"> <dependency type="build" id="libgcrypt-devel">
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="shellcheck"> <dependency type="build" id="shellcheck">
@ -1625,6 +1682,7 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64">protobuf-c-devel</package> <package variant="x86_64">protobuf-c-devel</package>
<package variant="aarch64">protobuf-c-devel</package>
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">protobuf-c-devel</package> <package variant="x86_64">protobuf-c-devel</package>
@ -1642,12 +1700,16 @@
</distro> </distro>
<distro id="fedora"> <distro id="fedora">
<package variant="x86_64" /> <package variant="x86_64" />
<package variant="aarch64" />
</distro> </distro>
<distro id="void"> <distro id="void">
<package variant="x86_64">protobuf</package> <package variant="x86_64">protobuf</package>
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="sudo"> <dependency type="build" id="sudo">
<distro id="debian">
<package variant="i386" />
</distro>
<distro id="ubuntu"> <distro id="ubuntu">
<package variant="x86_64" /> <package variant="x86_64" />
</distro> </distro>
@ -1667,4 +1729,10 @@
<package variant="mingw64">wine</package> <package variant="mingw64">wine</package>
</distro> </distro>
</dependency> </dependency>
<dependency type="build" id="msitools">
<distro id="fedora">
<!-- for building the MSI package -->
<package variant="mingw64">msitools</package>
</distro>
</dependency>
</dependencies> </dependencies>

View File

@ -17,14 +17,13 @@ if [ "$QUBES" = "true" ]; then
fi fi
meson .. \ meson .. \
-Ddocs=none \ -Ddocs=disabled \
-Dman=true \ -Dman=true \
-Dtests=true \ -Dtests=true \
-Dgusb:tests=false \ -Dgusb:tests=false \
-Dplugin_dummy=true \ -Dplugin_dummy=true \
-Dplugin_flashrom=enabled \ -Dplugin_flashrom=enabled \
-Dplugin_modem_manager=disabled \ -Dplugin_modem_manager=disabled \
-Dplugin_thunderbolt=enabled \
-Dplugin_uefi_capsule=enabled \ -Dplugin_uefi_capsule=enabled \
-Dplugin_dell=enabled \ -Dplugin_dell=enabled \
-Dplugin_synaptics_mst=enabled $@ -Dplugin_synaptics_mst=enabled $@

View File

@ -10,9 +10,15 @@ import os
import sys import sys
import argparse import argparse
WARNING = "\033[93m"
ENDC = "\033[0m"
# Minimum version of markdown required # Minimum version of markdown required
MINIMUM_MARKDOWN = (3, 3, 3) MINIMUM_MARKDOWN = (3, 3, 3)
# Minimum meson required
MINIMUM_MESON = "0.60.0"
def get_possible_profiles(): def get_possible_profiles():
return ["fedora", "centos", "debian", "ubuntu", "arch", "void"] return ["fedora", "centos", "debian", "ubuntu", "arch", "void"]
@ -30,7 +36,16 @@ def detect_profile():
return target return target
def test_markdown(): def pip_install_package(debug, name):
import subprocess
cmd = ["python3", "-m", "pip", "install", "--upgrade", name]
if debug:
print(cmd)
subprocess.call(cmd)
def test_markdown(debug):
try: try:
import markdown import markdown
@ -39,7 +54,16 @@ def test_markdown():
new_enough = False new_enough = False
if not new_enough: if not new_enough:
print("python3-markdown must be installed/upgraded") print("python3-markdown must be installed/upgraded")
sys.exit(not new_enough) pip_install_package(debug, "markdown")
def test_meson(debug):
from importlib.metadata import version
new_enough = version("meson") >= MINIMUM_MESON
if not new_enough:
print("meson must be installed/upgraded")
pip_install_package(debug, "meson")
def parse_dependencies(OS, variant, requested_type): def parse_dependencies(OS, variant, requested_type):
@ -74,8 +98,29 @@ def parse_dependencies(OS, variant, requested_type):
return deps return deps
def _validate_deps(os, deps):
validated = deps
if os == "debian" or os == "ubuntu":
try:
from apt import cache
cache = cache.Cache()
for pkg in deps:
if not cache.has_key(pkg) and not cache.is_virtual_package(pkg):
print(
f"{WARNING}WARNING:{ENDC} ignoring unavailable package %s" % pkg
)
validated.remove(pkg)
except ModuleNotFoundError:
print(
f"{WARNING}WARNING:{ENDC} Unable to validate package dependency list without python3-apt"
)
return validated
def get_build_dependencies(os, variant): def get_build_dependencies(os, variant):
return parse_dependencies(os, variant, "build") parsed = parse_dependencies(os, variant, "build")
return _validate_deps(os, parsed)
def _get_installer_cmd(os, yes): def _get_installer_cmd(os, yes):
@ -122,6 +167,7 @@ if __name__ == "__main__":
choices=[ choices=[
"get-dependencies", "get-dependencies",
"test-markdown", "test-markdown",
"test-meson",
"detect-profile", "detect-profile",
"install-dependencies", "install-dependencies",
"install-pip", "install-pip",
@ -154,7 +200,9 @@ if __name__ == "__main__":
# command to run # command to run
if command == "test-markdown": if command == "test-markdown":
test_markdown() test_markdown(args.debug)
elif command == "test-meson":
test_meson(args.debug)
elif command == "detect-profile": elif command == "detect-profile":
print(detect_profile()) print(detect_profile())
elif command == "get-dependencies": elif command == "get-dependencies":

View File

@ -347,9 +347,14 @@ def _build(bld: Builder) -> None:
# built in formats # built in formats
for fzr in [ for fzr in [
Fuzzer("dfuse"), Fuzzer("dfuse"),
Fuzzer("fdt"),
Fuzzer("fit"),
Fuzzer("fmap"), Fuzzer("fmap"),
Fuzzer("ihex"), Fuzzer("ihex"),
Fuzzer("srec"), Fuzzer("srec"),
Fuzzer("ifwi-cpd"),
Fuzzer("ifwi-fpt"),
Fuzzer("oprom"),
Fuzzer("uswid"), Fuzzer("uswid"),
Fuzzer("efi-firmware-filesystem", pattern="efi-firmware-filesystem"), Fuzzer("efi-firmware-filesystem", pattern="efi-firmware-filesystem"),
Fuzzer("efi-firmware-volume", pattern="efi-firmware-volume"), Fuzzer("efi-firmware-volume", pattern="efi-firmware-volume"),

View File

@ -8,6 +8,6 @@
int int
main(void) main(void)
{ {
assert(fu_common_vercmp_full("1.0", "2.1", FWUPD_VERSION_FORMAT_NUMBER) < 0); assert(fu_version_compare("1.0", "2.1", FWUPD_VERSION_FORMAT_NUMBER) < 0);
return 0; return 0;
} }

View File

@ -2,12 +2,21 @@
set -e set -e
set -x set -x
#clone test firmware if necessary
. ./contrib/ci/get_test_firmware.sh
#check for and install missing dependencies #check for and install missing dependencies
./contrib/ci/fwupd_setup_helpers.py install-dependencies --yes -o ubuntu ./contrib/ci/fwupd_setup_helpers.py install-dependencies --yes -o ubuntu
#check we have pip
./contrib/ci/fwupd_setup_helpers.py install-pip --yes -o ubuntu
#check meson is new enough
./contrib/ci/fwupd_setup_helpers.py test-meson
#check markdown is new enough
./contrib/ci/fwupd_setup_helpers.py test-markdown
#clone test firmware if necessary
. ./contrib/ci/get_test_firmware.sh
#evaluate using Ubuntu's buildflags #evaluate using Ubuntu's buildflags
#evaluate using Debian/Ubuntu's buildflags #evaluate using Debian/Ubuntu's buildflags
#disable link time optimization, Ubuntu currently only sets it for GCC #disable link time optimization, Ubuntu currently only sets it for GCC
@ -20,7 +29,7 @@ export LDFLAGS
root=$(pwd) root=$(pwd)
rm -rf ${root}/build rm -rf ${root}/build
chown -R nobody ${root} chown -R nobody ${root}
sudo -u nobody meson ${root}/build -Dman=false -Ddocs=docgen -Dgusb:tests=false -Dplugin_platform_integrity=true --prefix=${root}/dist sudo -u nobody meson ${root}/build -Dman=false -Ddocs=enabled -Dgusb:tests=false -Dplugin_platform_integrity=true --prefix=${root}/dist
#build with clang #build with clang
sudo -u nobody ninja -C ${root}/build test -v sudo -u nobody ninja -C ${root}/build test -v

View File

@ -11,7 +11,7 @@ COMMENT= Update firmware automatically, safely, and reliably
LICENSE= LGPL21 LICENSE= LGPL21
BUILD_DEPENDS= gtkdoc-scan:textproc/gtk-doc \ BUILD_DEPENDS= gi-docgen:textproc/gi-docgen \
help2man:misc/help2man \ help2man:misc/help2man \
vala:lang/vala \ vala:lang/vala \
${LOCALBASE}/libexec/fwupd/efi/fwupdx64.efi:sysutils/fwupd-efi \ ${LOCALBASE}/libexec/fwupd/efi/fwupdx64.efi:sysutils/fwupd-efi \
@ -47,7 +47,7 @@ MESON_ARGS= -Dgudev=disabled \
-Dsystemd=disabled \ -Dsystemd=disabled \
-Doffline=false \ -Doffline=false \
-Dtests=false \ -Dtests=false \
-Ddocs=gtkdoc \ -Ddocs=enabled \
-Defi_binary=false -Defi_binary=false
.include <bsd.port.mk> .include <bsd.port.mk>

View File

@ -76,7 +76,7 @@ BuildRequires: gcab
BuildRequires: valgrind BuildRequires: valgrind
BuildRequires: valgrind-devel BuildRequires: valgrind-devel
%endif %endif
BuildRequires: gtk-doc BuildRequires: gi-docgen
BuildRequires: gnutls-devel BuildRequires: gnutls-devel
BuildRequires: gnutls-utils BuildRequires: gnutls-utils
BuildRequires: meson BuildRequires: meson
@ -236,7 +236,7 @@ fwupd wrapper for Qubes OS
%if 0%{?enable_ci} %if 0%{?enable_ci}
--werror \ --werror \
%endif %endif
-Ddocs=gtkdoc \ -Ddocs=enabled \
%if 0%{?enable_tests} %if 0%{?enable_tests}
-Dtests=true \ -Dtests=true \
%else %else
@ -257,7 +257,6 @@ fwupd wrapper for Qubes OS
%else %else
-Dplugin_msr=disabled \ -Dplugin_msr=disabled \
%endif %endif
-Dplugin_thunderbolt=enabled \
%if 0%{?have_uefi} %if 0%{?have_uefi}
-Dplugin_uefi_capsule=enabled \ -Dplugin_uefi_capsule=enabled \
-Dplugin_uefi_pk=enabled \ -Dplugin_uefi_pk=enabled \
@ -271,10 +270,8 @@ fwupd wrapper for Qubes OS
%endif %endif
%if 0%{?have_dell} %if 0%{?have_dell}
-Dplugin_dell=enabled \ -Dplugin_dell=enabled \
-Dplugin_synaptics_mst=enabled \
%else %else
-Dplugin_dell=disabled \ -Dplugin_dell=disabled \
-Dplugin_synaptics_mst=disabled \
%endif %endif
%if 0%{?have_modem_manager} %if 0%{?have_modem_manager}
-Dplugin_modem_manager=enabled \ -Dplugin_modem_manager=enabled \
@ -287,6 +284,7 @@ fwupd wrapper for Qubes OS
-Dman=true \ -Dman=true \
-Dbluez=enabled \ -Dbluez=enabled \
-Dplugin_powerd=disabled \ -Dplugin_powerd=disabled \
-Dgresource_quirks=disabled \
-Dsupported_build=enabled -Dsupported_build=enabled
%meson_build %meson_build
@ -365,7 +363,6 @@ done
/usr/lib/modules-load.d/fwupd-msr.conf /usr/lib/modules-load.d/fwupd-msr.conf
%config(noreplace)%{_sysconfdir}/fwupd/msr.conf %config(noreplace)%{_sysconfdir}/fwupd/msr.conf
%endif %endif
/usr/lib/modules-load.d/fwupd-redfish.conf
%{_datadir}/dbus-1/system.d/org.freedesktop.fwupd.conf %{_datadir}/dbus-1/system.d/org.freedesktop.fwupd.conf
%{_datadir}/bash-completion/completions/fwupdmgr %{_datadir}/bash-completion/completions/fwupdmgr
%{_datadir}/bash-completion/completions/fwupdtool %{_datadir}/bash-completion/completions/fwupdtool
@ -480,9 +477,7 @@ done
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_scsi.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_scsi.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_steelseries.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_steelseries.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_superio.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_superio.so
%if 0%{?have_dell}
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_mst.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_mst.so
%endif
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_cape.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_cape.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_cxaudio.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_cxaudio.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_prometheus.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_synaptics_prometheus.so
@ -504,6 +499,7 @@ done
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_uefi_recovery.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_uefi_recovery.so
%endif %endif
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_usi_dock.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_usi_dock.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_vbe.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_logind.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_logind.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_logitech_bulkcontroller.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_logitech_bulkcontroller.so
%{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_logitech_hidpp.so %{_libdir}/fwupd-plugins-%{fwupdplugin_version}/libfu_plugin_logitech_hidpp.so
@ -531,7 +527,8 @@ done
%files devel %files devel
%{_datadir}/gir-1.0/Fwupd-2.0.gir %{_datadir}/gir-1.0/Fwupd-2.0.gir
%{_datadir}/gir-1.0/FwupdPlugin-1.0.gir %{_datadir}/gir-1.0/FwupdPlugin-1.0.gir
%{_datadir}/gtk-doc/html/fwupd %{_datadir}/doc/libfwupdplugin
%{_datadir}/doc/libfwupd
%{_datadir}/vala/vapi %{_datadir}/vala/vapi
%{_includedir}/fwupd-1 %{_includedir}/fwupd-1
%{_libdir}/libfwupd*.so %{_libdir}/libfwupd*.so

View File

@ -0,0 +1,28 @@
#!/usr/bin/python3
# pylint: disable=invalid-name,missing-docstring
#
# Copyright (C) 2022 Richard Hughes <richard@hughsie.com>
#
# SPDX-License-Identifier: LGPL-2.1+
import sys
import os
import xml.etree.ElementTree as ET
if len(sys.argv) < 2:
print("not enough arguments")
sys.exit(1)
root = ET.Element("gresources")
n_gresource = ET.SubElement(root, "gresource", {"prefix": "/org/freedesktop/fwupd"})
for fn in sorted(sys.argv[2:]):
n_file = ET.SubElement(n_gresource, "file", {"compressed": "true"})
n_file.text = fn
if fn.endswith(".xml"):
n_file.set("preprocess", "xml-stripblanks")
n_file.set("alias", os.path.basename(fn))
with open(sys.argv[1], "wb") as f:
f.write(ET.tostring(root, "utf-8", xml_declaration=True))
sys.exit(0)

142
contrib/migrate.py Executable file
View File

@ -0,0 +1,142 @@
#!/usr/bin/python3
#
# Copyright (C) 2022 Richard Hughes <richard@hughsie.com>
#
# SPDX-License-Identifier: LGPL-2.1+
#
# import os
import sys
import glob
if __name__ == "__main__":
fns = []
if len(sys.argv) > 1:
fns.extend(sys.argv[1:])
else:
exts = ["c", "h", "map"]
for ext in exts:
for fn in glob.glob("**/*.{}".format(ext), recursive=True):
if fn.startswith("build"):
continue
if fn.startswith("subprojects"):
continue
if fn.startswith(".git"):
continue
fns.append(fn)
for fn in fns:
modified: bool = False
with open(fn, "r") as f:
buf = f.read()
for old, new in {
"fu_common_sum8": "fu_sum8",
"fu_common_sum8_bytes": "fu_sum8_bytes",
"fu_common_sum16": "fu_sum16",
"fu_common_sum16_bytes": "fu_sum16_bytes",
"fu_common_sum16w": "fu_sum16w",
"fu_common_sum16w_bytes": "fu_sum16w_bytes",
"fu_common_sum32": "fu_sum32",
"fu_common_sum32_bytes": "fu_sum32_bytes",
"fu_common_sum32w": "fu_sum32w",
"fu_common_sum32w_bytes": "fu_sum32w_bytes",
"fu_common_crc8": "fu_crc8",
"fu_common_crc8_full": "fu_crc8_full",
"fu_common_crc16": "fu_crc16",
"fu_common_crc16_full": "fu_crc16_full",
"fu_common_crc32": "fu_crc32",
"fu_common_crc32_full": "fu_crc32_full",
"fu_byte_array_set_size_full": "fu_byte_array_set_size",
"fu_common_string_replace": "fu_string_replace",
"fu_common_string_append_kv": "fu_string_append",
"fu_common_string_append_ku": "fu_string_append_ku",
"fu_common_string_append_kx": "fu_string_append_kx",
"fu_common_string_append_kb": "fu_string_append_kb",
"fu_common_strnsplit": "fu_strsplit",
"fu_common_strnsplit_full": "fu_strsplit_full",
"fu_common_strjoin_array": "fu_strjoin",
"fu_common_strsafe": "fu_strsafe",
"fu_common_strwidth": "fu_strwidth",
"fu_common_strstrip": "fu_strstrip",
"fu_common_strtoull": "fu_strtoull",
"fu_common_strtoull_full": "fu_strtoull",
"FuCommonStrsplitFunc": "FuStrsplitFunc",
"fu_common_bytes_pad": "fu_bytes_pad",
"fu_common_bytes_new_offset": "fu_bytes_new_offset",
"fu_common_bytes_align": "fu_bytes_align",
"fu_common_bytes_is_empty": "fu_bytes_is_empty",
"fu_common_bytes_compare(": "fu_bytes_compare(",
"fu_common_set_contents_bytes": "fu_bytes_set_contents",
"fu_common_get_contents_bytes": "fu_bytes_get_contents",
"fu_common_get_contents_stream": "fu_bytes_get_contents_stream",
"fu_common_get_contents_fd": "fu_bytes_get_contents_fd",
"fu_common_read_uint8_safe": "fu_memread_uint8_safe",
"fu_common_read_uint16_safe": "fu_memread_uint16_safe",
"fu_common_read_uint32_safe": "fu_memread_uint32_safe",
"fu_common_read_uint64_safe": "fu_memread_uint64_safe",
"fu_common_write_uint8_safe": "fu_memwrite_uint8_safe",
"fu_common_write_uint16_safe": "fu_memwrite_uint16_safe",
"fu_common_write_uint32_safe": "fu_memwrite_uint32_safe",
"fu_common_write_uint64_safe": "fu_memwrite_uint64_safe",
"fu_common_write_uint16": "fu_memwrite_uint16",
"fu_common_write_uint24": "fu_memwrite_uint24",
"fu_common_write_uint32": "fu_memwrite_uint32",
"fu_common_write_uint64": "fu_memwrite_uint64",
"fu_common_read_uint16": "fu_memread_uint16",
"fu_common_read_uint24": "fu_memread_uint24",
"fu_common_read_uint32": "fu_memread_uint32",
"fu_common_read_uint64": "fu_memread_uint64",
"fu_common_bytes_compare_raw": "fu_memcmp_safe",
"FuOutputHandler": "FuSpawnOutputHandler",
"fu_common_spawn_sync": "fu_spawn_sync",
"fu_common_kernel_locked_down": "fu_kernel_locked_down",
"fu_common_check_kernel_version": "fu_kernel_check_version",
"fu_common_get_firmware_search_path": "fu_kernel_get_firmware_search_path",
"fu_common_set_firmware_search_path": "fu_kernel_set_firmware_search_path",
"fu_common_reset_firmware_search_path": "fu_kernel_reset_firmware_search_path",
"fu_common_firmware_builder": "fu_firmware_builder_process",
"fu_common_uri_get_scheme": "fu_release_uri_get_scheme",
"fu_common_dump_raw": "fu_dump_raw",
"fu_common_dump_full": "fu_dump_full",
"fu_common_dump_bytes": "fu_dump_bytes",
"fu_common_error_array_get_best": "fu_engine_error_array_get_best",
"fu_common_get_path": "fu_path_from_kind",
"fu_common_filename_glob": "fu_path_glob",
"fu_common_fnmatch": "fu_path_fnmatch",
"fu_common_rmtree": "fu_path_rmtree",
"fu_common_get_files_recursive": "fu_path_get_files",
"fu_common_mkdir": "fu_path_mkdir",
"fu_common_mkdir_parent": "fu_path_mkdir_parent",
"fu_common_find_program_in_path": "fu_path_find_program",
"fu_common_cpuid": "fu_cpuid",
"fu_common_get_cpu_vendor": "fu_cpu_get_vendor",
"fu_common_vercmp_full": "fu_version_compare",
"fu_common_version_ensure_semver_full": "fu_version_ensure_semver",
"fu_common_version_from_uint16": "fu_version_from_uint16",
"fu_common_version_from_uint32": "fu_version_from_uint32",
"fu_common_version_from_uint64": "fu_version_from_uint64",
"fu_common_version_guess_format": "fu_version_guess_format",
"fu_common_version_parse_from_format": "fu_version_parse_from_format",
"fu_common_version_verify_format": "fu_version_verify_format",
"fu_common_get_volumes_by_kind": "fu_volume_new_by_kind",
"fu_common_get_volume_by_device": "fu_volume_new_by_device",
"fu_common_get_volume_by_devnum": "fu_volume_new_by_devnum",
"fu_common_get_esp_for_path": "fu_volume_new_esp_for_path",
"fu_common_get_esp_default": "fu_volume_new_esp_default",
"fu_smbios_to_string": "fu_firmware_to_string",
"fu_i2c_device_read_full": "fu_i2c_device_read",
"fu_i2c_device_write_full": "fu_i2c_device_write",
}.items():
if buf.find(old) == -1:
continue
buf = buf.replace(old, new)
modified = True
if modified:
print("MODIFIED: {}".format(fn))
with open(fn, "w") as f:
f.write(buf)
sys.exit(0)

View File

@ -1,3 +1,2 @@
[binaries] [binaries]
exe_wrapper = '/usr/bin/wine'
windmc = '/usr/bin/x86_64-w64-mingw32-windmc' windmc = '/usr/bin/x86_64-w64-mingw32-windmc'

View File

@ -33,14 +33,12 @@ class FwupdHeads:
""" """
Checks if Qubes works under heads Checks if Qubes works under heads
""" """
if "heads" in self.dom0_hwids_info: if "Heads" in self.dom0_hwids_info:
self.heads_version = None self.heads_version = None
hwids = self.dom0_hwids_info.split("\n") hwids = self.dom0_hwids_info.split("\n")
for line in hwids: for line in hwids:
if line.startswith("BiosVersion: CBET4000 "): if "Heads" in line:
self.heads_version = line.replace( self.heads_version = line.split("Heads-v")[1]
"BiosVersion: CBET4000 ", ""
).replace(" heads", "")
else: else:
print("Device is not running under the heads firmware!!") print("Device is not running under the heads firmware!!")
print("Exiting...") print("Exiting...")

View File

@ -906,7 +906,6 @@ class QubesFwupdmgr(FwupdHeads, FwupdUpdate, FwupdReceiveUpdates):
whonix -- Flag enforces downloading the metadata updates via Tor whonix -- Flag enforces downloading the metadata updates via Tor
metadata_url -- Use custom metadata from the url metadata_url -- Use custom metadata from the url
""" """
self._check_fwupdtool_version()
if metadata_url: if metadata_url:
custom_metadata_name = metadata_url.replace(FWUPD_DOWNLOAD_PREFIX, "") custom_metadata_name = metadata_url.replace(FWUPD_DOWNLOAD_PREFIX, "")
self.metadata_file = os.path.join( self.metadata_file = os.path.join(
@ -988,7 +987,7 @@ def main():
print("Exiting...") print("Exiting...")
exit(1) exit(1)
if "--device=" in arg: if "--device=" in arg:
device = arg.replace("--board=", "") device = arg.replace("--device=", "")
if sys.argv[1] == "get-updates": if sys.argv[1] == "get-updates":
q.get_updates_qubes(usbvm=sys_usb) q.get_updates_qubes(usbvm=sys_usb)

View File

@ -36,19 +36,18 @@ class TestQubesFwupdHeads(unittest.TestCase):
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS") @unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
def test_get_hwids(self): def test_get_hwids(self):
self.q._check_fwupdtool_version()
self.q._get_hwids() self.q._get_hwids()
self.assertNotEqual(self.q.dom0_hwids_info, "") self.assertNotEqual(self.q.dom0_hwids_info, "")
def test_gather_firmware_version_empty(self): def test_gather_firmware_version_empty(self):
self.q.dom0_hwids_info = "" self.q.dom0_hwids_info = ""
return_code = self.q._gather_firmware_version() return_code = self.q._gather_firmware_version()
self.assertEqual(return_code, 2) self.assertEqual(return_code, self.qfwupd.EXIT_CODES["NOTHING_TO_DO"])
def test_gather_firmware_version(self): def test_gather_firmware_version(self):
self.q.dom0_hwids_info = "BiosVersion: CBET4000 0.2.2 heads" self.q.dom0_hwids_info = "CBET4000 Heads-v0.2.2-917-g19f0e65"
self.q._gather_firmware_version() self.q._gather_firmware_version()
self.assertEqual(self.q.heads_version, "0.2.2") self.assertEqual(self.q.heads_version, "0.2.2-917-g19f0e65")
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS") @unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
def test_parse_metadata(self): def test_parse_metadata(self):
@ -64,13 +63,14 @@ class TestQubesFwupdHeads(unittest.TestCase):
self.q.metadata_info = HEADS_XML self.q.metadata_info = HEADS_XML
self.q.heads_version = "heads" self.q.heads_version = "heads"
return_code = self.q._parse_heads_updates("x230") return_code = self.q._parse_heads_updates("x230")
self.assertEqual(return_code, 0) self.assertEqual(return_code, self.qfwupd.EXIT_CODES["SUCCESS"])
self.assertEqual( self.assertEqual(
self.q.heads_update_url, self.q.heads_update_url,
"https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab", "https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab",
) )
self.assertEqual( self.assertEqual(
self.q.heads_update_sha, "1a54e69ca2b58d1218035115d481480eaf4c66e4" self.q.heads_update_sha,
"ba519a7a5d8136c8ade0cf0c775c58f3165f42798ff631c3f57f075897ef1586",
) )
self.assertEqual(self.q.heads_update_version, "0.2.3") self.assertEqual(self.q.heads_update_version, "0.2.3")
@ -78,19 +78,20 @@ class TestQubesFwupdHeads(unittest.TestCase):
self.q.metadata_info = HEADS_XML self.q.metadata_info = HEADS_XML
self.q.heads_version = "0.2.3" self.q.heads_version = "0.2.3"
return_code = self.q._parse_heads_updates("x230") return_code = self.q._parse_heads_updates("x230")
self.assertEqual(return_code, 2) self.assertEqual(return_code, self.qfwupd.EXIT_CODES["NOTHING_TO_DO"])
def test_check_heads_updates_lower_version(self): def test_check_heads_updates_lower_version(self):
self.q.metadata_info = HEADS_XML self.q.metadata_info = HEADS_XML
self.q.heads_version = "0.2.2" self.q.heads_version = "0.2.2"
return_code = self.q._parse_heads_updates("x230") return_code = self.q._parse_heads_updates("x230")
self.assertEqual(return_code, 0) self.assertEqual(return_code, self.qfwupd.EXIT_CODES["SUCCESS"])
self.assertEqual( self.assertEqual(
self.q.heads_update_url, self.q.heads_update_url,
"https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab", "https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab",
) )
self.assertEqual( self.assertEqual(
self.q.heads_update_sha, "1a54e69ca2b58d1218035115d481480eaf4c66e4" self.q.heads_update_sha,
"ba519a7a5d8136c8ade0cf0c775c58f3165f42798ff631c3f57f075897ef1586",
) )
self.assertEqual(self.q.heads_update_version, "0.2.3") self.assertEqual(self.q.heads_update_version, "0.2.3")
@ -98,7 +99,9 @@ class TestQubesFwupdHeads(unittest.TestCase):
def test_copy_heads_firmware(self): def test_copy_heads_firmware(self):
qmgr = self.qfwupd.QubesFwupdmgr() qmgr = self.qfwupd.QubesFwupdmgr()
self.q.heads_update_url = "https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab" self.q.heads_update_url = "https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab"
self.q.heads_update_sha = "1a54e69ca2b58d1218035115d481480eaf4c66e4" self.q.heads_update_sha = (
"ba519a7a5d8136c8ade0cf0c775c58f3165f42798ff631c3f57f075897ef1586"
)
self.q.heads_update_version = "0.2.3" self.q.heads_update_version = "0.2.3"
qmgr._download_firmware_updates( qmgr._download_firmware_updates(
self.q.heads_update_url, self.q.heads_update_sha self.q.heads_update_url, self.q.heads_update_sha
@ -109,7 +112,7 @@ class TestQubesFwupdHeads(unittest.TestCase):
if os.path.exists(heads_boot_path): if os.path.exists(heads_boot_path):
shutil.rmtree(heads_boot_path) shutil.rmtree(heads_boot_path)
ret_code = self.q._copy_heads_firmware(qmgr.arch_path) ret_code = self.q._copy_heads_firmware(qmgr.arch_path)
self.assertNotEqual(ret_code, self.qfwupd.EXIT_CODES["NO_UPDATES"]) self.assertNotEqual(ret_code, self.qfwupd.EXIT_CODES["NOTHING_TO_DO"])
firmware_path = os.path.join(heads_boot_path, "firmware.rom") firmware_path = os.path.join(heads_boot_path, "firmware.rom")
self.assertTrue(os.path.exists(firmware_path)) self.assertTrue(os.path.exists(firmware_path))

View File

@ -218,34 +218,29 @@ class TestQubesFwupdmgr(unittest.TestCase):
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS") @unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
def test_download_firmware_updates(self): def test_download_firmware_updates(self):
self.q._download_firmware_updates( self.q._download_firmware_updates(
"https://fwupd.org/downloads/0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7.cab", "https://fwupd.org/downloads/e5ad222bdbd3d3d48d8613e67c7e0a0e194f"
"32c4a2c9be787cdf1d757c489d6455bd7bb14053425180b6d331c37e1ccc1cda", "8cd828e33c554d9f05d933e482c7-hughski-colorhug2-2.0.7.cab",
"e5ad222bdbd3d3d48d8613e67c7e0a0e194f8cd828e33c554d9f05d933e482c7",
) )
update_path = os.path.join( update_path = os.path.join(
FWUPD_DOM0_UPDATES_DIR, FWUPD_DOM0_UPDATES_DIR,
"0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7", "e5ad222bdbd3d3d48d8613e67c7e0a0e194f8cd828e33c554d9f05d933e482c7"
"-hughski-colorhug2-2.0.7.cab",
) )
self.assertTrue(os.path.exists(update_path)) self.assertTrue(os.path.exists(update_path))
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
def test_download_firmware_special_char(self):
self.q._download_firmware_updates(
"https://fwupd.org/downloads/bc334d8b098f2e91603c5f7dfdc837fb01797bbe-Dell%20XPS%2015%209560&Precision%205520%20System%20BIOS_Ver.1.18.0.cab",
"86d9e5e35b0b264be1bb1e49ec16ccd1330390423bfe962267a58c27be7712b8",
)
update_path = os.path.join(FWUPD_DOM0_UPDATES_DIR, "trusted")
self.assertTrue(os.path.exists(update_path))
@unittest.skipUnless(check_whonix_updatevm(), "Requires sys-whonix") @unittest.skipUnless(check_whonix_updatevm(), "Requires sys-whonix")
def test_download_firmware_updates_whonix(self): def test_download_firmware_updates_whonix(self):
self.q._download_firmware_updates( self.q._download_firmware_updates(
"https://fwupd.org/downloads/0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7.cab", "https://fwupd.org/downloads/e5ad222bdbd3d3d48d8613e67c7e0a0e194f"
"32c4a2c9be787cdf1d757c489d6455bd7bb14053425180b6d331c37e1ccc1cda", "8cd828e33c554d9f05d933e482c7-hughski-colorhug2-2.0.7.cab",
"e5ad222bdbd3d3d48d8613e67c7e0a0e194f8cd828e33c554d9f05d933e482c7",
whonix=True, whonix=True,
) )
update_path = os.path.join( update_path = os.path.join(
FWUPD_DOM0_UPDATES_DIR, FWUPD_DOM0_UPDATES_DIR,
"0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7", "e5ad222bdbd3d3d48d8613e67c7e0a0e194f8cd828e33c554d9f05d933e482c7"
"-hughski-colorhug2-2.0.7.cab",
) )
self.assertTrue(os.path.exists(update_path)) self.assertTrue(os.path.exists(update_path))
@ -825,8 +820,11 @@ class TestQubesFwupdmgr(unittest.TestCase):
@unittest.skipUnless(check_usbvm(), REQUIRED_USBVM) @unittest.skipUnless(check_usbvm(), REQUIRED_USBVM)
def test_validate_usbvm_archive(self): def test_validate_usbvm_archive(self):
url = "https://fwupd.org/downloads/0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7.cab" url = (
sha = "32c4a2c9be787cdf1d757c489d6455bd7bb14053425180b6d331c37e1ccc1cda" "https://fwupd.org/downloads/e5ad222bdbd3d3d48d8613e67c7e0a0e1"
"94f8cd828e33c554d9f05d933e482c7-hughski-colorhug2-2.0.7.cab"
)
sha = "e5ad222bdbd3d3d48d8613e67c7e0a0e194f8cd828e33c554d9f05d933e482c7"
name = url.replace("https://fwupd.org/downloads/", "") name = url.replace("https://fwupd.org/downloads/", "")
self.q._clean_usbvm() self.q._clean_usbvm()
self.q._validate_usbvm_dirs() self.q._validate_usbvm_dirs()

View File

@ -56,6 +56,7 @@ setup_unsafe_polkit_rules()
{ {
read -p "Install developer-friendly **unsafe** PolicyKit rules into /etc/polkit-1/rules.d? (y/N) " question read -p "Install developer-friendly **unsafe** PolicyKit rules into /etc/polkit-1/rules.d? (y/N) " question
if [ "$question" = "y" ]; then if [ "$question" = "y" ]; then
sudo mkdir -p /etc/polkit-1/rules.d
sudo cp ./policy/org.freedesktop.fwupd-unsafe.rules /etc/polkit-1/rules.d/ sudo cp ./policy/org.freedesktop.fwupd-unsafe.rules /etc/polkit-1/rules.d/
fi fi
} }
@ -111,9 +112,12 @@ setup_prepush()
check_markdown() check_markdown()
{ {
if ! python3 $HELPER test-markdown; then python3 $HELPER test-markdown
install_pip markdown --upgrade }
fi
check_meson()
{
python3 $HELPER test-meson
} }
detect_os() detect_os()
@ -173,6 +177,7 @@ if [ -t 2 ]; then
esac esac
setup_unsafe_polkit_rules setup_unsafe_polkit_rules
check_markdown check_markdown
check_meson
setup_vscode setup_vscode
rename_branch rename_branch
setup_prepush setup_prepush

View File

@ -9,7 +9,7 @@ fi
# build in tree # build in tree
sudo rm -rf build ${ROOT}/dist sudo rm -rf build ${ROOT}/dist
meson build --prefix=${ROOT}/dist -Dsystemd=disabled -Dudevdir=${ROOT}/dist -Ddocs=none meson build --prefix=${ROOT}/dist -Dsystemd=disabled -Dudevdir=${ROOT}/dist
ninja -C build install ninja -C build install
#create helper scripts #create helper scripts

View File

@ -16,24 +16,24 @@ _show_modifiers()
_fwupdagent() _fwupdagent()
{ {
local cur prev command local cur prev command arg args
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` _get_comp_words_by_ref cur prev
prev=${COMP_WORDS[COMP_CWORD-1]} _get_first_arg
command=${COMP_WORDS[1]} _count_args
case $command in case $arg in
*) *)
#find first command #find first command
if [[ ${COMP_CWORD} = 1 ]]; then if [[ "$args" = "1" ]]; then
COMPREPLY=( $(compgen -W '${_fwupdagent_cmd_list[@]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${_fwupdagent_cmd_list[@]}' -- "$cur") )
#modifiers for all commands
else
_show_modifiers
fi fi
;; ;;
esac esac
#modifiers
_show_modifiers
return 0 return 0
} }

View File

@ -102,11 +102,11 @@ _show_remotes()
_fwupdmgr() _fwupdmgr()
{ {
local cur prev command local cur prev command arg args
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` _get_comp_words_by_ref cur prev
prev=${COMP_WORDS[COMP_CWORD-1]} _get_first_arg
command=${COMP_WORDS[1]} _count_args
case $prev in case $prev in
--filter) --filter)
@ -115,114 +115,90 @@ _fwupdmgr()
;; ;;
esac esac
case $command in case $arg in
activate|clear-results|downgrade|get-releases|get-results|unlock|verify|verify-update|get-updates|switch-branch|update|upgrade) activate|clear-results|downgrade|get-releases|get-results|unlock|verify|verify-update|get-updates|switch-branch|update|upgrade)
if [[ "$prev" = "$command" ]]; then #device ID
if [[ "$args" = "2" ]]; then
_show_device_ids _show_device_ids
else
_show_modifiers
fi fi
;; ;;
get-details) get-details)
#browse for file #find files
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#modifiers
else
_show_modifiers
fi fi
;; ;;
device-test) device-test)
#browse for files #find files
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#modifiers
else
_show_modifiers
fi fi
;; ;;
install) install)
#device ID #device ID
if [[ "$prev" = "${COMP_WORDS[2]}" ]]; then if [[ "$args" = "2" ]]; then
_show_device_ids _show_device_ids
#version #version
elif [[ "$prev" = "${COMP_WORDS[3]}" ]]; then elif [[ "$args" = "3" ]]; then
_show_release_versions "$prev" _show_release_versions "$prev"
#modifiers
else
_show_modifiers
fi fi
;; ;;
local-install) local-install)
#find files #find files
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#device ID or modifiers #device ID or modifiers
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then elif [[ "$args" = "3" ]]; then
_show_device_ids _show_device_ids
_show_modifiers _show_modifiers
#modifiers
else
_show_modifiers
fi fi
;; ;;
modify-remote) modify-remote)
#find remotes #find remotes
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_show_remotes _show_remotes
#add key #add key
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then elif [[ "$args" = "3" ]]; then
local keys local keys
keys="$(command fwupdmgr get-remotes | command awk -v pattern="Remote ID:.*${prev}$" '$0~pattern{show=1; next}/Remote/{show=0}{gsub(/:.*/,"")}show')" keys="$(command fwupdmgr get-remotes | command awk -v pattern="Remote ID:.*${prev}$" '$0~pattern{show=1; next}/Remote/{show=0}{gsub(/:.*/,"")}show')"
COMPREPLY+=( $(compgen -W "${keys}" -- "$cur") ) COMPREPLY+=( $(compgen -W "${keys}" -- "$cur") )
#modifiers
else
_show_modifiers
fi fi
;; ;;
enable-remote) enable-remote)
#find remotes #find remotes
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_show_remotes _show_remotes
#modifiers
else
_show_modifiers
fi fi
;; ;;
disable-remote) disable-remote)
#find remotes #find remotes
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_show_remotes _show_remotes
#modifiers
else
_show_modifiers
fi fi
;; ;;
refresh) refresh)
#find first file #find first file
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#find second file #find second file
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then elif [[ "$args" = "3" ]]; then
_filedir _filedir
#find remote ID #find remote ID
elif [[ "$prev" = "${COMP_WORDS[3]}" ]]; then elif [[ "$args" = "4" ]]; then
_show_remotes _show_remotes
else
_show_modifiers
fi fi
;; ;;
*) *)
#find first command #find first command
if [[ ${COMP_CWORD} = 1 ]]; then if [[ "$args" = "1" ]]; then
COMPREPLY=( $(compgen -W '${_fwupdmgr_cmd_list[@]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${_fwupdmgr_cmd_list[@]}' -- "$cur") )
#modifiers for all commands
else
_show_modifiers
fi fi
;; ;;
esac esac
#modifiers
_show_modifiers
return 0 return 0
} }

View File

@ -47,7 +47,6 @@ _fwupdtool_cmd_list=(
_fwupdtool_opts=( _fwupdtool_opts=(
'--verbose' '--verbose'
'--enable-json-state'
'--allow-reinstall' '--allow-reinstall'
'--allow-older' '--allow-older'
'--force' '--force'
@ -77,6 +76,15 @@ _show_firmware_types()
COMPREPLY+=( $(compgen -W "${firmware_types}" -- "$cur") ) COMPREPLY+=( $(compgen -W "${firmware_types}" -- "$cur") )
} }
_show_device_ids()
{
if ! command -v jq &> /dev/null; then
return 0
fi
local description
description="$(command jq '.Devices | .[] | .DeviceId' @localstatedir@/cache/fwupd/devices.json 2>/dev/null)"
COMPREPLY+=( $(compgen -W "${description}" -- "$cur") )
}
_show_plugins() _show_plugins()
{ {
@ -95,11 +103,11 @@ _show_modifiers()
_fwupdtool() _fwupdtool()
{ {
local cur prev command local cur prev command arg args
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` _get_comp_words_by_ref cur prev
prev=${COMP_WORDS[COMP_CWORD-1]} _get_first_arg
command=${COMP_WORDS[1]} _count_args
case $prev in case $prev in
--plugins) --plugins)
@ -112,80 +120,72 @@ _fwupdtool()
;; ;;
esac esac
case $command in case $arg in
get-details|install|install-blob|firmware-dump) get-details|install|install-blob|firmware-dump|firmware-read)
#find files #find files
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#modifiers #device ID
else elif [[ "$args" = "3" ]]; then
_show_modifiers _show_device_ids
fi fi
;; ;;
attach|detach|activate|verify-update|reinstall|get-updates) attach|detach|activate|verify-update|reinstall|get-updates)
if [[ "$prev" = "$command" ]]; then #device ID
if [[ "$args" = "2" ]]; then
_show_device_ids _show_device_ids
#modifiers
else
_show_modifiers
fi fi
;; ;;
build-firmware) build-firmware)
#file in #file in
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#file out #file out
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then elif [[ "$args" = "3" ]]; then
_filedir _filedir
#script #script
elif [[ "$prev" = "${COMP_WORDS[3]}" ]]; then elif [[ "$args" = "4" ]]; then
_filedir _filedir
#output #output
elif [[ "$prev" = "${COMP_WORDS[4]}" ]]; then elif [[ "$args" = "5" ]]; then
_filedir _filedir
else
_show_modifiers
fi fi
;; ;;
firmware-parse|firmware-patch) firmware-parse|firmware-patch)
#find files #find files
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#firmware_type #firmware_type
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then elif [[ "$args" = "3" ]]; then
_show_firmware_types _show_firmware_types
else
_show_modifiers
fi fi
;; ;;
firmware-convert) firmware-convert)
#file in #file in
if [[ "$prev" = "$command" ]]; then if [[ "$args" = "2" ]]; then
_filedir _filedir
#file out #file out
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then elif [[ "$args" = "3" ]]; then
_filedir _filedir
#firmware_type in #firmware_type in
elif [[ "$prev" = "${COMP_WORDS[3]}" ]]; then elif [[ "$args" = "4" ]]; then
_show_firmware_types _show_firmware_types
#firmware_type out #firmware_type out
elif [[ "$prev" = "${COMP_WORDS[4]}" ]]; then elif [[ "$args" = "5" ]]; then
_show_firmware_types _show_firmware_types
else
_show_modifiers
fi fi
;; ;;
*) *)
#find first command #find first command
if [[ ${COMP_CWORD} = 1 ]]; then if [[ "$args" = "1" ]]; then
COMPREPLY=( $(compgen -W '${_fwupdtool_cmd_list[@]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${_fwupdtool_cmd_list[@]}' -- "$cur") )
#modifiers for all commands
else
_show_modifiers
fi fi
;; ;;
esac esac
#modifiers
_show_modifiers
return 0 return 0
} }

View File

@ -3,7 +3,14 @@ if bashcomp.found()
pkgconfig_define: bashcomp.version().version_compare('>= 2.10') ? ['datadir', datadir] : ['prefix', prefix], pkgconfig_define: bashcomp.version().version_compare('>= 2.10') ? ['datadir', datadir] : ['prefix', prefix],
) )
install_data(['fwupdtool'], con = configuration_data()
con.set('localstatedir', localstatedir)
configure_file(
input: 'fwupdtool',
output: 'fwupdtool',
configuration: con,
install: true,
install_dir: completions_dir, install_dir: completions_dir,
) )

View File

@ -0,0 +1,30 @@
{
"name": "Corsair HARPOON RGB WIRELESS Gaming Mouse",
"interactive": false,
"steps": [
{
"url": "https://fwupd.org/downloads/4865c619fafd6b60d9e57378e51a5d8fff97856be9a08a57e1e8886d812e2969-corsair-mysterio-5.1.132.cab",
"components": [
{
"version": "5.1.132",
"protocol": "com.corsair.bp",
"guids": [
"e6c56fae-0368-5b19-a3f4-b1017abec183"
]
}
]
},
{
"url": "https://fwupd.org/downloads/4787d6b940e56e04549704f6e061eaaa6d24fec3c45cdb551845a2ffa651fb42-corsair-mysterio-5.1.133.cab",
"components": [
{
"version": "5.1.133",
"protocol": "com.corsair.bp",
"guids": [
"e6c56fae-0368-5b19-a3f4-b1017abec183"
]
}
]
}
]
}

View File

@ -0,0 +1,54 @@
{
"name": "Corsair KATAR PRO WIRELESS",
"interactive": false,
"steps": [
{
"url": "https://fwupd.org/downloads/03c478a9248c658d985267c6a67da878ab8c856e71bbd49105424d48e7fbf98c-corsair-mandarin-receiver-2.3.22.cab",
"components": [
{
"version": "2.3.22",
"protocol": "com.corsair.bp",
"guids": [
"8bf1f03f-3c6f-53a1-9169-800fddf0952c"
]
}
]
},
{
"url": "https://fwupd.org/downloads/713ec6eace214d6646c788fdbaa24b24c1077dc52d8e9e404bf545db63940d00-corsair-mandarin-mouse-2.5.32.cab",
"components": [
{
"version": "2.5.32",
"protocol": "com.corsair.bp",
"guids": [
"7235bc76-2e5a-5312-b848-882871503152"
]
}
]
},
{
"url": "https://fwupd.org/downloads/e89d2bda6e66c1af342ffe307e313c49a16371a83a7e9a5f87dcdeadba61f4ad-corsair-mandarin-receiver-2.3.23.cab",
"components": [
{
"version": "2.3.23",
"protocol": "com.corsair.bp",
"guids": [
"8bf1f03f-3c6f-53a1-9169-800fddf0952c"
]
}
]
},
{
"url": "https://fwupd.org/downloads/7cccf09f717ae6eb8d5d23fb089aa07f8279edc63ec1dfff9bf2f74d46e498fc-corsair-mandarin-mouse-2.5.33.cab",
"components": [
{
"version": "2.5.33",
"protocol": "com.corsair.bp",
"guids": [
"7235bc76-2e5a-5312-b848-882871503152"
]
}
]
}
]
}

View File

@ -0,0 +1,30 @@
{
"name": "Corsair KATAR PRO XT Gaming Mouse",
"interactive": false,
"steps": [
{
"url": "https://fwupd.org/downloads/3bfde46a20bffd123ea4efd8eb7b59fb50d473ec9176735538e139a4e6b6e12c-corsair-bora-1.6.25.cab",
"components": [
{
"version": "1.6.25",
"protocol": "com.corsair.bp",
"guids": [
"b7b0728e-94e9-5ad5-999f-c6a359a9ddd4"
]
}
]
},
{
"url": "https://fwupd.org/downloads/7598356dbb3c40f16bc4cd314497ad0b983303e52311f95afc1d9aa8661a154d-corsair-bora-1.6.26.cab",
"components": [
{
"version": "1.6.26",
"protocol": "com.corsair.bp",
"guids": [
"b7b0728e-94e9-5ad5-999f-c6a359a9ddd4"
]
}
]
}
]
}

View File

@ -0,0 +1,30 @@
{
"name": "Corsair SABRE PRO Gaming Mouse",
"interactive": false,
"steps": [
{
"url": "https://fwupd.org/downloads/c5d729ea474b0c380641a5a86f05796dad6e74888b3eb207237f18fab9da8157-corsair-tongs-1.15.24.cab",
"components": [
{
"version": "1.15.24",
"protocol": "com.corsair.bp",
"guids": [
"9896f0c3-6682-5392-80f6-0ba462918645"
]
}
]
},
{
"url": "https://fwupd.org/downloads/5adc54e39596b5b941339d247ac01f6a40377bc58e6b1b87c49d60c8a7509f4e-corsair-tongs-1.15.25.cab",
"components": [
{
"version": "1.15.25",
"protocol": "com.corsair.bp",
"guids": [
"9896f0c3-6682-5392-80f6-0ba462918645"
]
}
]
}
]
}

View File

@ -4,6 +4,10 @@ install_data([
'8bitdo-sfc30.json', '8bitdo-sfc30.json',
'aiaiai-h05.json', 'aiaiai-h05.json',
'bizlink-no-sku-vli.json', 'bizlink-no-sku-vli.json',
'corsair-harpoon-rgb-wireless.json',
'corsair-katar-pro-wireless.json',
'corsair-katar-pro-xt.json',
'corsair-sabre-pro.json',
'dell-kh08p.json', 'dell-kh08p.json',
'dell-wd19tb.json', 'dell-wd19tb.json',
'fwupd-a3bu-xplained.json', 'fwupd-a3bu-xplained.json',

View File

@ -20,6 +20,7 @@
{ {
"version": "1.8.1", "version": "1.8.1",
"guids": [ "guids": [
"541b2713-d367-5240-a443-bed07f09ffbf",
"4f3fac7c-981b-58cc-bb58-8a3b90f31c9c", "4f3fac7c-981b-58cc-bb58-8a3b90f31c9c",
"ac7d7cbb-7ef5-5466-ab3d-e70ced97ee61" "ac7d7cbb-7ef5-5466-ab3d-e70ced97ee61"
] ]
@ -44,6 +45,7 @@
{ {
"version": "1.9.3", "version": "1.9.3",
"guids": [ "guids": [
"541b2713-d367-5240-a443-bed07f09ffbf",
"4f3fac7c-981b-58cc-bb58-8a3b90f31c9c", "4f3fac7c-981b-58cc-bb58-8a3b90f31c9c",
"ac7d7cbb-7ef5-5466-ab3d-e70ced97ee61" "ac7d7cbb-7ef5-5466-ab3d-e70ced97ee61"
] ]

View File

@ -2,17 +2,6 @@
"name": "Steelseries Rival 3 Wireless", "name": "Steelseries Rival 3 Wireless",
"interactive": true, "interactive": true,
"steps": [ "steps": [
{
"url": "https://fwupd.org/downloads/89791626948cb485e15d093ac47c7823d5ad6a7dcbe8b9917a3711f5c8694d52-SteelSeries_Rival_3_Wireless_0.20.cab",
"components": [
{
"version": "0.20",
"guids": [
"73e6daa7-d5a1-567d-a0ff-01514f8498b1"
]
}
]
},
{ {
"url": "https://fwupd.org/downloads/fe3775d33b41898e69f06698ed03779a158d99b9716a9b1c0ee7e3051ab857c3-SteelSeries_Rival_3_Wireless_1.0.cab", "url": "https://fwupd.org/downloads/fe3775d33b41898e69f06698ed03779a158d99b9716a9b1c0ee7e3051ab857c3-SteelSeries_Rival_3_Wireless_1.0.cab",
"components": [ "components": [
@ -23,6 +12,17 @@
] ]
} }
] ]
},
{
"url": "https://fwupd.org/downloads/30c6979b393fee0bbf27695fa1b36c1fa8ac276c7744a8e3845a859e79fb0c94-SteelSeries_Rival_3_Wireless_1.4.cab",
"components": [
{
"version": "1.4",
"guids": [
"73e6daa7-d5a1-567d-a0ff-01514f8498b1"
]
}
]
} }
] ]
} }

View File

@ -28,8 +28,8 @@ if build_standalone
install_data(['daemon.conf'], install_data(['daemon.conf'],
install_dir: join_paths(sysconfdir, 'fwupd') install_dir: join_paths(sysconfdir, 'fwupd')
) )
install_data(['power.quirk', 'cfi.quirk'], plugin_quirks += join_paths(meson.current_source_dir(), 'power.quirk')
install_dir: join_paths(datadir, 'fwupd', 'quirks.d')) plugin_quirks += join_paths(meson.current_source_dir(), 'cfi.quirk')
endif endif
if get_option('metainfo') if get_option('metainfo')

View File

@ -34,6 +34,53 @@
<binary>fwupdagent</binary> <binary>fwupdagent</binary>
</provides> </provides>
<releases> <releases>
<release version="1.8.2" date="2022-07-11">
<description>
<p>
This release adds the following features:
</p>
<ul>
<li>Add startup profiling which allowed us to speed up daemon startup considerably</li>
<li>Add support for OptionROM, CPD and FPT firmware formats for future hardware</li>
<li>Add the HostVendor to the D-Bus interface</li>
<li>Break some internal ABI and add a conversion helper for out-of-tree plugins</li>
<li>Optionally build the quirk files into the daemon binary to reduce installed size</li>
</ul>
<p>This release fixes the following bugs:</p>
<ul>
<li>Allow front-end clients to read the percentage property</li>
<li>Allow more quirk entries to add multiple items</li>
<li>Allow to force install Genesys firmware even if the public-key does not match</li>
<li>Allow UFS disks to define the signed status in metadata</li>
<li>Autoconnect the Redfish network device when rebooting the BMC</li>
<li>Copy the instance ID strings when incorporating devices</li>
<li>Do not generate a capsule header for the FMP GUID</li>
<li>Ensure more firmware formats can round-trip to and from XML</li>
<li>Fix a regression for devices using the Atmel FLIP Bootloader</li>
<li>Fix running fwupdtool security with a user-specified plugin allowlist</li>
<li>Handle ENOTTY with the correct error code for ioctl calls</li>
<li>Increase the self tests coverage substantially</li>
<li>Modernize the AMT plugin and split out common MEI functionality</li>
<li>Only move the logitech-bulkcontroller progressbar forwards when writing</li>
<li>Set the device ID on the FwupdRequest to allow better UX</li>
<li>Show the get-details output when the device requirements fail</li>
<li>Simply quirk matching for i2c devices to speed up daemon startup</li>
<li>Support SHA256 fastboot hashes if specified</li>
<li>Use force-detach to bypass the DFU streaming check for camera devices</li>
<li>Use the SCSI target to correctly set the physical ID</li>
<li>Wait for the System76 launch device to re-enumerate if already unlocked</li>
</ul>
<p>This release adds support for the following hardware:</p>
<ul>
<li>Corsair HARPOON RGB Wireless mouse</li>
<li>U-Boot devices writing simple FIT images</li>
<li>Genesys M27fd AIM101</li>
<li>More PixArt wireless devices</li>
<li>More Steelseries HID, Sonic and Fizz devices</li>
<li>System76 launch_2</li>
</ul>
</description>
</release>
<release version="1.8.1" date="2022-05-27"> <release version="1.8.1" date="2022-05-27">
<description> <description>
<p> <p>

3
debian/clean vendored
View File

@ -1,2 +1 @@
gtk-doc.make
m4/gtk-doc.m4

4
debian/control.in vendored
View File

@ -15,7 +15,7 @@ Homepage: https://github.com/fwupd/fwupd
Vcs-Git: https://salsa.debian.org/efi-team/fwupd.git Vcs-Git: https://salsa.debian.org/efi-team/fwupd.git
Vcs-Browser: https://salsa.debian.org/efi-team/fwupd Vcs-Browser: https://salsa.debian.org/efi-team/fwupd
Package: libfwupdplugin6 Package: libfwupdplugin7
Section: libs Section: libs
Architecture: linux-any Architecture: linux-any
Depends: ${misc:Depends}, Depends: ${misc:Depends},
@ -156,7 +156,7 @@ Description: GObject introspection data for libfwupd
Package: libfwupdplugin-dev Package: libfwupdplugin-dev
Architecture: linux-any Architecture: linux-any
Multi-Arch: same Multi-Arch: same
Depends: libfwupdplugin6 (= ${binary:Version}), Depends: libfwupdplugin7 (= ${binary:Version}),
gir1.2-fwupdplugin-1.0 (= ${binary:Version}), gir1.2-fwupdplugin-1.0 (= ${binary:Version}),
libarchive-dev, libarchive-dev,
libcbor-dev, libcbor-dev,

View File

@ -1,4 +1,4 @@
libfwupdplugin.so.6 libfwupdplugin6 #MINVER# libfwupdplugin.so.7 libfwupdplugin7 #MINVER#
LIBFWUPDPLUGIN_0.1.0@LIBFWUPDPLUGIN_0.1.0 0.1.0 LIBFWUPDPLUGIN_0.1.0@LIBFWUPDPLUGIN_0.1.0 0.1.0
LIBFWUPDPLUGIN_0.6.1@LIBFWUPDPLUGIN_0.6.1 0.6.1 LIBFWUPDPLUGIN_0.6.1@LIBFWUPDPLUGIN_0.6.1 0.6.1
LIBFWUPDPLUGIN_0.7.1@LIBFWUPDPLUGIN_0.7.1 0.7.1 LIBFWUPDPLUGIN_0.7.1@LIBFWUPDPLUGIN_0.7.1 0.7.1

2
debian/rules vendored
View File

@ -49,7 +49,7 @@ ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
CONFARGS += -Dplugin_logitech_bulkcontroller=disabled CONFARGS += -Dplugin_logitech_bulkcontroller=disabled
endif endif
CONFARGS += -Dplugin_dummy=true -Dplugin_powerd=disabled -Ddocs=gtkdoc -Dsupported_build=enabled -Dplugin_modem_manager=enabled -Dsystemd_unit_user=fwupd-refresh CONFARGS += -Dplugin_dummy=true -Dplugin_powerd=disabled -Dsupported_build=enabled -Dplugin_modem_manager=enabled -Dsystemd_unit_user=fwupd-refresh
%: %:
dh $@ --with gir dh $@ --with gir

View File

@ -17,6 +17,7 @@ with a non-standard filesystem layout.
* `FWUPD_XMLB_VERBOSE` can be set to show Xmlb silo regeneration and quirk matches * `FWUPD_XMLB_VERBOSE` can be set to show Xmlb silo regeneration and quirk matches
* `FWUPD_DBUS_SOCKET` is used to set the socket filename if running without a dbus-daemon * `FWUPD_DBUS_SOCKET` is used to set the socket filename if running without a dbus-daemon
* `FWUPD_DOWNLOAD_VERBOSE` can be used to show wget or curl output * `FWUPD_DOWNLOAD_VERBOSE` can be used to show wget or curl output
* `FWUPD_PROFILE` can be used to set the profile traceback threshold value in ms
* standard glibc variables like `LANG` are also honored for CLI tools that are translated * standard glibc variables like `LANG` are also honored for CLI tools that are translated
* libcurl respects the session proxy, e.g. `http_proxy`, `all_proxy`, `sftp_proxy` and `no_proxy` * libcurl respects the session proxy, e.g. `http_proxy`, `all_proxy`, `sftp_proxy` and `no_proxy`

View File

@ -1,87 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
]>
<book id="index">
<bookinfo>
<title>fwupd Reference Manual</title>
</bookinfo>
<reference id="intro">
<title>About fwupd</title>
<partintro>
<para>
fwupd is a daemon for updating firmware.
</para>
</partintro>
</reference>
<reference id="libfwupd">
<title>libfwupd</title>
<partintro>
<para>
Functionality exported by libfwupd for client applications.
</para>
</partintro>
<xi:include href="xml/fwupd-client.xml"/>
<xi:include href="xml/fwupd-client-sync.xml"/>
<xi:include href="xml/fwupd-device.xml"/>
<xi:include href="xml/fwupd-release.xml"/>
<xi:include href="xml/fwupd-plugin.xml"/>
<xi:include href="xml/fwupd-remote.xml"/>
<xi:include href="xml/fwupd-error.xml"/>
<xi:include href="xml/fwupd-enums.xml"/>
<xi:include href="xml/fwupd-version.xml"/>
</reference>
<reference id="plugin-reference">
<title>Plugin Reference</title>
<partintro>
<para>
Functionality available to plugins.
</para>
</partintro>
<xi:include href="xml/fu-archive.xml"/>
<xi:include href="xml/fu-chunk.xml"/>
<xi:include href="xml/fu-common-cab.xml"/>
<xi:include href="xml/fu-common-guid.xml"/>
<xi:include href="xml/fu-common-version.xml"/>
<xi:include href="xml/fu-common.xml"/>
<xi:include href="xml/fu-context.xml"/>
<xi:include href="xml/fu-cfu-offer.xml"/>
<xi:include href="xml/fu-cfu-payload.xml"/>
<xi:include href="xml/fu-device-locker.xml"/>
<xi:include href="xml/fu-device-metadata.xml"/>
<xi:include href="xml/fu-device.xml"/>
<xi:include href="xml/fu-dfu-firmware.xml"/>
<xi:include href="xml/fu-efi-signature.xml"/>
<xi:include href="xml/fu-efi-signature-list.xml"/>
<xi:include href="xml/fu-firmware-common.xml"/>
<xi:include href="xml/fu-firmware.xml"/>
<xi:include href="xml/fu-hwids.xml"/>
<xi:include href="xml/fu-ihex-firmware.xml"/>
<xi:include href="xml/fu-srec-firmware.xml"/>
<xi:include href="xml/fu-io-channel.xml"/>
<xi:include href="xml/fu-mutex.xml"/>
<xi:include href="xml/fu-plugin-vfuncs.xml"/>
<xi:include href="xml/fu-plugin.xml"/>
<xi:include href="xml/fu-progress.xml"/>
<xi:include href="xml/fu-quirks.xml"/>
<xi:include href="xml/fu-smbios.xml"/>
<xi:include href="xml/fu-udev-device.xml"/>
<xi:include href="xml/fu-usb-device.xml"/>
</reference>
<index id="api-index-full">
<title>API Index</title>
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
</index>
<index id="deprecated-api-index" role="deprecated">
<title>Index of deprecated API</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</book>

View File

@ -1,4 +1,4 @@
if get_option('docs') == 'docgen' if gidocgen_dep.found() and docs_python_deps.allowed() and gidocgen_app.found() and introspection.allowed()
toml_conf = configuration_data() toml_conf = configuration_data()
docgen_version = source_version docgen_version = source_version
if git.found() and source_version != fwupd_version if git.found() and source_version != fwupd_version
@ -25,7 +25,7 @@ if get_option('docs') == 'docgen'
], ],
output: 'libfwupd', output: 'libfwupd',
command: [ command: [
gidocgen, gidocgen_app,
'generate', 'generate',
'--quiet', '--quiet',
'--add-include-path=@0@'.format(meson.current_build_dir() / '../libfwupd'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../libfwupd'),
@ -40,7 +40,7 @@ if get_option('docs') == 'docgen'
], ],
build_by_default: true, build_by_default: true,
install: true, install: true,
install_dir: join_paths(datadir, 'doc', 'fwupd'), install_dir: join_paths(datadir, 'doc'),
) )
custom_target('doc-fwupdplugin', custom_target('doc-fwupdplugin',
@ -50,7 +50,7 @@ if get_option('docs') == 'docgen'
], ],
output: 'libfwupdplugin', output: 'libfwupdplugin',
command: [ command: [
gidocgen, gidocgen_app,
'generate', 'generate',
'--quiet', '--quiet',
'--add-include-path=@0@'.format(meson.current_build_dir() / '../libfwupd'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../libfwupd'),
@ -66,30 +66,12 @@ if get_option('docs') == 'docgen'
], ],
build_by_default: true, build_by_default: true,
install: true, install: true,
install_dir: join_paths(datadir, 'doc', 'fwupd'), install_dir: join_paths(datadir, 'doc'),
)
install_data(['index.html', 'hsi.html'],
install_dir : join_paths(datadir, 'doc', 'fwupd')
) )
install_data(['urlmap_fwupd.js'], install_data(['urlmap_fwupd.js'],
install_dir : join_paths(datadir, 'doc', 'fwupd', 'libfwupd') install_dir: join_paths(datadir, 'doc', 'libfwupd')
) )
install_data(['urlmap_fwupdplugin.js'], install_data(['urlmap_fwupdplugin.js'],
install_dir : join_paths(datadir, 'doc', 'fwupd', 'libfwupdplugin') install_dir: join_paths(datadir, 'doc', 'libfwupdplugin')
)
elif get_option('docs') == 'gtkdoc'
gnome.gtkdoc(
'fwupd',
src_dir : [
join_paths(meson.project_source_root(), 'libfwupd'),
join_paths(meson.project_source_root(), 'libfwupdplugin'),
join_paths(meson.build_root(), 'libfwupd'),
join_paths(meson.build_root(), 'libfwupdplugin'),
join_paths(meson.current_source_dir()),
],
main_xml : 'fwupd-docs.xml',
install : true
) )
endif endif

View File

@ -56,7 +56,7 @@ is taken automatically from the suffix of the `.so` file.
} }
static gboolean static gboolean
fu_plugin_foo_startup(FuPlugin *plugin, GError **error) fu_plugin_foo_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *data = fu_plugin_get_data(plugin);
data->proxy = create_proxy(); data->proxy = create_proxy();
@ -92,7 +92,7 @@ derive the details about the `FuDevice` from the hardware, for example reading
data from `sysfs` or `/dev`. data from `sysfs` or `/dev`.
static gboolean static gboolean
fu_plugin_foo_coldplug(FuPlugin *plugin, GError **error) fu_plugin_foo_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
g_autoptr(FuDevice) dev = NULL; g_autoptr(FuDevice) dev = NULL;
fu_device_set_id(dev, "dummy-1:2:3"); fu_device_set_id(dev, "dummy-1:2:3");
@ -545,6 +545,49 @@ configuration or serial numbers. This is meant to retrieve the current
firmware contents for verification purposes. The data read can then be firmware contents for verification purposes. The data read can then be
output to a binary blob using `fu_firmware_write()`. output to a binary blob using `fu_firmware_write()`.
#### set_progress
Informs the daemon of the expected duration percentages for the different
phases of update. The daemon runs the `->detach()`, `->write_firmware()`,
`->attach()` and `->reload()` phases as part of the engine during the firmware
update (rather than being done by plugin-specific code) and so this vfunc
informs the daemon how to scale the progress output accordingly.
For instance, if your update takes 2 seconds to detach into bootloader mode,
10 seconds to write the firmware, 7 seconds to attach back into runtime mode
(which includes the time required for USB enumeration) and then 1 second to
read the new firmware version you would use:
fu_progress_set_id(progress, G_STRLOC);
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 10, "detach");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 45, "write");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 40, "attach");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 5, "reload");
If however your device does not require `->detach()` or `->attach()`, and
`->reload()` is instantaneous, you still however need to include 4 steps:
fu_progress_set_id(progress, G_STRLOC);
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 0, "detach");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 100, "write");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 0, "attach");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 0, "reload");
If the device has multiple phases that occur when actually in the write phase
then it is perfectly okay to split up the `FuProgress` steps in the
`->write_firmware()` vfunc further. For instance:
fu_progress_set_id(progress, G_STRLOC);
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 5, "wait-for-idle");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 90, "write");
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 5, "reset");
It should be noted that actions that are required to be done *before* the update
should be added as a `->prepare()` vfunc, and those to be done after in the `->cleanup()`
as the daemon will then recover the hardware if the update fails. For instance,
putting the device back into a *normal runtime power saving* state should always
be done during cleanup.
### Creating a new firmware type ### Creating a new firmware type
The same way a device type implements some methods to complete its The same way a device type implements some methods to complete its
@ -758,7 +801,7 @@ information.
### Inspecting raw binary data ### Inspecting raw binary data
The `fu_common_dump_full` and `fu_common_dump_raw` functions implement the The `fu_dump_full` and `fu_dump_raw` functions implement the
printing of a binary buffer to the console as a stream of bytes in printing of a binary buffer to the console as a stream of bytes in
hexadecimal. See `libfwupdplugin/fu-common.c` for their definitions, you hexadecimal. See `libfwupdplugin/fu-common.c` for their definitions, you
can find many examples of how to use them in the plugins code. can find many examples of how to use them in the plugins code.

View File

@ -7,7 +7,6 @@
#include "config.h" #include "config.h"
#include <gio/gio.h> #include <gio/gio.h>
#include <glib-object.h>
#include <gmodule.h> #include <gmodule.h>
#ifdef HAVE_LIBCURL #ifdef HAVE_LIBCURL
#include <curl/curl.h> #include <curl/curl.h>
@ -66,6 +65,7 @@ typedef struct {
gchar *daemon_version; gchar *daemon_version;
gchar *host_bkc; gchar *host_bkc;
gchar *host_product; gchar *host_product;
gchar *host_vendor;
gchar *host_machine_id; gchar *host_machine_id;
gchar *host_security_id; gchar *host_security_id;
gboolean only_trusted; gboolean only_trusted;
@ -107,6 +107,7 @@ enum {
PROP_TAINTED, PROP_TAINTED,
PROP_SOUP_SESSION, /* compat ABI, do not use! */ PROP_SOUP_SESSION, /* compat ABI, do not use! */
PROP_HOST_PRODUCT, PROP_HOST_PRODUCT,
PROP_HOST_VENDOR,
PROP_HOST_MACHINE_ID, PROP_HOST_MACHINE_ID,
PROP_HOST_SECURITY_ID, PROP_HOST_SECURITY_ID,
PROP_HOST_BKC, PROP_HOST_BKC,
@ -264,6 +265,20 @@ fwupd_client_signal_emit_object(FwupdClient *self, guint signal_id, GObject *pay
fwupd_client_context_helper(self, helper); fwupd_client_context_helper(self, helper);
} }
static void
fwupd_client_set_host_vendor(FwupdClient *self, const gchar *host_vendor)
{
FwupdClientPrivate *priv = GET_PRIVATE(self);
/* not changed */
if (g_strcmp0(priv->host_vendor, host_vendor) == 0)
return;
g_free(priv->host_vendor);
priv->host_vendor = g_strdup(host_vendor);
fwupd_client_object_notify(self, "host-vendor");
}
static void static void
fwupd_client_set_host_product(FwupdClient *self, const gchar *host_product) fwupd_client_set_host_product(FwupdClient *self, const gchar *host_product)
{ {
@ -441,6 +456,12 @@ fwupd_client_properties_changed_cb(GDBusProxy *proxy,
if (val != NULL) if (val != NULL)
fwupd_client_set_host_bkc(self, g_variant_get_string(val, NULL)); fwupd_client_set_host_bkc(self, g_variant_get_string(val, NULL));
} }
if (g_variant_dict_contains(dict, "HostVendor")) {
g_autoptr(GVariant) val = NULL;
val = g_dbus_proxy_get_cached_property(proxy, "HostVendor");
if (val != NULL)
fwupd_client_set_host_vendor(self, g_variant_get_string(val, NULL));
}
if (g_variant_dict_contains(dict, "HostProduct")) { if (g_variant_dict_contains(dict, "HostProduct")) {
g_autoptr(GVariant) val = NULL; g_autoptr(GVariant) val = NULL;
val = g_dbus_proxy_get_cached_property(proxy, "HostProduct"); val = g_dbus_proxy_get_cached_property(proxy, "HostProduct");
@ -720,6 +741,7 @@ fwupd_client_connect_get_proxy_cb(GObject *source, GAsyncResult *res, gpointer u
g_autoptr(GVariant) val7 = NULL; g_autoptr(GVariant) val7 = NULL;
g_autoptr(GVariant) val8 = NULL; g_autoptr(GVariant) val8 = NULL;
g_autoptr(GVariant) val9 = NULL; g_autoptr(GVariant) val9 = NULL;
g_autoptr(GVariant) val10 = NULL;
g_autoptr(GMutexLocker) locker = NULL; g_autoptr(GMutexLocker) locker = NULL;
proxy = g_dbus_proxy_new_finish(res, &error); proxy = g_dbus_proxy_new_finish(res, &error);
@ -760,6 +782,9 @@ fwupd_client_connect_get_proxy_cb(GObject *source, GAsyncResult *res, gpointer u
val5 = g_dbus_proxy_get_cached_property(priv->proxy, "HostProduct"); val5 = g_dbus_proxy_get_cached_property(priv->proxy, "HostProduct");
if (val5 != NULL) if (val5 != NULL)
fwupd_client_set_host_product(self, g_variant_get_string(val5, NULL)); fwupd_client_set_host_product(self, g_variant_get_string(val5, NULL));
val10 = g_dbus_proxy_get_cached_property(priv->proxy, "HostVendor");
if (val10 != NULL)
fwupd_client_set_host_vendor(self, g_variant_get_string(val10, NULL));
val6 = g_dbus_proxy_get_cached_property(priv->proxy, "HostMachineId"); val6 = g_dbus_proxy_get_cached_property(priv->proxy, "HostMachineId");
if (val6 != NULL) if (val6 != NULL)
fwupd_client_set_host_machine_id(self, g_variant_get_string(val6, NULL)); fwupd_client_set_host_machine_id(self, g_variant_get_string(val6, NULL));
@ -827,8 +852,8 @@ fwupd_client_connect_get_connection_cb(GObject *source, GAsyncResult *res, gpoin
* Sets up the client ready for use. This is probably the first method you call * Sets up the client ready for use. This is probably the first method you call
* when wanting to use libfwupd in an asynchronous manner. * when wanting to use libfwupd in an asynchronous manner.
* *
* Other methods such as fwupd_client_get_devices_async() should only be called * Other methods such as [method@FwupdClient.get_devices_async] should only be called
* after fwupd_client_connect_finish() has been called without an error. * after [method@FwupdClient.connect_finish] has been called without an error.
* *
* Since: 1.5.0 * Since: 1.5.0
**/ **/
@ -921,7 +946,7 @@ fwupd_client_connect_finish(FwupdClient *self, GAsyncResult *res, GError **error
* *
* - connecting to the daemon in one thread and finalizing the client in another one * - connecting to the daemon in one thread and finalizing the client in another one
* - to change the `FWUPD_DBUS_SOCKET` for a different peer-to-peer connection * - to change the `FWUPD_DBUS_SOCKET` for a different peer-to-peer connection
* - to add or change connection hints as specified by `fwupd_client_add_hint()` * - to add or change connection hints as specified by [method@FwupdClient.add_hint].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -1044,7 +1069,7 @@ fwupd_client_get_host_security_attrs_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_host_security_attrs_async(). * Gets the result of [method@FwupdClient.get_host_security_attrs_async].
* *
* Returns: (element-type FwupdSecurityAttr) (transfer container): attributes * Returns: (element-type FwupdSecurityAttr) (transfer container): attributes
* *
@ -1126,7 +1151,7 @@ fwupd_client_get_host_security_events_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_host_security_events_async(). * Gets the result of [method@FwupdClient.get_host_security_events_async].
* *
* Returns: (element-type FwupdSecurityAttr) (transfer container): attributes * Returns: (element-type FwupdSecurityAttr) (transfer container): attributes
* *
@ -1227,7 +1252,7 @@ fwupd_client_get_report_metadata_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_report_metadata_async(). * Gets the result of [method@FwupdClient.get_report_metadata_async].
* *
* Returns: (transfer container): attributes * Returns: (transfer container): attributes
* *
@ -1307,7 +1332,7 @@ fwupd_client_get_devices_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_devices_async(). * Gets the result of [method@FwupdClient.get_devices_async].
* *
* Returns: (element-type FwupdDevice) (transfer container): results * Returns: (element-type FwupdDevice) (transfer container): results
* *
@ -1387,7 +1412,7 @@ fwupd_client_get_plugins_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_plugins_async(). * Gets the result of [method@FwupdClient.get_plugins_async].
* *
* Returns: (element-type FwupdDevice) (transfer container): results * Returns: (element-type FwupdDevice) (transfer container): results
* *
@ -1467,7 +1492,7 @@ fwupd_client_get_history_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_history_async(). * Gets the result of [method@FwupdClient.get_history_async].
* *
* Returns: (element-type FwupdDevice) (transfer container): results * Returns: (element-type FwupdDevice) (transfer container): results
* *
@ -1576,7 +1601,7 @@ fwupd_client_get_device_by_id_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_device_by_id_async(). * Gets the result of [method@FwupdClient.get_device_by_id_async].
* *
* Returns: (transfer full): a device, or %NULL for failure * Returns: (transfer full): a device, or %NULL for failure
* *
@ -1675,7 +1700,7 @@ fwupd_client_get_devices_by_guid_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_devices_by_guid_async(). * Gets the result of [method@FwupdClient.get_devices_by_guid_async].
* *
* Returns: (element-type FwupdRelease) (transfer container): results * Returns: (element-type FwupdRelease) (transfer container): results
* *
@ -1758,7 +1783,7 @@ fwupd_client_get_releases_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_releases_async(). * Gets the result of [method@FwupdClient.get_releases_async].
* *
* Returns: (element-type FwupdRelease) (transfer container): results * Returns: (element-type FwupdRelease) (transfer container): results
* *
@ -1841,7 +1866,7 @@ fwupd_client_get_downgrades_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_downgrades_async(). * Gets the result of [method@FwupdClient.get_downgrades_async].
* *
* Returns: (element-type FwupdRelease) (transfer container): results * Returns: (element-type FwupdRelease) (transfer container): results
* *
@ -1924,7 +1949,7 @@ fwupd_client_get_upgrades_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_upgrades_async(). * Gets the result of [method@FwupdClient.get_upgrades_async].
* *
* Returns: (element-type FwupdRelease) (transfer container): results * Returns: (element-type FwupdRelease) (transfer container): results
* *
@ -2006,7 +2031,7 @@ fwupd_client_modify_config_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_modify_config_async(). * Gets the result of [method@FwupdClient.modify_config_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2085,7 +2110,7 @@ fwupd_client_activate_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_activate_async(). * Gets the result of [method@FwupdClient.activate_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2163,7 +2188,7 @@ fwupd_client_verify_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_verify_async(). * Gets the result of [method@FwupdClient.verify_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2241,7 +2266,7 @@ fwupd_client_verify_update_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_verify_update_async(). * Gets the result of [method@FwupdClient.verify_update_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2319,7 +2344,7 @@ fwupd_client_unlock_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_unlock_async(). * Gets the result of [method@FwupdClient.unlock_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2397,7 +2422,7 @@ fwupd_client_clear_results_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_clear_results_async(). * Gets the result of [method@FwupdClient.clear_results_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2480,7 +2505,7 @@ fwupd_client_get_results_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_results_async(). * Gets the result of [method@FwupdClient.get_results_async].
* *
* Returns: (transfer full): a device, or %NULL for failure * Returns: (transfer full): a device, or %NULL for failure
* *
@ -2670,7 +2695,7 @@ fwupd_client_install_bytes_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_install_bytes_async(). * Gets the result of [method@FwupdClient.install_bytes_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -2755,7 +2780,7 @@ fwupd_client_install_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_install_async(). * Gets the result of [method@FwupdClient.install_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -3097,7 +3122,7 @@ fwupd_client_install_release_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_install_release_async(). * Gets the result of [method@FwupdClient.install_release_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -3229,7 +3254,7 @@ fwupd_client_get_details_bytes_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_details_bytes_async(). * Gets the result of [method@FwupdClient.get_details_bytes_async].
* *
* Returns: (transfer container) (element-type FwupdDevice): an array of results * Returns: (transfer container) (element-type FwupdDevice): an array of results
* *
@ -3316,6 +3341,24 @@ fwupd_client_get_host_product(FwupdClient *self)
return priv->host_product; return priv->host_product;
} }
/**
* fwupd_client_get_host_vendor:
* @self: a #FwupdClient
*
* Gets the string that represents the vendor of the host running fwupd
*
* Returns: a string, or %NULL for unknown.
*
* Since: 1.8.2
**/
const gchar *
fwupd_client_get_host_vendor(FwupdClient *self)
{
FwupdClientPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_CLIENT(self), NULL);
return priv->host_vendor;
}
/** /**
* fwupd_client_get_host_machine_id: * fwupd_client_get_host_machine_id:
* @self: a #FwupdClient * @self: a #FwupdClient
@ -3611,7 +3654,7 @@ fwupd_client_update_metadata_bytes_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_update_metadata_bytes_async(). * Gets the result of [method@FwupdClient.update_metadata_bytes_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -3799,7 +3842,7 @@ fwupd_client_refresh_remote_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_refresh_remote_async(). * Gets the result of [method@FwupdClient.refresh_remote_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -3879,7 +3922,7 @@ fwupd_client_get_remotes_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_remotes_async(). * Gets the result of [method@FwupdClient.get_remotes_async].
* *
* Returns: (element-type FwupdRemote) (transfer container): results * Returns: (element-type FwupdRemote) (transfer container): results
* *
@ -3963,7 +4006,7 @@ fwupd_client_get_approved_firmware_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_approved_firmware_async(). * Gets the result of [method@FwupdClient.get_approved_firmware_async].
* *
* Returns: (element-type utf8) (transfer container): checksums, or %NULL for error * Returns: (element-type utf8) (transfer container): checksums, or %NULL for error
* *
@ -4046,7 +4089,7 @@ fwupd_client_set_approved_firmware_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_set_approved_firmware_async(). * Gets the result of [method@FwupdClient.set_approved_firmware_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -4130,7 +4173,7 @@ fwupd_client_get_blocked_firmware_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_blocked_firmware_async(). * Gets the result of [method@FwupdClient.get_blocked_firmware_async].
* *
* Returns: (element-type utf8) (transfer container): checksums, or %NULL for error * Returns: (element-type utf8) (transfer container): checksums, or %NULL for error
* *
@ -4213,7 +4256,7 @@ fwupd_client_set_blocked_firmware_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_set_blocked_firmware_async(). * Gets the result of [method@FwupdClient.set_blocked_firmware_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -4292,7 +4335,7 @@ fwupd_client_set_feature_flags_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_set_feature_flags_async(). * Gets the result of [method@FwupdClient.set_feature_flags_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -4390,7 +4433,7 @@ fwupd_client_self_sign_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_self_sign_async(). * Gets the result of [method@FwupdClient.self_sign_async].
* *
* Returns: a signature, or %NULL for failure * Returns: a signature, or %NULL for failure
* *
@ -4474,7 +4517,7 @@ fwupd_client_modify_remote_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_modify_remote_async(). * Gets the result of [method@FwupdClient.modify_remote_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -4559,7 +4602,7 @@ fwupd_client_modify_device_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_modify_device_async(). * Gets the result of [method@FwupdClient.modify_device_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
@ -4656,7 +4699,7 @@ fwupd_client_get_remote_by_id_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_get_remote_by_id_async(). * Gets the result of [method@FwupdClient.get_remote_by_id_async].
* *
* Returns: (transfer full): a #FwupdRemote, or %NULL if not found * Returns: (transfer full): a #FwupdRemote, or %NULL if not found
* *
@ -5006,7 +5049,7 @@ fwupd_client_download_bytes_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_download_bytes_async(). * Gets the result of [method@FwupdClient.download_bytes_async].
* *
* Returns: (transfer full): downloaded data, or %NULL for error * Returns: (transfer full): downloaded data, or %NULL for error
* *
@ -5161,7 +5204,7 @@ fwupd_client_upload_bytes_async(FwupdClient *self,
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of fwupd_client_upload_bytes_async(). * Gets the result of [method@FwupdClient.upload_bytes_async].
* *
* Returns: (transfer full): response data, or %NULL for error * Returns: (transfer full): response data, or %NULL for error
* *
@ -5269,6 +5312,9 @@ fwupd_client_get_property(GObject *object, guint prop_id, GValue *value, GParamS
case PROP_HOST_BKC: case PROP_HOST_BKC:
g_value_set_string(value, priv->host_bkc); g_value_set_string(value, priv->host_bkc);
break; break;
case PROP_HOST_VENDOR:
g_value_set_string(value, priv->host_vendor);
break;
case PROP_HOST_PRODUCT: case PROP_HOST_PRODUCT:
g_value_set_string(value, priv->host_product); g_value_set_string(value, priv->host_product);
break; break;
@ -5318,6 +5364,9 @@ fwupd_client_set_property(GObject *object, guint prop_id, const GValue *value, G
case PROP_HOST_BKC: case PROP_HOST_BKC:
fwupd_client_set_host_bkc(self, g_value_get_string(value)); fwupd_client_set_host_bkc(self, g_value_get_string(value));
break; break;
case PROP_HOST_VENDOR:
fwupd_client_set_host_vendor(self, g_value_get_string(value));
break;
case PROP_HOST_PRODUCT: case PROP_HOST_PRODUCT:
fwupd_client_set_host_product(self, g_value_get_string(value)); fwupd_client_set_host_product(self, g_value_get_string(value));
break; break;
@ -5572,6 +5621,20 @@ fwupd_client_class_init(FwupdClientClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_NAME); G_PARAM_READABLE | G_PARAM_STATIC_NAME);
g_object_class_install_property(object_class, PROP_SOUP_SESSION, pspec); g_object_class_install_property(object_class, PROP_SOUP_SESSION, pspec);
/**
* FwupdClient:host-vendor:
*
* The host vendor string
*
* Since: 1.8.2
*/
pspec = g_param_spec_string("host-vendor",
NULL,
NULL,
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME);
g_object_class_install_property(object_class, PROP_HOST_VENDOR, pspec);
/** /**
* FwupdClient:host-product: * FwupdClient:host-product:
* *
@ -5688,6 +5751,7 @@ fwupd_client_finalize(GObject *object)
g_free(priv->user_agent); g_free(priv->user_agent);
g_free(priv->daemon_version); g_free(priv->daemon_version);
g_free(priv->host_bkc); g_free(priv->host_bkc);
g_free(priv->host_vendor);
g_free(priv->host_product); g_free(priv->host_product);
g_free(priv->host_machine_id); g_free(priv->host_machine_id);
g_free(priv->host_security_id); g_free(priv->host_security_id);

View File

@ -7,7 +7,6 @@
#pragma once #pragma once
#include <gio/gio.h> #include <gio/gio.h>
#include <glib-object.h>
#include "fwupd-device.h" #include "fwupd-device.h"
#include "fwupd-enums.h" #include "fwupd-enums.h"
@ -376,6 +375,8 @@ fwupd_client_get_daemon_version(FwupdClient *self);
const gchar * const gchar *
fwupd_client_get_host_bkc(FwupdClient *self); fwupd_client_get_host_bkc(FwupdClient *self);
const gchar * const gchar *
fwupd_client_get_host_vendor(FwupdClient *self);
const gchar *
fwupd_client_get_host_product(FwupdClient *self); fwupd_client_get_host_product(FwupdClient *self);
const gchar * const gchar *
fwupd_client_get_host_machine_id(FwupdClient *self); fwupd_client_get_host_machine_id(FwupdClient *self);

View File

@ -429,14 +429,20 @@ static void
fwupd_build_history_report_json_device(JsonBuilder *builder, FwupdDevice *dev) fwupd_build_history_report_json_device(JsonBuilder *builder, FwupdDevice *dev)
{ {
FwupdRelease *rel = fwupd_device_get_release_default(dev); FwupdRelease *rel = fwupd_device_get_release_default(dev);
GChecksumType checksum_types[] = {G_CHECKSUM_SHA256, G_CHECKSUM_SHA1, 0};
GPtrArray *checksums; GPtrArray *checksums;
GPtrArray *guids; GPtrArray *guids;
/* identify the firmware used */ /* identify the firmware used */
json_builder_set_member_name(builder, "Checksum");
checksums = fwupd_release_get_checksums(rel); checksums = fwupd_release_get_checksums(rel);
json_builder_add_string_value(builder, for (guint i = 0; checksum_types[i] != 0; i++) {
fwupd_checksum_get_by_kind(checksums, G_CHECKSUM_SHA1)); const gchar *checksum = fwupd_checksum_get_by_kind(checksums, checksum_types[i]);
if (checksum != NULL) {
json_builder_set_member_name(builder, "Checksum");
json_builder_add_string_value(builder, checksum);
break;
}
}
/* identify the firmware written */ /* identify the firmware written */
checksums = fwupd_device_get_checksums(dev); checksums = fwupd_device_get_checksums(dev);

View File

@ -6,7 +6,6 @@
#pragma once #pragma once
#include <glib-object.h>
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include "fwupd-device.h" #include "fwupd-device.h"
@ -21,5 +20,7 @@ void
fwupd_device_incorporate(FwupdDevice *self, FwupdDevice *donor); fwupd_device_incorporate(FwupdDevice *self, FwupdDevice *donor);
void void
fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder); fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder);
void
fwupd_device_to_json_full(FwupdDevice *self, JsonBuilder *builder, FwupdDeviceFlags flags);
G_END_DECLS G_END_DECLS

View File

@ -7,7 +7,6 @@
#include "config.h" #include "config.h"
#include <gio/gio.h> #include <gio/gio.h>
#include <glib-object.h>
#include <string.h> #include <string.h>
#include "fwupd-common-private.h" #include "fwupd-common-private.h"
@ -2888,16 +2887,18 @@ fwupd_pad_kv_ups(GString *str, const gchar *key, FwupdUpdateState value)
} }
/** /**
* fwupd_device_to_json: * fwupd_device_to_json_full:
* @self: a #FwupdDevice * @self: a #FwupdDevice
* @builder: (not nullable): a JSON builder * @builder: (not nullable): a JSON builder
* @flags: device flags
* *
* Adds a fwupd device to a JSON builder * Adds a fwupd device to a JSON builder
* Optionally provides additional data based upon flags
* *
* Since: 1.2.6 * Since: 1.8.2
**/ **/
void void
fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder) fwupd_device_to_json_full(FwupdDevice *self, JsonBuilder *builder, FwupdDeviceFlags flags)
{ {
FwupdDevicePrivate *priv = GET_PRIVATE(self); FwupdDevicePrivate *priv = GET_PRIVATE(self);
@ -2908,7 +2909,7 @@ fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder)
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_DEVICE_ID, priv->id); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_DEVICE_ID, priv->id);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PARENT_DEVICE_ID, priv->parent_id); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PARENT_DEVICE_ID, priv->parent_id);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_COMPOSITE_ID, priv->composite_id); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_COMPOSITE_ID, priv->composite_id);
if (priv->instance_ids->len > 0) { if (flags & FWUPD_DEVICE_FLAG_TRUSTED && priv->instance_ids->len > 0) {
json_builder_set_member_name(builder, FWUPD_RESULT_KEY_INSTANCE_IDS); json_builder_set_member_name(builder, FWUPD_RESULT_KEY_INSTANCE_IDS);
json_builder_begin_array(builder); json_builder_begin_array(builder);
for (guint i = 0; i < priv->instance_ids->len; i++) { for (guint i = 0; i < priv->instance_ids->len; i++) {
@ -2926,6 +2927,7 @@ fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder)
} }
json_builder_end_array(builder); json_builder_end_array(builder);
} }
if (flags & FWUPD_DEVICE_FLAG_TRUSTED)
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SERIAL, priv->serial); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SERIAL, priv->serial);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SUMMARY, priv->summary); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SUMMARY, priv->summary);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_DESCRIPTION, priv->description); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_DESCRIPTION, priv->description);
@ -3074,6 +3076,21 @@ fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder)
} }
} }
/**
* fwupd_device_to_json:
* @self: a #FwupdDevice
* @builder: (not nullable): a JSON builder
*
* Adds a fwupd device to a JSON builder
*
* Since: 1.2.6
**/
void
fwupd_device_to_json(FwupdDevice *self, JsonBuilder *builder)
{
return fwupd_device_to_json_full(self, builder, FWUPD_DEVICE_FLAG_NONE);
}
static gchar * static gchar *
fwupd_device_verstr_raw(guint64 value_raw) fwupd_device_verstr_raw(guint64 value_raw)
{ {

View File

@ -145,6 +145,8 @@ fwupd_device_flag_to_string(FwupdDeviceFlags device_flag)
return "wait-for-replug"; return "wait-for-replug";
if (device_flag == FWUPD_DEVICE_FLAG_IGNORE_VALIDATION) if (device_flag == FWUPD_DEVICE_FLAG_IGNORE_VALIDATION)
return "ignore-validation"; return "ignore-validation";
if (device_flag == FWUPD_DEVICE_FLAG_TRUSTED)
return "trusted";
if (device_flag == FWUPD_DEVICE_FLAG_ANOTHER_WRITE_REQUIRED) if (device_flag == FWUPD_DEVICE_FLAG_ANOTHER_WRITE_REQUIRED)
return "another-write-required"; return "another-write-required";
if (device_flag == FWUPD_DEVICE_FLAG_NO_AUTO_INSTANCE_IDS) if (device_flag == FWUPD_DEVICE_FLAG_NO_AUTO_INSTANCE_IDS)
@ -262,6 +264,8 @@ fwupd_device_flag_from_string(const gchar *device_flag)
return FWUPD_DEVICE_FLAG_WAIT_FOR_REPLUG; return FWUPD_DEVICE_FLAG_WAIT_FOR_REPLUG;
if (g_strcmp0(device_flag, "ignore-validation") == 0) if (g_strcmp0(device_flag, "ignore-validation") == 0)
return FWUPD_DEVICE_FLAG_IGNORE_VALIDATION; return FWUPD_DEVICE_FLAG_IGNORE_VALIDATION;
if (g_strcmp0(device_flag, "trusted") == 0)
return FWUPD_DEVICE_FLAG_TRUSTED;
if (g_strcmp0(device_flag, "another-write-required") == 0) if (g_strcmp0(device_flag, "another-write-required") == 0)
return FWUPD_DEVICE_FLAG_ANOTHER_WRITE_REQUIRED; return FWUPD_DEVICE_FLAG_ANOTHER_WRITE_REQUIRED;
if (g_strcmp0(device_flag, "no-auto-instance-ids") == 0) if (g_strcmp0(device_flag, "no-auto-instance-ids") == 0)

View File

@ -6,7 +6,6 @@
#pragma once #pragma once
#include <glib-object.h>
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include "fwupd-release.h" #include "fwupd-release.h"

View File

@ -7,7 +7,6 @@
#include "config.h" #include "config.h"
#include <gio/gio.h> #include <gio/gio.h>
#include <glib-object.h>
#include <string.h> #include <string.h>
#include "fwupd-common-private.h" #include "fwupd-common-private.h"

View File

@ -24,6 +24,10 @@ fwupd_remote_set_priority(FwupdRemote *self, gint priority);
void void
fwupd_remote_set_agreement(FwupdRemote *self, const gchar *agreement); fwupd_remote_set_agreement(FwupdRemote *self, const gchar *agreement);
void void
fwupd_remote_set_checksum(FwupdRemote *self, const gchar *checksum);
void
fwupd_remote_set_filename_cache(FwupdRemote *self, const gchar *filename);
void
fwupd_remote_set_mtime(FwupdRemote *self, guint64 mtime); fwupd_remote_set_mtime(FwupdRemote *self, guint64 mtime);
gchar ** gchar **
fwupd_remote_get_order_after(FwupdRemote *self); fwupd_remote_get_order_after(FwupdRemote *self);

View File

@ -188,7 +188,16 @@ fwupd_remote_set_agreement(FwupdRemote *self, const gchar *agreement)
priv->agreement = g_strdup(agreement); priv->agreement = g_strdup(agreement);
} }
static void /**
* fwupd_remote_set_checksum:
* @self: a #FwupdRemote
* @checksum: (nullable): checksum string
*
* Sets the remote checksum, typically only useful in the self tests.
*
* Since: 1.8.2
**/
void
fwupd_remote_set_checksum(FwupdRemote *self, const gchar *checksum) fwupd_remote_set_checksum(FwupdRemote *self, const gchar *checksum)
{ {
FwupdRemotePrivate *priv = GET_PRIVATE(self); FwupdRemotePrivate *priv = GET_PRIVATE(self);
@ -462,7 +471,16 @@ fwupd_remote_kind_to_string(FwupdRemoteKind kind)
return NULL; return NULL;
} }
static void /**
* fwupd_remote_set_filename_cache:
* @self: a #FwupdRemote
* @filename: (nullable): filename string
*
* Sets the remote filename cache filename, typically only useful in the self tests.
*
* Since: 1.8.2
**/
void
fwupd_remote_set_filename_cache(FwupdRemote *self, const gchar *filename) fwupd_remote_set_filename_cache(FwupdRemote *self, const gchar *filename)
{ {
FwupdRemotePrivate *priv = GET_PRIVATE(self); FwupdRemotePrivate *priv = GET_PRIVATE(self);

View File

@ -26,7 +26,7 @@ typedef struct {
gchar *image; gchar *image;
} FwupdRequestPrivate; } FwupdRequestPrivate;
enum { PROP_0, PROP_ID, PROP_KIND, PROP_MESSAGE, PROP_IMAGE, PROP_LAST }; enum { PROP_0, PROP_ID, PROP_KIND, PROP_MESSAGE, PROP_IMAGE, PROP_DEVICE_ID, PROP_LAST };
G_DEFINE_TYPE_WITH_PRIVATE(FwupdRequest, fwupd_request, G_TYPE_OBJECT) G_DEFINE_TYPE_WITH_PRIVATE(FwupdRequest, fwupd_request, G_TYPE_OBJECT)
#define GET_PRIVATE(o) (fwupd_request_get_instance_private(o)) #define GET_PRIVATE(o) (fwupd_request_get_instance_private(o))
@ -227,7 +227,7 @@ fwupd_request_to_variant(FwupdRequest *self)
if (priv->device_id != NULL) { if (priv->device_id != NULL) {
g_variant_builder_add(&builder, g_variant_builder_add(&builder,
"{sv}", "{sv}",
FWUPD_RESULT_KEY_PLUGIN, FWUPD_RESULT_KEY_DEVICE_ID,
g_variant_new_string(priv->device_id)); g_variant_new_string(priv->device_id));
} }
if (priv->message != NULL) { if (priv->message != NULL) {
@ -475,6 +475,9 @@ fwupd_request_get_property(GObject *object, guint prop_id, GValue *value, GParam
case PROP_IMAGE: case PROP_IMAGE:
g_value_set_string(value, priv->image); g_value_set_string(value, priv->image);
break; break;
case PROP_DEVICE_ID:
g_value_set_string(value, priv->device_id);
break;
case PROP_KIND: case PROP_KIND:
g_value_set_uint(value, priv->kind); g_value_set_uint(value, priv->kind);
break; break;
@ -498,6 +501,9 @@ fwupd_request_set_property(GObject *object, guint prop_id, const GValue *value,
case PROP_IMAGE: case PROP_IMAGE:
fwupd_request_set_image(self, g_value_get_string(value)); fwupd_request_set_image(self, g_value_get_string(value));
break; break;
case PROP_DEVICE_ID:
fwupd_request_set_device_id(self, g_value_get_string(value));
break;
case PROP_KIND: case PROP_KIND:
fwupd_request_set_kind(self, g_value_get_uint(value)); fwupd_request_set_kind(self, g_value_get_uint(value));
break; break;
@ -589,6 +595,20 @@ fwupd_request_class_init(FwupdRequestClass *klass)
pspec = pspec =
g_param_spec_string("image", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_STATIC_NAME); g_param_spec_string("image", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_STATIC_NAME);
g_object_class_install_property(object_class, PROP_IMAGE, pspec); g_object_class_install_property(object_class, PROP_IMAGE, pspec);
/**
* FwupdRequest:device-id:
*
* The device ID for the request.
*
* Since: 1.8.2
*/
pspec = g_param_spec_string("device-id",
NULL,
NULL,
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME);
g_object_class_install_property(object_class, PROP_DEVICE_ID, pspec);
} }
static void static void

View File

@ -6,7 +6,6 @@
#pragma once #pragma once
#include <glib-object.h>
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include "fwupd-security-attr.h" #include "fwupd-security-attr.h"

View File

@ -29,6 +29,8 @@ typedef struct {
GPtrArray *guids; GPtrArray *guids;
GHashTable *metadata; /* (nullable) */ GHashTable *metadata; /* (nullable) */
gchar *name; gchar *name;
gchar *title;
gchar *description;
gchar *plugin; gchar *plugin;
gchar *url; gchar *url;
guint64 created; guint64 created;
@ -445,6 +447,52 @@ fwupd_security_attr_set_name(FwupdSecurityAttr *self, const gchar *name)
priv->name = g_strdup(name); priv->name = g_strdup(name);
} }
/**
* fwupd_security_attr_set_title:
* @self: a #FwupdSecurityAttr
* @title: (nullable): the attribute title
*
* Sets the attribute title.
*
* Since: 1.8.2
**/
void
fwupd_security_attr_set_title(FwupdSecurityAttr *self, const gchar *title)
{
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FWUPD_IS_SECURITY_ATTR(self));
/* not changed */
if (g_strcmp0(priv->title, title) == 0)
return;
g_free(priv->title);
priv->title = g_strdup(title);
}
/**
* fwupd_security_attr_set_description:
* @self: a #FwupdSecurityAttr
* @description: (nullable): the attribute description
*
* Sets the attribute description.
*
* Since: 1.8.2
**/
void
fwupd_security_attr_set_description(FwupdSecurityAttr *self, const gchar *description)
{
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FWUPD_IS_SECURITY_ATTR(self));
/* not changed */
if (g_strcmp0(priv->description, description) == 0)
return;
g_free(priv->description);
priv->description = g_strdup(description);
}
/** /**
* fwupd_security_attr_set_plugin: * fwupd_security_attr_set_plugin:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
@ -543,6 +591,52 @@ fwupd_security_attr_get_name(FwupdSecurityAttr *self)
return priv->name; return priv->name;
} }
/**
* fwupd_security_attr_get_title:
* @self: a #FwupdSecurityAttr
*
* Gets the attribute title, which is typically a two word title.
*
* The fwupd client program may be able to get translations for this value using a method call
* like `dgettext("fwupd",str)`.
*
* Returns: the attribute title, or %NULL if unset
*
* Since: 1.8.2
**/
const gchar *
fwupd_security_attr_get_title(FwupdSecurityAttr *self)
{
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL);
return priv->title;
}
/**
* fwupd_security_attr_get_description:
* @self: a #FwupdSecurityAttr
*
* Gets the attribute description which is a few lines of prose that normal users will understand.
*
* The fwupd client program may be able to get translations for this value using a method call
* like `dgettext("fwupd",str)`.
*
* NOTE: The returned string may contain placeholders such as `$HostVendor$` or `$HostProduct$`
* and these should be replaced with the values from [method@FwupdClient.get_host_vendor] and
* [method@FwupdClient.get_host_product].
*
* Returns: the attribute description, or %NULL if unset
*
* Since: 1.8.2
**/
const gchar *
fwupd_security_attr_get_description(FwupdSecurityAttr *self)
{
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL);
return priv->description;
}
/** /**
* fwupd_security_attr_get_plugin: * fwupd_security_attr_get_plugin:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
@ -777,6 +871,24 @@ fwupd_security_attr_to_variant(FwupdSecurityAttr *self)
FWUPD_RESULT_KEY_NAME, FWUPD_RESULT_KEY_NAME,
g_variant_new_string(priv->name)); g_variant_new_string(priv->name));
} }
if (priv->title != NULL) {
g_variant_builder_add(&builder,
"{sv}",
FWUPD_RESULT_KEY_SUMMARY,
g_variant_new_string(priv->title));
}
if (priv->description != NULL) {
g_variant_builder_add(&builder,
"{sv}",
FWUPD_RESULT_KEY_DESCRIPTION,
g_variant_new_string(priv->description));
}
if (priv->plugin != NULL) {
g_variant_builder_add(&builder,
"{sv}",
FWUPD_RESULT_KEY_PLUGIN,
g_variant_new_string(priv->plugin));
}
if (priv->url != NULL) { if (priv->url != NULL) {
g_variant_builder_add(&builder, g_variant_builder_add(&builder,
"{sv}", "{sv}",
@ -899,6 +1011,14 @@ fwupd_security_attr_from_key_value(FwupdSecurityAttr *self, const gchar *key, GV
fwupd_security_attr_set_name(self, g_variant_get_string(value, NULL)); fwupd_security_attr_set_name(self, g_variant_get_string(value, NULL));
return; return;
} }
if (g_strcmp0(key, FWUPD_RESULT_KEY_SUMMARY) == 0) {
fwupd_security_attr_set_title(self, g_variant_get_string(value, NULL));
return;
}
if (g_strcmp0(key, FWUPD_RESULT_KEY_DESCRIPTION) == 0) {
fwupd_security_attr_set_description(self, g_variant_get_string(value, NULL));
return;
}
if (g_strcmp0(key, FWUPD_RESULT_KEY_PLUGIN) == 0) { if (g_strcmp0(key, FWUPD_RESULT_KEY_PLUGIN) == 0) {
fwupd_security_attr_set_plugin(self, g_variant_get_string(value, NULL)); fwupd_security_attr_set_plugin(self, g_variant_get_string(value, NULL));
return; return;
@ -1022,6 +1142,12 @@ fwupd_security_attr_from_json(FwupdSecurityAttr *self, JsonNode *json_node, GErr
fwupd_security_attr_set_name( fwupd_security_attr_set_name(
self, self,
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_NAME, NULL)); json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_NAME, NULL));
fwupd_security_attr_set_title(
self,
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_SUMMARY, NULL));
fwupd_security_attr_set_description(
self,
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_DESCRIPTION, NULL));
fwupd_security_attr_set_plugin( fwupd_security_attr_set_plugin(
self, self,
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_PLUGIN, NULL)); json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_PLUGIN, NULL));
@ -1108,6 +1234,8 @@ fwupd_security_attr_to_json(FwupdSecurityAttr *self, JsonBuilder *builder)
FWUPD_RESULT_KEY_HSI_RESULT_FALLBACK, FWUPD_RESULT_KEY_HSI_RESULT_FALLBACK,
fwupd_security_attr_result_to_string(priv->result_fallback)); fwupd_security_attr_result_to_string(priv->result_fallback));
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_NAME, priv->name); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_NAME, priv->name);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SUMMARY, priv->title);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_DESCRIPTION, priv->description);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PLUGIN, priv->plugin); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PLUGIN, priv->plugin);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_URI, priv->url); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_URI, priv->url);
if (priv->flags != FWUPD_SECURITY_ATTR_FLAG_NONE) { if (priv->flags != FWUPD_SECURITY_ATTR_FLAG_NONE) {
@ -1188,6 +1316,8 @@ fwupd_security_attr_to_string(FwupdSecurityAttr *self)
if (priv->flags != FWUPD_SECURITY_ATTR_FLAG_NONE) if (priv->flags != FWUPD_SECURITY_ATTR_FLAG_NONE)
fwupd_pad_kv_tfl(str, FWUPD_RESULT_KEY_FLAGS, priv->flags); fwupd_pad_kv_tfl(str, FWUPD_RESULT_KEY_FLAGS, priv->flags);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_NAME, priv->name); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_NAME, priv->name);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_SUMMARY, priv->title);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_DESCRIPTION, priv->description);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_PLUGIN, priv->plugin); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_PLUGIN, priv->plugin);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_URI, priv->url); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_URI, priv->url);
for (guint i = 0; i < priv->obsoletes->len; i++) { for (guint i = 0; i < priv->obsoletes->len; i++) {
@ -1236,6 +1366,8 @@ fwupd_security_attr_finalize(GObject *object)
g_hash_table_unref(priv->metadata); g_hash_table_unref(priv->metadata);
g_free(priv->appstream_id); g_free(priv->appstream_id);
g_free(priv->name); g_free(priv->name);
g_free(priv->title);
g_free(priv->description);
g_free(priv->plugin); g_free(priv->plugin);
g_free(priv->url); g_free(priv->url);
g_ptr_array_unref(priv->obsoletes); g_ptr_array_unref(priv->obsoletes);
@ -1342,6 +1474,8 @@ fwupd_security_attr_copy(FwupdSecurityAttr *self)
fwupd_security_attr_set_appstream_id(new, priv->appstream_id); fwupd_security_attr_set_appstream_id(new, priv->appstream_id);
fwupd_security_attr_set_name(new, priv->name); fwupd_security_attr_set_name(new, priv->name);
fwupd_security_attr_set_title(new, priv->title);
fwupd_security_attr_set_description(new, priv->description);
fwupd_security_attr_set_plugin(new, priv->plugin); fwupd_security_attr_set_plugin(new, priv->plugin);
fwupd_security_attr_set_url(new, priv->url); fwupd_security_attr_set_url(new, priv->url);
fwupd_security_attr_set_level(new, priv->level); fwupd_security_attr_set_level(new, priv->level);

View File

@ -137,6 +137,14 @@ fwupd_security_attr_get_name(FwupdSecurityAttr *self);
void void
fwupd_security_attr_set_name(FwupdSecurityAttr *self, const gchar *name); fwupd_security_attr_set_name(FwupdSecurityAttr *self, const gchar *name);
const gchar * const gchar *
fwupd_security_attr_get_title(FwupdSecurityAttr *self);
void
fwupd_security_attr_set_title(FwupdSecurityAttr *self, const gchar *title);
const gchar *
fwupd_security_attr_get_description(FwupdSecurityAttr *self);
void
fwupd_security_attr_set_description(FwupdSecurityAttr *self, const gchar *description);
const gchar *
fwupd_security_attr_get_plugin(FwupdSecurityAttr *self); fwupd_security_attr_get_plugin(FwupdSecurityAttr *self);
void void
fwupd_security_attr_set_plugin(FwupdSecurityAttr *self, const gchar *plugin); fwupd_security_attr_set_plugin(FwupdSecurityAttr *self, const gchar *plugin);

View File

@ -6,7 +6,7 @@
#include "config.h" #include "config.h"
#include <glib-object.h> #include <locale.h>
#include <string.h> #include <string.h>
#ifdef HAVE_FNMATCH_H #ifdef HAVE_FNMATCH_H
#include <fnmatch.h> #include <fnmatch.h>
@ -18,6 +18,7 @@
#include "fwupd-device-private.h" #include "fwupd-device-private.h"
#include "fwupd-enums.h" #include "fwupd-enums.h"
#include "fwupd-error.h" #include "fwupd-error.h"
#include "fwupd-plugin-private.h"
#include "fwupd-release-private.h" #include "fwupd-release-private.h"
#include "fwupd-remote-private.h" #include "fwupd-remote-private.h"
#include "fwupd-request-private.h" #include "fwupd-request-private.h"
@ -147,26 +148,55 @@ fwupd_enums_func(void)
g_assert_cmpstr(tmp, !=, NULL); g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_version_format_from_string(tmp), ==, i); g_assert_cmpint(fwupd_version_format_from_string(tmp), ==, i);
} }
for (guint i = 1; i < FWUPD_REMOTE_KIND_LAST; i++) {
const gchar *tmp = fwupd_remote_kind_to_string(i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_remote_kind_from_string(tmp), ==, i);
}
/* bitfield */ /* bitfield */
for (guint64 i = 1; i < FWUPD_DEVICE_FLAG_UNKNOWN; i *= 2) { for (guint64 i = 1; i <= FWUPD_DEVICE_FLAG_UNSIGNED_PAYLOAD; i *= 2) {
const gchar *tmp = fwupd_device_flag_to_string(i); const gchar *tmp = fwupd_device_flag_to_string(i);
if (tmp == NULL) if (tmp == NULL)
break; g_warning("missing device flag 0x%x", (guint)i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_device_flag_from_string(tmp), ==, i); g_assert_cmpint(fwupd_device_flag_from_string(tmp), ==, i);
} }
for (guint64 i = 1; i < FWUPD_DEVICE_PROBLEM_UNKNOWN; i *= 2) { for (guint64 i = 1; i <= FWUPD_DEVICE_PROBLEM_LID_IS_CLOSED; i *= 2) {
const gchar *tmp = fwupd_device_problem_to_string(i); const gchar *tmp = fwupd_device_problem_to_string(i);
if (tmp == NULL) if (tmp == NULL)
break; g_warning("missing device problem 0x%x", (guint)i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_device_problem_from_string(tmp), ==, i); g_assert_cmpint(fwupd_device_problem_from_string(tmp), ==, i);
} }
for (guint64 i = 1; i < FWUPD_PLUGIN_FLAG_UNKNOWN; i *= 2) { for (guint64 i = 1; i <= FWUPD_PLUGIN_FLAG_AUTH_REQUIRED; i *= 2) {
const gchar *tmp = fwupd_plugin_flag_to_string(i); const gchar *tmp = fwupd_plugin_flag_to_string(i);
if (tmp == NULL) if (tmp == NULL)
break; g_warning("missing plugin flag 0x%x", (guint)i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_plugin_flag_from_string(tmp), ==, i); g_assert_cmpint(fwupd_plugin_flag_from_string(tmp), ==, i);
} }
for (guint64 i = 1; i <= FWUPD_FEATURE_FLAG_SHOW_PROBLEMS; i *= 2) {
const gchar *tmp = fwupd_feature_flag_to_string(i);
if (tmp == NULL)
g_warning("missing feature flag 0x%x", (guint)i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_feature_flag_from_string(tmp), ==, i);
}
for (guint64 i = 1; i <= FWUPD_RELEASE_FLAG_IS_COMMUNITY; i *= 2) {
const gchar *tmp = fwupd_release_flag_to_string(i);
if (tmp == NULL)
g_warning("missing release flag 0x%x", (guint)i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_release_flag_from_string(tmp), ==, i);
}
for (guint i = 1; i < FWUPD_KEYRING_KIND_LAST; i++) {
const gchar *tmp = fwupd_keyring_kind_to_string(i);
if (tmp == NULL)
g_warning("missing keyring kind 0x%x", (guint)i);
g_assert_cmpstr(tmp, !=, NULL);
g_assert_cmpint(fwupd_keyring_kind_from_string(tmp), ==, i);
}
} }
static void static void
@ -236,6 +266,8 @@ fwupd_remote_baseuri_func(void)
g_assert_cmpint(fwupd_remote_get_keyring_kind(remote), ==, FWUPD_KEYRING_KIND_JCAT); g_assert_cmpint(fwupd_remote_get_keyring_kind(remote), ==, FWUPD_KEYRING_KIND_JCAT);
g_assert_cmpint(fwupd_remote_get_priority(remote), ==, 0); g_assert_cmpint(fwupd_remote_get_priority(remote), ==, 0);
g_assert_true(fwupd_remote_get_enabled(remote)); g_assert_true(fwupd_remote_get_enabled(remote));
g_assert_cmpstr(fwupd_remote_get_firmware_base_uri(remote), ==, "https://my.fancy.cdn/");
g_assert_cmpstr(fwupd_remote_get_agreement(remote), ==, NULL);
g_assert_cmpstr(fwupd_remote_get_checksum(remote), ==, NULL); g_assert_cmpstr(fwupd_remote_get_checksum(remote), ==, NULL);
g_assert_cmpstr(fwupd_remote_get_metadata_uri(remote), g_assert_cmpstr(fwupd_remote_get_metadata_uri(remote),
==, ==,
@ -249,6 +281,136 @@ fwupd_remote_baseuri_func(void)
g_assert_cmpstr(firmware_uri, ==, "https://my.fancy.cdn/firmware.cab"); g_assert_cmpstr(firmware_uri, ==, "https://my.fancy.cdn/firmware.cab");
} }
static gchar *
fwupd_remote_to_json_string(FwupdRemote *remote, GError **error)
{
g_autofree gchar *data = NULL;
g_autoptr(JsonGenerator) json_generator = NULL;
g_autoptr(JsonBuilder) builder = json_builder_new();
g_autoptr(JsonNode) json_root = NULL;
json_builder_begin_object(builder);
fwupd_remote_to_json(remote, builder);
json_builder_end_object(builder);
json_root = json_builder_get_root(builder);
json_generator = json_generator_new();
json_generator_set_pretty(json_generator, TRUE);
json_generator_set_root(json_generator, json_root);
data = json_generator_to_data(json_generator, NULL);
if (data == NULL) {
g_set_error(error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"Failed to convert remote to json.");
return NULL;
}
return g_steal_pointer(&data);
}
static void
fwupd_remote_auth_func(void)
{
gboolean ret;
gchar **order;
g_autofree gchar *fn = NULL;
g_autofree gchar *remotes_dir = NULL;
g_autofree gchar *json = NULL;
g_autoptr(FwupdRemote) remote = fwupd_remote_new();
g_autoptr(FwupdRemote) remote2 = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GVariant) data = NULL;
remotes_dir = g_test_build_filename(G_TEST_BUILT, "tests", NULL);
fwupd_remote_set_remotes_dir(remote, remotes_dir);
fn = g_test_build_filename(G_TEST_DIST, "tests", "auth.conf", NULL);
ret = fwupd_remote_load_from_filename(remote, fn, NULL, &error);
g_assert_no_error(error);
g_assert_true(ret);
g_assert_cmpstr(fwupd_remote_get_username(remote), ==, "user");
g_assert_cmpstr(fwupd_remote_get_password(remote), ==, "pass");
g_assert_cmpstr(fwupd_remote_get_security_report_uri(remote),
==,
"https://fwupd.org/lvfs/hsireports/upload");
g_assert_false(fwupd_remote_get_approval_required(remote));
g_assert_false(fwupd_remote_get_automatic_reports(remote));
g_assert_true(fwupd_remote_get_automatic_security_reports(remote));
g_assert_true(
g_str_has_suffix(fwupd_remote_get_filename_source(remote), "tests/auth.conf"));
g_assert_true(g_str_has_suffix(fwupd_remote_get_remotes_dir(remote), "/libfwupd/tests"));
g_assert_cmpint(fwupd_remote_get_age(remote), >, 1000000);
ret = fwupd_remote_setup(remote, &error);
g_assert_no_error(error);
g_assert_true(ret);
order = fwupd_remote_get_order_before(remote);
g_assert_nonnull(order);
g_assert_cmpint(g_strv_length(order), ==, 1);
g_assert_cmpstr(order[0], ==, "before");
order = fwupd_remote_get_order_after(remote);
g_assert_nonnull(order);
g_assert_cmpint(g_strv_length(order), ==, 1);
g_assert_cmpstr(order[0], ==, "after");
/* to/from GVariant */
fwupd_remote_set_priority(remote, 999);
data = fwupd_remote_to_variant(remote);
remote2 = fwupd_remote_from_variant(data);
g_assert_cmpstr(fwupd_remote_get_username(remote2), ==, "user");
g_assert_cmpint(fwupd_remote_get_priority(remote2), ==, 999);
/* jcat-tool is not a hard dep, and the tests create an empty file if unfound */
ret = fwupd_remote_load_signature(remote,
fwupd_remote_get_filename_cache_sig(remote),
&error);
if (!ret) {
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT)) {
g_test_skip("no jcat-tool, so skipping test");
return;
}
}
g_assert_no_error(error);
g_assert_true(ret);
/* to JSON */
fwupd_remote_set_filename_source(remote2, NULL);
fwupd_remote_set_checksum(
remote2,
"dd1b4fd2a59bb0e4d9ea760c658ac3cf9336c7b6729357bab443485b5cf071b2");
fwupd_remote_set_filename_cache(remote2, "./libfwupd/tests/auth/metadata.xml.gz");
json = fwupd_remote_to_json_string(remote2, &error);
g_assert_no_error(error);
g_assert_nonnull(json);
ret = fu_test_compare_lines(
json,
"{\n"
" \"Id\" : \"auth\",\n"
" \"Kind\" : \"download\",\n"
" \"KeyringKind\" : \"jcat\",\n"
" \"FirmwareBaseUri\" : \"https://my.fancy.cdn/\",\n"
" \"ReportUri\" : \"https://fwupd.org/lvfs/firmware/report\",\n"
" \"SecurityReportUri\" : \"https://fwupd.org/lvfs/hsireports/upload\",\n"
" \"MetadataUri\" : \"https://cdn.fwupd.org/downloads/firmware.xml.gz\",\n"
" \"MetadataUriSig\" : \"https://cdn.fwupd.org/downloads/firmware.xml.gz.jcat\",\n"
" \"Username\" : \"user\",\n"
" \"Password\" : \"pass\",\n"
" \"Checksum\" : "
"\"dd1b4fd2a59bb0e4d9ea760c658ac3cf9336c7b6729357bab443485b5cf071b2\",\n"
" \"FilenameCache\" : \"./libfwupd/tests/auth/metadata.xml.gz\",\n"
" \"FilenameCacheSig\" : \"./libfwupd/tests/auth/metadata.xml.gz.jcat\",\n"
" \"Enabled\" : \"true\",\n"
" \"ApprovalRequired\" : \"false\",\n"
" \"AutomaticReports\" : \"false\",\n"
" \"AutomaticSecurityReports\" : \"true\",\n"
" \"Priority\" : 999,\n"
" \"Mtime\" : 0\n"
"}",
&error);
g_assert_no_error(error);
g_assert_true(ret);
}
static void static void
fwupd_remote_duplicate_func(void) fwupd_remote_duplicate_func(void)
{ {
@ -322,8 +484,11 @@ fwupd_remote_local_func(void)
{ {
gboolean ret; gboolean ret;
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
g_autofree gchar *json = NULL;
g_autoptr(FwupdRemote) remote = NULL; g_autoptr(FwupdRemote) remote = NULL;
g_autoptr(FwupdRemote) remote2 = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(GVariant) data = NULL;
remote = fwupd_remote_new(); remote = fwupd_remote_new();
fn = g_test_build_filename(G_TEST_DIST, "tests", "dell-esrt.conf", NULL); fn = g_test_build_filename(G_TEST_DIST, "tests", "dell-esrt.conf", NULL);
@ -344,22 +509,238 @@ fwupd_remote_local_func(void)
"@datadir@/fwupd/remotes.d/dell-esrt/metadata.xml"); "@datadir@/fwupd/remotes.d/dell-esrt/metadata.xml");
g_assert_cmpstr(fwupd_remote_get_filename_cache_sig(remote), ==, NULL); g_assert_cmpstr(fwupd_remote_get_filename_cache_sig(remote), ==, NULL);
g_assert_cmpstr(fwupd_remote_get_checksum(remote), ==, NULL); g_assert_cmpstr(fwupd_remote_get_checksum(remote), ==, NULL);
/* to/from GVariant */
data = fwupd_remote_to_variant(remote);
remote2 = fwupd_remote_from_variant(data);
g_assert_null(fwupd_remote_get_metadata_uri(remote));
/* to JSON */
fwupd_remote_set_filename_source(remote2, NULL);
json = fwupd_remote_to_json_string(remote2, &error);
g_assert_no_error(error);
g_assert_nonnull(json);
ret = fu_test_compare_lines(
json,
"{\n"
" \"Id\" : \"dell-esrt\",\n"
" \"Kind\" : \"local\",\n"
" \"KeyringKind\" : \"none\",\n"
" \"Title\" : \"Enable UEFI capsule updates on Dell systems\",\n"
" \"FilenameCache\" : \"@datadir@/fwupd/remotes.d/dell-esrt/metadata.xml\",\n"
" \"Enabled\" : \"true\",\n"
" \"ApprovalRequired\" : \"false\",\n"
" \"AutomaticReports\" : \"false\",\n"
" \"AutomaticSecurityReports\" : \"false\",\n"
" \"Priority\" : 0,\n"
" \"Mtime\" : 0\n"
"}",
&error);
g_assert_no_error(error);
g_assert_true(ret);
}
static gchar *
fwupd_release_to_json_string(FwupdRelease *release, GError **error)
{
g_autofree gchar *data = NULL;
g_autoptr(JsonGenerator) json_generator = NULL;
g_autoptr(JsonBuilder) builder = json_builder_new();
g_autoptr(JsonNode) json_root = NULL;
json_builder_begin_object(builder);
fwupd_release_to_json(release, builder);
json_builder_end_object(builder);
json_root = json_builder_get_root(builder);
json_generator = json_generator_new();
json_generator_set_pretty(json_generator, TRUE);
json_generator_set_root(json_generator, json_root);
data = json_generator_to_data(json_generator, NULL);
if (data == NULL) {
g_set_error(error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"Failed to convert release to json.");
return NULL;
}
return g_steal_pointer(&data);
} }
static void static void
fwupd_release_func(void) fwupd_release_func(void)
{ {
gboolean ret;
g_autofree gchar *json1 = NULL;
g_autofree gchar *json2 = NULL;
g_autofree gchar *str = NULL;
g_autoptr(FwupdRelease) release1 = NULL; g_autoptr(FwupdRelease) release1 = NULL;
g_autoptr(FwupdRelease) release2 = NULL; g_autoptr(FwupdRelease) release2 = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GVariant) data = NULL; g_autoptr(GVariant) data = NULL;
release1 = fwupd_release_new(); release1 = fwupd_release_new();
fwupd_release_add_metadata_item(release1, "foo", "bar"); fwupd_release_add_metadata_item(release1, "foo", "bar");
fwupd_release_add_metadata_item(release1, "baz", "bam"); fwupd_release_add_metadata_item(release1, "baz", "bam");
fwupd_release_set_remote_id(release1, "remote-id");
fwupd_release_set_appstream_id(release1, "appstream-id");
fwupd_release_set_id(release1, "id");
fwupd_release_set_detach_caption(release1, "detach_caption");
fwupd_release_set_detach_image(release1, "detach_image");
fwupd_release_set_update_message(release1, "update_message");
fwupd_release_set_update_image(release1, "update_image");
fwupd_release_set_filename(release1, "filename");
fwupd_release_set_protocol(release1, "protocol");
fwupd_release_set_license(release1, "license");
fwupd_release_set_name(release1, "name");
fwupd_release_set_name_variant_suffix(release1, "name_variant_suffix");
fwupd_release_set_summary(release1, "summary");
fwupd_release_set_branch(release1, "branch");
fwupd_release_set_description(release1, "description");
fwupd_release_set_homepage(release1, "homepage");
fwupd_release_set_details_url(release1, "details_url");
fwupd_release_set_source_url(release1, "source_url");
fwupd_release_set_version(release1, "version");
fwupd_release_set_vendor(release1, "vendor");
fwupd_release_set_size(release1, 1234);
fwupd_release_set_created(release1, 5678);
fwupd_release_set_install_duration(release1, 2468);
fwupd_release_add_category(release1, "category");
fwupd_release_add_category(release1, "category");
fwupd_release_add_issue(release1, "issue");
fwupd_release_add_issue(release1, "issue");
fwupd_release_add_location(release1, "location");
fwupd_release_add_location(release1, "location");
fwupd_release_add_tag(release1, "tag");
fwupd_release_add_tag(release1, "tag");
fwupd_release_add_checksum(release1, "checksum");
fwupd_release_add_checksum(release1, "checksum");
fwupd_release_add_flag(release1, FWUPD_RELEASE_FLAG_IS_UPGRADE);
fwupd_release_add_flag(release1, FWUPD_RELEASE_FLAG_IS_UPGRADE);
fwupd_release_add_flag(release1, FWUPD_RELEASE_FLAG_BLOCKED_APPROVAL);
fwupd_release_remove_flag(release1, FWUPD_RELEASE_FLAG_BLOCKED_APPROVAL);
fwupd_release_set_urgency(release1, FWUPD_RELEASE_URGENCY_MEDIUM);
data = fwupd_release_to_variant(release1); data = fwupd_release_to_variant(release1);
release2 = fwupd_release_from_variant(data); release2 = fwupd_release_from_variant(data);
g_assert_cmpstr(fwupd_release_get_metadata_item(release2, "foo"), ==, "bar"); g_assert_cmpstr(fwupd_release_get_metadata_item(release2, "foo"), ==, "bar");
g_assert_cmpstr(fwupd_release_get_metadata_item(release2, "baz"), ==, "bam"); g_assert_cmpstr(fwupd_release_get_metadata_item(release2, "baz"), ==, "bam");
g_assert_cmpstr(fwupd_release_get_remote_id(release2), ==, "remote-id");
g_assert_cmpstr(fwupd_release_get_appstream_id(release2), ==, "appstream-id");
g_assert_cmpstr(fwupd_release_get_id(release2), ==, "id");
g_assert_cmpstr(fwupd_release_get_detach_caption(release2), ==, "detach_caption");
g_assert_cmpstr(fwupd_release_get_detach_image(release2), ==, "detach_image");
g_assert_cmpstr(fwupd_release_get_update_message(release2), ==, "update_message");
g_assert_cmpstr(fwupd_release_get_update_image(release2), ==, "update_image");
g_assert_cmpstr(fwupd_release_get_filename(release2), ==, "filename");
g_assert_cmpstr(fwupd_release_get_protocol(release2), ==, "protocol");
g_assert_cmpstr(fwupd_release_get_license(release2), ==, "license");
g_assert_cmpstr(fwupd_release_get_name(release2), ==, "name");
g_assert_cmpstr(fwupd_release_get_name_variant_suffix(release2), ==, "name_variant_suffix");
g_assert_cmpstr(fwupd_release_get_summary(release2), ==, "summary");
g_assert_cmpstr(fwupd_release_get_branch(release2), ==, "branch");
g_assert_cmpstr(fwupd_release_get_description(release2), ==, "description");
g_assert_cmpstr(fwupd_release_get_homepage(release2), ==, "homepage");
g_assert_cmpstr(fwupd_release_get_details_url(release2), ==, "details_url");
g_assert_cmpstr(fwupd_release_get_source_url(release2), ==, "source_url");
g_assert_cmpstr(fwupd_release_get_version(release2), ==, "version");
g_assert_cmpstr(fwupd_release_get_vendor(release2), ==, "vendor");
g_assert_cmpint(fwupd_release_get_size(release2), ==, 1234);
g_assert_cmpint(fwupd_release_get_created(release2), ==, 5678);
g_assert_true(fwupd_release_has_category(release2, "category"));
g_assert_true(fwupd_release_has_tag(release2, "tag"));
g_assert_true(fwupd_release_has_checksum(release2, "checksum"));
g_assert_true(fwupd_release_has_flag(release2, FWUPD_RELEASE_FLAG_IS_UPGRADE));
g_assert_false(fwupd_release_has_flag(release2, FWUPD_RELEASE_FLAG_IS_COMMUNITY));
g_assert_cmpint(fwupd_release_get_issues(release2)->len, ==, 1);
g_assert_cmpint(fwupd_release_get_locations(release2)->len, ==, 1);
g_assert_cmpint(fwupd_release_get_categories(release2)->len, ==, 1);
g_assert_cmpint(fwupd_release_get_tags(release2)->len, ==, 1);
g_assert_cmpint(fwupd_release_get_checksums(release2)->len, ==, 1);
g_assert_cmpint(fwupd_release_get_urgency(release2), ==, FWUPD_RELEASE_URGENCY_MEDIUM);
g_assert_cmpint(fwupd_release_get_install_duration(release2), ==, 2468);
/* to JSON */
json1 = fwupd_release_to_json_string(release1, &error);
g_assert_no_error(error);
g_assert_nonnull(json1);
json2 = fwupd_release_to_json_string(release2, &error);
g_assert_no_error(error);
g_assert_nonnull(json2);
ret = fu_test_compare_lines(json1, json2, &error);
g_assert_no_error(error);
g_assert_true(ret);
/* to string */
str = fwupd_release_to_string(release2);
ret = fu_test_compare_lines(str,
" AppstreamId: appstream-id\n"
" ReleaseId: id\n"
" RemoteId: remote-id\n"
" Summary: summary\n"
" Description: description\n"
" Branch: branch\n"
" Version: version\n"
" Filename: filename\n"
" Protocol: protocol\n"
" Categories: category\n"
" Issues: issue\n"
" Checksum: SHA1(checksum)\n"
" Tags: tag\n"
" License: license\n"
" Size: 1.2 kB\n"
" Created: 1970-01-01\n"
" Uri: location\n"
" Homepage: homepage\n"
" DetailsUrl: details_url\n"
" SourceUrl: source_url\n"
" Urgency: medium\n"
" Vendor: vendor\n"
" Flags: is-upgrade\n"
" InstallDuration: 2468\n"
" DetachCaption: detach_caption\n"
" DetachImage: detach_image\n"
" UpdateMessage: update_message\n"
" UpdateImage: update_image\n"
" foo: bar\n"
" baz: bam\n",
&error);
g_assert_no_error(error);
g_assert_true(ret);
}
static void
fwupd_plugin_func(void)
{
gboolean ret;
g_autofree gchar *str = NULL;
g_autoptr(FwupdPlugin) plugin1 = NULL;
g_autoptr(FwupdPlugin) plugin2 = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GVariant) data = NULL;
plugin1 = fwupd_plugin_new();
fwupd_plugin_set_name(plugin1, "foo");
fwupd_plugin_set_flags(plugin1, FWUPD_PLUGIN_FLAG_USER_WARNING);
fwupd_plugin_add_flag(plugin1, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE);
fwupd_plugin_add_flag(plugin1, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE);
fwupd_plugin_add_flag(plugin1, FWUPD_PLUGIN_FLAG_NO_HARDWARE);
fwupd_plugin_remove_flag(plugin1, FWUPD_PLUGIN_FLAG_NO_HARDWARE);
fwupd_plugin_remove_flag(plugin1, FWUPD_PLUGIN_FLAG_NO_HARDWARE);
data = fwupd_plugin_to_variant(plugin1);
plugin2 = fwupd_plugin_from_variant(data);
g_assert_cmpstr(fwupd_plugin_get_name(plugin2), ==, "foo");
g_assert_cmpint(fwupd_plugin_get_flags(plugin2),
==,
FWUPD_PLUGIN_FLAG_USER_WARNING | FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE);
g_assert_true(fwupd_plugin_has_flag(plugin2, FWUPD_PLUGIN_FLAG_USER_WARNING));
g_assert_true(fwupd_plugin_has_flag(plugin2, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE));
g_assert_false(fwupd_plugin_has_flag(plugin2, FWUPD_PLUGIN_FLAG_NO_HARDWARE));
str = fwupd_plugin_to_string(plugin2);
ret = fu_test_compare_lines(str,
" Name: foo\n"
" Flags: user-warning|clear-updatable\n",
&error);
g_assert_no_error(error);
g_assert_true(ret);
} }
static void static void
@ -375,6 +756,7 @@ fwupd_request_func(void)
fwupd_request_set_id(request, FWUPD_REQUEST_ID_REMOVE_REPLUG); fwupd_request_set_id(request, FWUPD_REQUEST_ID_REMOVE_REPLUG);
fwupd_request_set_message(request, "foo"); fwupd_request_set_message(request, "foo");
fwupd_request_set_image(request, "bar"); fwupd_request_set_image(request, "bar");
fwupd_request_set_device_id(request, "950da62d4c753a26e64f7f7d687104ce38e32ca5");
str = fwupd_request_to_string(request); str = fwupd_request_to_string(request);
g_debug("%s", str); g_debug("%s", str);
@ -389,6 +771,9 @@ fwupd_request_func(void)
g_assert_cmpstr(fwupd_request_get_id(request2), ==, FWUPD_REQUEST_ID_REMOVE_REPLUG); g_assert_cmpstr(fwupd_request_get_id(request2), ==, FWUPD_REQUEST_ID_REMOVE_REPLUG);
g_assert_cmpstr(fwupd_request_get_message(request2), ==, "foo"); g_assert_cmpstr(fwupd_request_get_message(request2), ==, "foo");
g_assert_cmpstr(fwupd_request_get_image(request2), ==, "bar"); g_assert_cmpstr(fwupd_request_get_image(request2), ==, "bar");
g_assert_cmpstr(fwupd_request_get_device_id(request2),
==,
"950da62d4c753a26e64f7f7d687104ce38e32ca5");
} }
static void static void
@ -398,6 +783,7 @@ fwupd_device_func(void)
g_autofree gchar *data = NULL; g_autofree gchar *data = NULL;
g_autofree gchar *str = NULL; g_autofree gchar *str = NULL;
g_autoptr(FwupdDevice) dev = NULL; g_autoptr(FwupdDevice) dev = NULL;
g_autoptr(FwupdDevice) dev_new = fwupd_device_new();
g_autoptr(FwupdRelease) rel = NULL; g_autoptr(FwupdRelease) rel = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(GString) str_ascii = NULL; g_autoptr(GString) str_ascii = NULL;
@ -415,8 +801,11 @@ fwupd_device_func(void)
fwupd_device_set_name(dev, "ColorHug2"); fwupd_device_set_name(dev, "ColorHug2");
fwupd_device_add_guid(dev, "2082b5e0-7a64-478a-b1b2-e3404fab6dad"); fwupd_device_add_guid(dev, "2082b5e0-7a64-478a-b1b2-e3404fab6dad");
fwupd_device_add_guid(dev, "00000000-0000-0000-0000-000000000000"); fwupd_device_add_guid(dev, "00000000-0000-0000-0000-000000000000");
fwupd_device_add_instance_id(dev, "USB\\VID_1234&PID_0001");
fwupd_device_add_icon(dev, "input-gaming"); fwupd_device_add_icon(dev, "input-gaming");
fwupd_device_add_icon(dev, "input-mouse"); fwupd_device_add_icon(dev, "input-mouse");
fwupd_device_add_vendor_id(dev, "USB:0x1234");
fwupd_device_add_vendor_id(dev, "PCI:0x5678");
fwupd_device_add_flag(dev, FWUPD_DEVICE_FLAG_UPDATABLE | FWUPD_DEVICE_FLAG_REQUIRE_AC); fwupd_device_add_flag(dev, FWUPD_DEVICE_FLAG_UPDATABLE | FWUPD_DEVICE_FLAG_REQUIRE_AC);
g_assert_true(fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_REQUIRE_AC)); g_assert_true(fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_REQUIRE_AC));
g_assert_true(fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_UPDATABLE)); g_assert_true(fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_UPDATABLE));
@ -450,10 +839,14 @@ fwupd_device_func(void)
"FwupdDevice:\n" "FwupdDevice:\n"
" DeviceId: USB:foo\n" " DeviceId: USB:foo\n"
" Name: ColorHug2\n" " Name: ColorHug2\n"
" Guid: 18f514d2-c12e-581f-a696-cc6d6c271699 "
"← USB\\VID_1234&PID_0001 ⚠\n"
" Guid: 2082b5e0-7a64-478a-b1b2-e3404fab6dad\n" " Guid: 2082b5e0-7a64-478a-b1b2-e3404fab6dad\n"
" Guid: 00000000-0000-0000-0000-000000000000\n" " Guid: 00000000-0000-0000-0000-000000000000\n"
" Flags: updatable|require-ac\n" " Flags: updatable|require-ac\n"
" Checksum: SHA1(beefdead)\n" " Checksum: SHA1(beefdead)\n"
" VendorId: USB:0x1234\n"
" VendorId: PCI:0x5678\n"
" Icon: input-gaming,input-mouse\n" " Icon: input-gaming,input-mouse\n"
" Created: 1970-01-01\n" " Created: 1970-01-01\n"
" Modified: 1970-01-02\n" " Modified: 1970-01-02\n"
@ -477,7 +870,7 @@ fwupd_device_func(void)
/* export to json */ /* export to json */
builder = json_builder_new(); builder = json_builder_new();
json_builder_begin_object(builder); json_builder_begin_object(builder);
fwupd_device_to_json(dev, builder); fwupd_device_to_json_full(dev, builder, FWUPD_DEVICE_FLAG_TRUSTED);
json_builder_end_object(builder); json_builder_end_object(builder);
json_root = json_builder_get_root(builder); json_root = json_builder_get_root(builder);
json_generator = json_generator_new(); json_generator = json_generator_new();
@ -489,6 +882,9 @@ fwupd_device_func(void)
"{\n" "{\n"
" \"Name\" : \"ColorHug2\",\n" " \"Name\" : \"ColorHug2\",\n"
" \"DeviceId\" : \"USB:foo\",\n" " \"DeviceId\" : \"USB:foo\",\n"
" \"InstanceIds\" : [\n"
" \"USB\\\\VID_1234&PID_0001\"\n"
" ],\n"
" \"Guid\" : [\n" " \"Guid\" : [\n"
" \"2082b5e0-7a64-478a-b1b2-e3404fab6dad\",\n" " \"2082b5e0-7a64-478a-b1b2-e3404fab6dad\",\n"
" \"00000000-0000-0000-0000-000000000000\"\n" " \"00000000-0000-0000-0000-000000000000\"\n"
@ -500,6 +896,11 @@ fwupd_device_func(void)
" \"Checksums\" : [\n" " \"Checksums\" : [\n"
" \"beefdead\"\n" " \"beefdead\"\n"
" ],\n" " ],\n"
" \"VendorId\" : \"USB:0x1234|PCI:0x5678\",\n"
" \"VendorIds\" : [\n"
" \"USB:0x1234\",\n"
" \"PCI:0x5678\"\n"
" ],\n"
" \"Icons\" : [\n" " \"Icons\" : [\n"
" \"input-gaming\",\n" " \"input-gaming\",\n"
" \"input-mouse\"\n" " \"input-mouse\"\n"
@ -534,6 +935,12 @@ fwupd_device_func(void)
&error); &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
/* incorporate */
fwupd_device_incorporate(dev_new, dev);
g_assert_true(fwupd_device_has_vendor_id(dev_new, "USB:0x1234"));
g_assert_true(fwupd_device_has_vendor_id(dev_new, "PCI:0x5678"));
g_assert_true(fwupd_device_has_instance_id(dev_new, "USB\\VID_1234&PID_0001"));
} }
static void static void
@ -806,10 +1213,13 @@ fwupd_security_attr_func(void)
gboolean ret; gboolean ret;
g_autofree gchar *str1 = NULL; g_autofree gchar *str1 = NULL;
g_autofree gchar *str2 = NULL; g_autofree gchar *str2 = NULL;
g_autofree gchar *str3 = NULL;
g_autofree gchar *json = NULL; g_autofree gchar *json = NULL;
g_autoptr(FwupdSecurityAttr) attr1 = fwupd_security_attr_new("org.fwupd.hsi.bar"); g_autoptr(FwupdSecurityAttr) attr1 = fwupd_security_attr_new("org.fwupd.hsi.bar");
g_autoptr(FwupdSecurityAttr) attr2 = fwupd_security_attr_new(NULL); g_autoptr(FwupdSecurityAttr) attr2 = fwupd_security_attr_new(NULL);
g_autoptr(FwupdSecurityAttr) attr3 = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(GVariant) data = NULL;
g_autoptr(JsonParser) parser = json_parser_new(); g_autoptr(JsonParser) parser = json_parser_new();
for (guint i = 1; i < FWUPD_SECURITY_ATTR_RESULT_LAST; i++) { for (guint i = 1; i < FWUPD_SECURITY_ATTR_RESULT_LAST; i++) {
@ -870,6 +1280,25 @@ fwupd_security_attr_func(void)
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
/* roundtrip GVariant */
data = fwupd_security_attr_to_variant(attr1);
attr3 = fwupd_security_attr_from_variant(data);
fwupd_security_attr_set_created(attr3, 0);
str3 = fwupd_security_attr_to_string(attr3);
ret = fu_test_compare_lines(str3,
" AppstreamId: org.fwupd.hsi.baz\n"
" HsiLevel: 2\n"
" HsiResult: enabled\n"
" Flags: success\n"
" Name: DCI\n"
" Plugin: uefi-capsule\n"
" Uri: https://foo.bar\n"
" Guid: af3fc12c-d090-5783-8a67-845b90d3cfec\n"
" KEY: VALUE\n",
&error);
g_assert_no_error(error);
g_assert_true(ret);
/* to JSON */ /* to JSON */
json = fwupd_security_attr_to_json_string(attr1, &error); json = fwupd_security_attr_to_json_string(attr1, &error);
g_assert_no_error(error); g_assert_no_error(error);
@ -918,6 +1347,7 @@ fwupd_security_attr_func(void)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
setlocale(LC_ALL, "");
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
/* only critical and error are fatal */ /* only critical and error are fatal */
@ -930,6 +1360,7 @@ main(int argc, char **argv)
g_test_add_func("/fwupd/common{device-id}", fwupd_common_device_id_func); g_test_add_func("/fwupd/common{device-id}", fwupd_common_device_id_func);
g_test_add_func("/fwupd/common{guid}", fwupd_common_guid_func); g_test_add_func("/fwupd/common{guid}", fwupd_common_guid_func);
g_test_add_func("/fwupd/release", fwupd_release_func); g_test_add_func("/fwupd/release", fwupd_release_func);
g_test_add_func("/fwupd/plugin", fwupd_plugin_func);
g_test_add_func("/fwupd/request", fwupd_request_func); g_test_add_func("/fwupd/request", fwupd_request_func);
g_test_add_func("/fwupd/device", fwupd_device_func); g_test_add_func("/fwupd/device", fwupd_device_func);
g_test_add_func("/fwupd/security-attr", fwupd_security_attr_func); g_test_add_func("/fwupd/security-attr", fwupd_security_attr_func);
@ -938,6 +1369,7 @@ main(int argc, char **argv)
g_test_add_func("/fwupd/remote{no-path}", fwupd_remote_nopath_func); g_test_add_func("/fwupd/remote{no-path}", fwupd_remote_nopath_func);
g_test_add_func("/fwupd/remote{local}", fwupd_remote_local_func); g_test_add_func("/fwupd/remote{local}", fwupd_remote_local_func);
g_test_add_func("/fwupd/remote{duplicate}", fwupd_remote_duplicate_func); g_test_add_func("/fwupd/remote{duplicate}", fwupd_remote_duplicate_func);
g_test_add_func("/fwupd/remote{auth}", fwupd_remote_auth_func);
if (fwupd_has_system_bus()) { if (fwupd_has_system_bus()) {
g_test_add_func("/fwupd/client{remotes}", fwupd_client_remotes_func); g_test_add_func("/fwupd/client{remotes}", fwupd_client_remotes_func);
g_test_add_func("/fwupd/client{devices}", fwupd_client_devices_func); g_test_add_func("/fwupd/client{devices}", fwupd_client_devices_func);

View File

@ -780,3 +780,16 @@ LIBFWUPD_1.8.1 {
fwupd_device_set_problems; fwupd_device_set_problems;
local: *; local: *;
} LIBFWUPD_1.8.0; } LIBFWUPD_1.8.0;
LIBFWUPD_1.8.2 {
global:
fwupd_client_get_host_vendor;
fwupd_device_to_json_full;
fwupd_remote_set_checksum;
fwupd_remote_set_filename_cache;
fwupd_security_attr_get_description;
fwupd_security_attr_get_title;
fwupd_security_attr_set_description;
fwupd_security_attr_set_title;
local: *;
} LIBFWUPD_1.8.1;

View File

@ -1,3 +1,7 @@
if get_option('tests')
subdir('tests')
endif
fwupd_version_h = configure_file( fwupd_version_h = configure_file(
input: 'fwupd-version.h.in', input: 'fwupd-version.h.in',
output: 'fwupd-version.h', output: 'fwupd-version.h',
@ -180,6 +184,7 @@ if get_option('tests')
env.set('G_TEST_BUILDDIR', meson.current_build_dir()) env.set('G_TEST_BUILDDIR', meson.current_build_dir())
e = executable( e = executable(
'fwupd-self-test', 'fwupd-self-test',
metadata_xml_gz_jcat,
sources: [ sources: [
'fwupd-self-test.c' 'fwupd-self-test.c'
], ],

11
libfwupd/tests/auth.conf Normal file
View File

@ -0,0 +1,11 @@
[fwupd Remote]
Enabled=true
MetadataURI=https://cdn.fwupd.org/downloads/firmware.xml.gz
ReportURI=https://fwupd.org/lvfs/firmware/report
SecurityReportURI=https://fwupd.org/lvfs/hsireports/upload
AutomaticSecurityReports=true
Username=user
Password=pass
OrderBefore=before
OrderAfter=after
FirmwareBaseURI=https://my.fancy.cdn/

View File

@ -0,0 +1,23 @@
jcat_tool = find_program('jcat-tool', required: false)
if jcat_tool.found()
metadata_xml_gz_jcat = custom_target('metadata-xml-gz-jcat',
input: [
'metadata.xml.gz',
],
output: 'metadata.xml.gz.jcat',
command: [
jcat_tool, '--basename', '--appstream-id', 'localhost', 'self-sign', '@OUTPUT@', '@INPUT@',
],
)
else
metadata_xml_gz_jcat = custom_target('metadata-xml-gz-jcat',
input: [
'metadata.xml.gz',
],
output: 'metadata.xml.gz.jcat',
command: [
'touch', '@OUTPUT@',
],
)
endif

View File

@ -0,0 +1 @@
hello world

View File

@ -0,0 +1 @@
subdir('auth')

View File

@ -4,27 +4,93 @@ This library is only partially API and ABI stable. Keeping unused, unsafe and
deprecated functions around forever is a maintenance burden and so symbols are deprecated functions around forever is a maintenance burden and so symbols are
removed when branching for new minor versions. removed when branching for new minor versions.
Use `./contrib/migrate.py` to migrate up out-of-tree plugins to the new API.
Remember: Plugins should be upstream! Remember: Plugins should be upstream!
## Migrating from older API ## 1.5.5
* Migrate from fu_common_is_cpu_intel() to fu_common_get_cpu_vendor() * `fu_common_is_cpu_intel()`: Use `fu_common_get_cpu_vendor()` instead.
* Migrate from fu_firmware_strparse_uintXX() to fu_firmware_strparse_uintXX_safe() * `fu_firmware_strparse_uintXX()`: Use `fu_firmware_strparse_uintXX_safe()` instead.
* Remove calls to fu_plugin_get_usb_context() and fu_plugin_set_usb_context() * `fu_plugin_get_usb_context()`: Remove, as no longer required.
* Migrate from fu_plugin_runner_usb_device_added(), fu_plugin_runner_udev_device_added() and fu_plugin_runner_udev_device_changed() to fu_plugin_runner_backend_device_added() * `fu_plugin_set_usb_context()`: Remove, as no longer required.
* Migrate from FuHidDevice->open() and FuHidDevice->close() to using the superclass helpers * `fu_plugin_runner_usb_device_added()`: Use `fu_plugin_runner_backend_device_added()` instead.
* Migrate from FuUsbDevice->probe(), FuUsbDevice->open() and FuUsbDevice->close() to using the superclass helpers * `fu_plugin_runner_udev_device_added()`: Use `fu_plugin_runner_backend_device_added()` instead.
* Migrate from FuUdevDevice->to_string(), FuUdevDevice->probe(), FuUdevDevice->open() and FuUdevDevice->close() to using the superclass helpers * `fu_plugin_runner_udev_device_changed()`: Use `fu_plugin_runner_backend_device_added()` instead.
* Migrate from fu_device_get_protocol() to fu_device_get_protocols() and fu_device_set_protocol() to fu_device_add_protocol() * `FuHidDevice->open()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_has_custom_flag() to fu_device_has_private_flag() * `FuHidDevice->close()`: Use the `FuDevice` superclass instead.
* Migrate from fu_udev_device_set_readonly() to fu_udev_device_set_flags() * `FuUsbDevice->probe()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_sleep_with_progress() to fu_progress_sleep() -- but be aware the unit of time has changed from *seconds* to *milliseconds* * `FuUsbDevice->open()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_get_status() to fu_progress_get_status() * `FuUsbDevice->close()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_set_status() to fu_progress_set_status() * `FuUdevDevice->to_string()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_get_progress() to fu_progress_get_percentage() * `FuUdevDevice->probe()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_set_progress_full() to fu_progress_set_percentage_full() * `FuUdevDevice->open()`: Use the `FuDevice` superclass instead.
* Migrate from fu_device_set_progress() to fu_progress_set_steps(), fu_progress_add_step() and fu_progress_done -- see the FuProgress docs for more details! * `FuUdevDevice->close()`: Use the `FuDevice` superclass instead.
## Planned API/ABI changes for next release ## 1.5.6
* Nothing yet. * `fu_device_get_protocol()`: Use `fu_device_get_protocols()` instead.
* `fu_device_set_protocol()`: Use `fu_device_add_protocol()` instead.
## 1.6.2
* `fu_device_has_custom_flag()`: Use `fu_device_has_private_flag()` instead.
## 1.6.3
* `fu_device_sleep_with_progress()`: Use `fu_progress_sleep()` instead -- but be aware the unit of time has changed from *seconds* to *milliseconds*.
* `fu_device_get_status()`: Use `fu_progress_get_status()` instead.
* `fu_device_set_status()`: Use `fu_progress_set_status()` instead.
* `fu_device_get_progress()`: Use `fu_progress_get_percentage()` instead.
* `fu_device_set_progress_full()`: Use `fu_progress_set_percentage_full()` instead.
* `fu_device_set_progress()`: Use `fu_progress_set_steps()`, `fu_progress_add_step()` and `fu_progress_done()` -- see the `FuProgress` docs for more details!
## 1.8.2
* `fu_udev_device_pread_full()`: Use `fu_udev_device_pread()` instead -- as the latter now specifies the buffer length.
* `fu_udev_device_pread_full()`: Use `fu_udev_device_pwrite()` instead -- as the latter now specifies the buffer length.
* `fu_udev_device_ioctl_full()`: Use `fu_udev_device_ioctl()` instead -- as the latter now always specifies the timeout.
* `fu_udev_device_new_full()`: Use `fu_udev_device_new()` instead -- as the latter always specifies the context.
* `fu_usb_device_new_full()`: Use `fu_usb_device_new()` instead -- as the latter always specifies the context.
* `fu_device_new_with_context()`: Use `fu_device_new()` instead -- as the latter always specifies the context.
* `fu_plugin_has_custom_flag()`: Use `fu_plugin_has_private_flag()` instead.
* `fu_efivar_secure_boot_enabled_full()`: Use `fu_efivar_secure_boot_enabled()` instead -- as the latter always specifies the error.
* `fu_progress_add_step()`: Add a 4th parameter to the function to specify the nice name for the step, or NULL.
* `fu_backend_setup()`: Now requires a `FuProgress`, although it can be ignored.
* `fu_backend_coldplug`: Now requires a `FuProgress`, although it can be ignored.
* `FuPluginVfuncs->setup`: Now requires a `FuProgress`, although it can be ignored.
* `FuPluginVfuncs->coldplug`: Now requires a `FuProgress`, although it can be ignored.
* `fu_common_crc*`: Use `fu_crc` prefix, i.e. remove the `_common`
* `fu_common_sum*`: Use `fu_sum` prefix, i.e. remove the `_common`
* `fu_byte_array_set_size_full()`: Use `fu_byte_array_set_size` instead -- as the latter now always specifies the fill char.
* `fu_common_string*`: Use `fu_string` prefix, i.e. remove the `_common`
* `fu_common_bytes*`: Use `fu_bytes` prefix, i.e. remove the `_common`
* `fu_common_set_contents_bytes()`: Use `fu_bytes_set_contents()` instead
* `fu_common_get_contents_bytes()`: Use `fu_bytes_get_contents()` instead
* `fu_common_read*`: Use `fu_memread` prefix, i.e. replace the `_common` with `_mem`
* `fu_common_write*`: Use `fu_memwrite` prefix, i.e. replace the `_common` with `_mem`
* `fu_common_bytes_compare_raw()`: Use `fu_memcmp_safe()` instead
* `fu_common_spawn_sync()`: Use `g_spawn_sync()` instead, or ideally not at all!
* `fu_common_extract_archive()`: Use `FuArchiveFirmware()` instead.
* `fu_common_instance_id_strsafe()`: Use `fu_device_add_instance_strsafe()` instead.
* `fu_common_kernel_locked_down()`: Use `fu_kernel_locked_down` instead.
* `fu_common_check_kernel_version()`: Use `fu_kernel_check_version` instead.
* `fu_common_get_firmware_search_path()`: Use `fu_kernel_get_firmware_search_path` instead.
* `fu_common_set_firmware_search_path()`: Use `fu_kernel_set_firmware_search_path` instead.
* `fu_common_reset_firmware_search_path()`: Use `fu_kernel_reset_firmware_search_path` instead.
* `fu_common_firmware_builder()`: You should not be using this.
* `fu_common_realpath()`: You should not be using this.
* `fu_common_uri_get_scheme()`: You should not be using this.
* `fu_common_dump*`: Use `fu_dump` prefix, i.e. remove the `_common`
* `fu_common_error_array_get_best()`: You should not be using this.
* `fu_common_cpuid()`: Use `fu_cpuid` instead.
* `fu_common_get_cpu_vendor()`: Use `fu_cpu_get_vendor` instead.
* `fu_common_vercmp_full()`: Use `fu_version_compare()` instead.
* `fu_common_version_ensure_semver()`: Use `fu_version_ensure_semver()` instead.
* `fu_common_version_from_uint*()`: Use `fu_version_from_uint*()` instead.
* `fu_common_strtoull()`: Use `fu_strtoull()` instead -- as the latter always specifies the error.
* `fu_smbios_to_string()`: Use `fu_firmware_to_string()` instead -- as `FuSmbios` is a `FuFirmware` superclass.
* `fu_common_cab_build_silo()`: You should not be using this.
* `fu_i2c_device_read_full()`: Use `fu_i2c_device_read` instead.
* `fu_i2c_device_write_full()`: Use `fu_i2c_device_write` instead.
* `fu_firmware_parse_full()`: Remove the `addr_end` parameter, and ensure that `offset` is a `gsize`.

View File

@ -57,8 +57,7 @@ fu_archive_firmware_parse_cb(FuArchive *self,
static gboolean static gboolean
fu_archive_firmware_parse(FuFirmware *firmware, fu_archive_firmware_parse(FuFirmware *firmware,
GBytes *fw, GBytes *fw,
guint64 addr_start, gsize offset,
guint64 addr_end,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {

View File

@ -128,8 +128,8 @@ fu_backend_registered(FuBackend *self, FuDevice *device)
* fu_backend_invalidate: * fu_backend_invalidate:
* @self: a #FuBackend * @self: a #FuBackend
* *
* Normally when calling fu_backend_setup() multiple times it is only actually done once. * Normally when calling [method@FuBackend.setup] multiple times it is only actually done once.
* Calling this method causes the next requests to fu_backend_setup() to actually probe the * Calling this method causes the next requests to [method@FuBackend.setup] to actually probe the
* hardware. * hardware.
* *
* Only subclassed backends setting `can-invalidate=TRUE` at construction time can use this * Only subclassed backends setting `can-invalidate=TRUE` at construction time can use this
@ -160,6 +160,7 @@ fu_backend_invalidate(FuBackend *self)
/** /**
* fu_backend_setup: * fu_backend_setup:
* @self: a #FuBackend * @self: a #FuBackend
* @progress: a #FuProgress
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Sets up the backend ready for use, which typically calls the subclassed setup * Sets up the backend ready for use, which typically calls the subclassed setup
@ -170,7 +171,7 @@ fu_backend_invalidate(FuBackend *self)
* Since: 1.6.1 * Since: 1.6.1
**/ **/
gboolean gboolean
fu_backend_setup(FuBackend *self, GError **error) fu_backend_setup(FuBackend *self, FuProgress *progress, GError **error)
{ {
FuBackendClass *klass = FU_BACKEND_GET_CLASS(self); FuBackendClass *klass = FU_BACKEND_GET_CLASS(self);
FuBackendPrivate *priv = GET_PRIVATE(self); FuBackendPrivate *priv = GET_PRIVATE(self);
@ -181,7 +182,7 @@ fu_backend_setup(FuBackend *self, GError **error)
if (priv->done_setup) if (priv->done_setup)
return TRUE; return TRUE;
if (klass->setup != NULL) { if (klass->setup != NULL) {
if (!klass->setup(self, error)) { if (!klass->setup(self, progress, error)) {
priv->enabled = FALSE; priv->enabled = FALSE;
return FALSE; return FALSE;
} }
@ -193,9 +194,10 @@ fu_backend_setup(FuBackend *self, GError **error)
/** /**
* fu_backend_coldplug: * fu_backend_coldplug:
* @self: a #FuBackend * @self: a #FuBackend
* @progress: a #FuProgress
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Adds devices using the subclassed backend. If fu_backend_setup() has not * Adds devices using the subclassed backend. If [method@FuBackend.setup] has not
* already been called then it is run before this function automatically. * already been called then it is run before this function automatically.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
@ -203,16 +205,16 @@ fu_backend_setup(FuBackend *self, GError **error)
* Since: 1.6.1 * Since: 1.6.1
**/ **/
gboolean gboolean
fu_backend_coldplug(FuBackend *self, GError **error) fu_backend_coldplug(FuBackend *self, FuProgress *progress, GError **error)
{ {
FuBackendClass *klass = FU_BACKEND_GET_CLASS(self); FuBackendClass *klass = FU_BACKEND_GET_CLASS(self);
g_return_val_if_fail(FU_IS_BACKEND(self), FALSE); g_return_val_if_fail(FU_IS_BACKEND(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE); g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (!fu_backend_setup(self, error)) if (!fu_backend_setup(self, progress, error))
return FALSE; return FALSE;
if (klass->coldplug == NULL) if (klass->coldplug == NULL)
return TRUE; return TRUE;
return klass->coldplug(self, error); return klass->coldplug(self, progress, error);
} }
/** /**

View File

@ -15,8 +15,12 @@ G_DECLARE_DERIVABLE_TYPE(FuBackend, fu_backend, FU, BACKEND, GObject)
struct _FuBackendClass { struct _FuBackendClass {
GObjectClass parent_class; GObjectClass parent_class;
/* signals */ /* signals */
gboolean (*setup)(FuBackend *self, GError **error) G_GNUC_WARN_UNUSED_RESULT; gboolean (*setup)(FuBackend *self,
gboolean (*coldplug)(FuBackend *self, GError **error) G_GNUC_WARN_UNUSED_RESULT; FuProgress *progress,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
gboolean (*coldplug)(FuBackend *self,
FuProgress *progress,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
void (*registered)(FuBackend *self, FuDevice *device); void (*registered)(FuBackend *self, FuDevice *device);
void (*invalidate)(FuBackend *self); void (*invalidate)(FuBackend *self);
/*< private >*/ /*< private >*/
@ -36,9 +40,11 @@ fu_backend_get_devices(FuBackend *self);
FuDevice * FuDevice *
fu_backend_lookup_by_id(FuBackend *self, const gchar *device_id); fu_backend_lookup_by_id(FuBackend *self, const gchar *device_id);
gboolean gboolean
fu_backend_setup(FuBackend *self, GError **error) G_GNUC_WARN_UNUSED_RESULT; fu_backend_setup(FuBackend *self, FuProgress *progress, GError **error) G_GNUC_WARN_UNUSED_RESULT;
gboolean gboolean
fu_backend_coldplug(FuBackend *self, GError **error) G_GNUC_WARN_UNUSED_RESULT; fu_backend_coldplug(FuBackend *self,
FuProgress *progress,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
void void
fu_backend_device_added(FuBackend *self, FuDevice *device); fu_backend_device_added(FuBackend *self, FuDevice *device);
void void

View File

@ -14,6 +14,7 @@
#include "fu-common.h" #include "fu-common.h"
#include "fu-device-private.h" #include "fu-device-private.h"
#include "fu-firmware-common.h" #include "fu-firmware-common.h"
#include "fu-string.h"
#define DEFAULT_PROXY_TIMEOUT 5000 #define DEFAULT_PROXY_TIMEOUT 5000
@ -191,7 +192,7 @@ fu_bluez_device_set_modalias(FuBluezDevice *self, const gchar *modalias)
if (rev != 0x0 && if (rev != 0x0 &&
fu_device_get_version_format(FU_DEVICE(self)) == FWUPD_VERSION_FORMAT_UNKNOWN) { fu_device_get_version_format(FU_DEVICE(self)) == FWUPD_VERSION_FORMAT_UNKNOWN) {
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
version = fu_common_version_from_uint16(rev, FWUPD_VERSION_FORMAT_BCD); version = fu_version_from_uint16(rev, FWUPD_VERSION_FORMAT_BCD);
fu_device_set_version_format(FU_DEVICE(self), FWUPD_VERSION_FORMAT_BCD); fu_device_set_version_format(FU_DEVICE(self), FWUPD_VERSION_FORMAT_BCD);
fu_device_set_version(FU_DEVICE(self), version); fu_device_set_version(FU_DEVICE(self), version);
} }
@ -209,10 +210,7 @@ fu_bluez_device_to_string(FuDevice *device, guint idt, GString *str)
g_hash_table_iter_init(&iter, priv->uuids); g_hash_table_iter_init(&iter, priv->uuids);
while (g_hash_table_iter_next(&iter, &key, &value)) { while (g_hash_table_iter_next(&iter, &key, &value)) {
FuBluezDeviceUuidHelper *uuid_helper = (FuBluezDeviceUuidHelper *)value; FuBluezDeviceUuidHelper *uuid_helper = (FuBluezDeviceUuidHelper *)value;
fu_common_string_append_kv(str, fu_string_append(str, idt + 1, (const gchar *)key, uuid_helper->path);
idt + 1,
(const gchar *)key,
uuid_helper->path);
} }
} }
} }

View File

@ -0,0 +1,154 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#define G_LOG_DOMAIN "FuCommon"
#include "config.h"
#include "fu-byte-array.h"
#include "fu-common.h"
#include "fu-mem.h"
/**
* fu_byte_array_append_uint8:
* @array: a #GByteArray
* @data: value
*
* Adds a 8 bit integer to a byte array.
*
* Since: 1.3.1
**/
void
fu_byte_array_append_uint8(GByteArray *array, guint8 data)
{
g_byte_array_append(array, &data, sizeof(data));
}
/**
* fu_byte_array_append_uint16:
* @array: a #GByteArray
* @data: value
* @endian: endian type, e.g. #G_LITTLE_ENDIAN
*
* Adds a 16 bit integer to a byte array.
*
* Since: 1.3.1
**/
void
fu_byte_array_append_uint16(GByteArray *array, guint16 data, FuEndianType endian)
{
guint8 buf[2];
fu_memwrite_uint16(buf, data, endian);
g_byte_array_append(array, buf, sizeof(buf));
}
/**
* fu_byte_array_append_uint32:
* @array: a #GByteArray
* @data: value
* @endian: endian type, e.g. #G_LITTLE_ENDIAN
*
* Adds a 32 bit integer to a byte array.
*
* Since: 1.3.1
**/
void
fu_byte_array_append_uint32(GByteArray *array, guint32 data, FuEndianType endian)
{
guint8 buf[4];
fu_memwrite_uint32(buf, data, endian);
g_byte_array_append(array, buf, sizeof(buf));
}
/**
* fu_byte_array_append_uint64:
* @array: a #GByteArray
* @data: value
* @endian: endian type, e.g. #G_LITTLE_ENDIAN
*
* Adds a 64 bit integer to a byte array.
*
* Since: 1.5.8
**/
void
fu_byte_array_append_uint64(GByteArray *array, guint64 data, FuEndianType endian)
{
guint8 buf[8];
fu_memwrite_uint64(buf, data, endian);
g_byte_array_append(array, buf, sizeof(buf));
}
/**
* fu_byte_array_append_bytes:
* @array: a #GByteArray
* @bytes: data blob
*
* Adds the contents of a GBytes to a byte array.
*
* Since: 1.5.8
**/
void
fu_byte_array_append_bytes(GByteArray *array, GBytes *bytes)
{
g_byte_array_append(array, g_bytes_get_data(bytes, NULL), g_bytes_get_size(bytes));
}
/**
* fu_byte_array_set_size:
* @array: a #GByteArray
* @length: the new size of the GByteArray
* @data: the byte used to pad the array
*
* Sets the size of the GByteArray, expanding with @data as required.
*
* Since: 1.8.2
**/
void
fu_byte_array_set_size(GByteArray *array, guint length, guint8 data)
{
guint oldlength = array->len;
g_byte_array_set_size(array, length);
if (length > oldlength)
memset(array->data + oldlength, data, length - oldlength);
}
/**
* fu_byte_array_align_up:
* @array: a #GByteArray
* @alignment: align to this power of 2
* @data: the byte used to pad the array
*
* Align a byte array length to a power of 2 boundary, where @alignment is the
* bit position to align to. If @alignment is zero then @array is unchanged.
*
* Since: 1.6.0
**/
void
fu_byte_array_align_up(GByteArray *array, guint8 alignment, guint8 data)
{
fu_byte_array_set_size(array, fu_common_align_up(array->len, alignment), data);
}
/**
* fu_byte_array_compare:
* @buf1: a data blob
* @buf2: another #GByteArray
* @error: (nullable): optional return location for an error
*
* Compares two buffers for equality.
*
* Returns: %TRUE if @buf1 and @buf2 are identical
*
* Since: 1.8.0
**/
gboolean
fu_byte_array_compare(GByteArray *buf1, GByteArray *buf2, GError **error)
{
g_return_val_if_fail(buf1 != NULL, FALSE);
g_return_val_if_fail(buf2 != NULL, FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
return fu_memcmp_safe(buf1->data, buf1->len, buf2->data, buf2->len, error);
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include "fu-common.h"
void
fu_byte_array_set_size(GByteArray *array, guint length, guint8 data);
void
fu_byte_array_align_up(GByteArray *array, guint8 alignment, guint8 data);
void
fu_byte_array_append_uint8(GByteArray *array, guint8 data);
void
fu_byte_array_append_uint16(GByteArray *array, guint16 data, FuEndianType endian);
void
fu_byte_array_append_uint32(GByteArray *array, guint32 data, FuEndianType endian);
void
fu_byte_array_append_uint64(GByteArray *array, guint64 data, FuEndianType endian);
void
fu_byte_array_append_bytes(GByteArray *array, GBytes *bytes);
gboolean
fu_byte_array_compare(GByteArray *buf1, GByteArray *buf2, GError **error);

358
libfwupdplugin/fu-bytes.c Normal file
View File

@ -0,0 +1,358 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#define G_LOG_DOMAIN "FuCommon"
#include "config.h"
#ifdef HAVE_GIO_UNIX
#include <gio/gunixinputstream.h>
#endif
#include "fwupd-error.h"
#include "fu-bytes.h"
#include "fu-common.h"
#include "fu-mem.h"
/**
* fu_bytes_set_contents:
* @filename: a filename
* @bytes: data to write
* @error: (nullable): optional return location for an error
*
* Writes a blob of data to a filename, creating the parent directories as
* required.
*
* Returns: %TRUE for success
*
* Since: 1.8.2
**/
gboolean
fu_bytes_set_contents(const gchar *filename, GBytes *bytes, GError **error)
{
const gchar *data;
gsize size;
g_autoptr(GFile) file = NULL;
g_autoptr(GFile) file_parent = NULL;
g_return_val_if_fail(filename != NULL, FALSE);
g_return_val_if_fail(bytes != NULL, FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
file = g_file_new_for_path(filename);
file_parent = g_file_get_parent(file);
if (!g_file_query_exists(file_parent, NULL)) {
if (!g_file_make_directory_with_parents(file_parent, NULL, error))
return FALSE;
}
data = g_bytes_get_data(bytes, &size);
g_debug("writing %s with %" G_GSIZE_FORMAT " bytes", filename, size);
return g_file_set_contents(filename, data, size, error);
}
/**
* fu_bytes_get_contents:
* @filename: a filename
* @error: (nullable): optional return location for an error
*
* Reads a blob of data from a file.
*
* Returns: a #GBytes, or %NULL for failure
*
* Since: 1.8.2
**/
GBytes *
fu_bytes_get_contents(const gchar *filename, GError **error)
{
gchar *data = NULL;
gsize len = 0;
g_return_val_if_fail(filename != NULL, NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
if (!g_file_get_contents(filename, &data, &len, error))
return NULL;
g_debug("reading %s with %" G_GSIZE_FORMAT " bytes", filename, len);
return g_bytes_new_take(data, len);
}
/**
* fu_bytes_get_contents_fd:
* @fd: a file descriptor
* @count: the maximum number of bytes to read
* @error: (nullable): optional return location for an error
*
* Reads a blob from a specific file descriptor.
*
* Note: this will close the fd when done
*
* Returns: (transfer full): a #GBytes, or %NULL
*
* Since: 1.8.2
**/
GBytes *
fu_bytes_get_contents_fd(gint fd, gsize count, GError **error)
{
#ifdef HAVE_GIO_UNIX
g_autoptr(GInputStream) stream = NULL;
g_return_val_if_fail(fd > 0, NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
/* read the entire fd to a data blob */
stream = g_unix_input_stream_new(fd, TRUE);
return fu_bytes_get_contents_stream(stream, count, error);
#else
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <glib-unix.h> is unavailable");
return NULL;
#endif
}
/**
* fu_bytes_get_contents_stream:
* @stream: input stream
* @count: the maximum number of bytes to read
* @error: (nullable): optional return location for an error
*
* Reads a blob from a specific input stream.
*
* Returns: (transfer full): a #GBytes, or %NULL
*
* Since: 1.8.2
**/
GBytes *
fu_bytes_get_contents_stream(GInputStream *stream, gsize count, GError **error)
{
guint8 tmp[0x8000] = {0x0};
g_autoptr(GByteArray) buf = g_byte_array_new();
g_autoptr(GError) error_local = NULL;
g_return_val_if_fail(G_IS_INPUT_STREAM(stream), NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
/* this is invalid */
if (count == 0) {
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"A maximum read size must be specified");
return NULL;
}
/* read from stream in 32kB chunks */
while (TRUE) {
gssize sz;
sz = g_input_stream_read(stream, tmp, sizeof(tmp), NULL, &error_local);
if (sz == 0)
break;
if (sz < 0) {
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
error_local->message);
return NULL;
}
g_byte_array_append(buf, tmp, sz);
if (buf->len > count) {
g_set_error(error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"cannot read from fd: 0x%x > 0x%x",
buf->len,
(guint)count);
return NULL;
}
}
return g_byte_array_free_to_bytes(g_steal_pointer(&buf));
}
/**
* fu_bytes_align:
* @bytes: data blob
* @blksz: block size in bytes
* @padval: the byte used to pad the byte buffer
*
* Aligns a block of memory to @blksize using the @padval value; if
* the block is already aligned then the original @bytes is returned.
*
* Returns: (transfer full): a #GBytes, possibly @bytes
*
* Since: 1.8.2
**/
GBytes *
fu_bytes_align(GBytes *bytes, gsize blksz, gchar padval)
{
const guint8 *data;
gsize sz;
g_return_val_if_fail(bytes != NULL, NULL);
g_return_val_if_fail(blksz > 0, NULL);
/* pad */
data = g_bytes_get_data(bytes, &sz);
if (sz % blksz != 0) {
gsize sz_align = ((sz / blksz) + 1) * blksz;
guint8 *data_align = g_malloc(sz_align);
memcpy(data_align, data, sz);
memset(data_align + sz, padval, sz_align - sz);
g_debug("aligning 0x%x bytes to 0x%x", (guint)sz, (guint)sz_align);
return g_bytes_new_take(data_align, sz_align);
}
/* perfectly aligned */
return g_bytes_ref(bytes);
}
/**
* fu_bytes_is_empty:
* @bytes: data blob
*
* Checks if a byte array are just empty (0xff) bytes.
*
* Returns: %TRUE if @bytes is empty
*
* Since: 1.8.2
**/
gboolean
fu_bytes_is_empty(GBytes *bytes)
{
gsize sz = 0;
const guint8 *buf = g_bytes_get_data(bytes, &sz);
for (gsize i = 0; i < sz; i++) {
if (buf[i] != 0xff)
return FALSE;
}
return TRUE;
}
/**
* fu_bytes_compare:
* @bytes1: a data blob
* @bytes2: another #GBytes
* @error: (nullable): optional return location for an error
*
* Compares the buffers for equality.
*
* Returns: %TRUE if @bytes1 and @bytes2 are identical
*
* Since: 1.8.2
**/
gboolean
fu_bytes_compare(GBytes *bytes1, GBytes *bytes2, GError **error)
{
const guint8 *buf1;
const guint8 *buf2;
gsize bufsz1;
gsize bufsz2;
g_return_val_if_fail(bytes1 != NULL, FALSE);
g_return_val_if_fail(bytes2 != NULL, FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
buf1 = g_bytes_get_data(bytes1, &bufsz1);
buf2 = g_bytes_get_data(bytes2, &bufsz2);
return fu_memcmp_safe(buf1, bufsz1, buf2, bufsz2, error);
}
/**
* fu_bytes_pad:
* @bytes: data blob
* @sz: the desired size in bytes
*
* Pads a GBytes to a minimum @sz with `0xff`.
*
* Returns: (transfer full): a data blob
*
* Since: 1.8.2
**/
GBytes *
fu_bytes_pad(GBytes *bytes, gsize sz)
{
gsize bytes_sz;
g_return_val_if_fail(bytes != NULL, NULL);
g_return_val_if_fail(sz != 0, NULL);
/* pad */
bytes_sz = g_bytes_get_size(bytes);
if (bytes_sz < sz) {
const guint8 *data = g_bytes_get_data(bytes, NULL);
guint8 *data_new = g_malloc(sz);
memcpy(data_new, data, bytes_sz);
memset(data_new + bytes_sz, 0xff, sz - bytes_sz);
return g_bytes_new_take(data_new, sz);
}
/* not required */
return g_bytes_ref(bytes);
}
/**
* fu_bytes_new_offset:
* @bytes: data blob
* @offset: where subsection starts at
* @length: length of subsection
* @error: (nullable): optional return location for an error
*
* Creates a #GBytes which is a subsection of another #GBytes.
*
* Returns: (transfer full): a #GBytes, or #NULL if range is invalid
*
* Since: 1.8.2
**/
GBytes *
fu_bytes_new_offset(GBytes *bytes, gsize offset, gsize length, GError **error)
{
g_return_val_if_fail(bytes != NULL, NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
/* sanity check */
if (offset + length > g_bytes_get_size(bytes)) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"cannot create bytes @0x%02x for 0x%02x "
"as buffer only 0x%04x bytes in size",
(guint)offset,
(guint)length,
(guint)g_bytes_get_size(bytes));
return NULL;
}
return g_bytes_new_from_bytes(bytes, offset, length);
}
/**
* fu_bytes_get_data_safe:
* @bytes: data blob
* @bufsz: (out) (optional): location to return size of byte data
* @error: (nullable): optional return location for an error
*
* Get the byte data in the #GBytes. This data should not be modified.
* This function will always return the same pointer for a given #GBytes.
*
* If the size of @bytes is zero, then %NULL is returned and the @error is set,
* which differs in behavior to that of g_bytes_get_data().
*
* This may be useful when calling g_mapped_file_new() on a zero-length file.
*
* Returns: a pointer to the byte data, or %NULL.
*
* Since: 1.6.0
**/
const guint8 *
fu_bytes_get_data_safe(GBytes *bytes, gsize *bufsz, GError **error)
{
const guint8 *buf = g_bytes_get_data(bytes, bufsz);
if (buf == NULL) {
g_set_error(error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "invalid data");
return NULL;
}
return buf;
}

35
libfwupdplugin/fu-bytes.h Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <gio/gio.h>
gboolean
fu_bytes_set_contents(const gchar *filename,
GBytes *bytes,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
GBytes *
fu_bytes_get_contents(const gchar *filename, GError **error) G_GNUC_WARN_UNUSED_RESULT;
GBytes *
fu_bytes_get_contents_stream(GInputStream *stream,
gsize count,
GError **error) G_GNUC_WARN_UNUSED_RESULT;
GBytes *
fu_bytes_get_contents_fd(gint fd, gsize count, GError **error) G_GNUC_WARN_UNUSED_RESULT;
GBytes *
fu_bytes_align(GBytes *bytes, gsize blksz, gchar padval);
const guint8 *
fu_bytes_get_data_safe(GBytes *bytes, gsize *bufsz, GError **error);
gboolean
fu_bytes_is_empty(GBytes *bytes);
gboolean
fu_bytes_compare(GBytes *bytes1, GBytes *bytes2, GError **error) G_GNUC_WARN_UNUSED_RESULT;
GBytes *
fu_bytes_pad(GBytes *bytes, gsize sz);
GBytes *
fu_bytes_new_offset(GBytes *bytes, gsize offset, gsize length, GError **error)
G_GNUC_WARN_UNUSED_RESULT;

View File

@ -17,6 +17,7 @@
#include "fu-cabinet.h" #include "fu-cabinet.h"
#include "fu-common.h" #include "fu-common.h"
#include "fu-string.h"
/** /**
* FuCabinet: * FuCabinet:
@ -291,7 +292,9 @@ fu_cabinet_parse_release(FuCabinet *self, XbNode *release, GError **error)
/* set as metadata if unset, but error if specified and incorrect */ /* set as metadata if unset, but error if specified and incorrect */
nsize = xb_node_query_first(release, "size[@type='installed']", NULL); nsize = xb_node_query_first(release, "size[@type='installed']", NULL);
if (nsize != NULL) { if (nsize != NULL) {
guint64 size = fu_common_strtoull(xb_node_get_text(nsize)); guint64 size = 0;
if (!fu_strtoull(xb_node_get_text(nsize), &size, 0, G_MAXSIZE, error))
return FALSE;
if (size != g_bytes_get_size(blob)) { if (size != g_bytes_get_size(blob)) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,

View File

@ -6,7 +6,6 @@
#pragma once #pragma once
#include <glib-object.h>
#include <jcat.h> #include <jcat.h>
#include <xmlb.h> #include <xmlb.h>

View File

@ -9,6 +9,8 @@
#include "config.h" #include "config.h"
#include "fu-cfi-device.h" #include "fu-cfi-device.h"
#include "fu-quirks.h"
#include "fu-string.h"
/** /**
* FuCfiDevice: * FuCfiDevice:
@ -365,80 +367,80 @@ fu_cfi_device_set_quirk_kv(FuDevice *device, const gchar *key, const gchar *valu
FuCfiDevicePrivate *priv = GET_PRIVATE(self); FuCfiDevicePrivate *priv = GET_PRIVATE(self);
guint64 tmp; guint64 tmp;
if (g_strcmp0(key, "CfiDeviceCmdReadId") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_ID) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_READ_ID] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_READ_ID] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdReadIdSz") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_ID_SZ) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmd_read_id_sz = tmp; priv->cmd_read_id_sz = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdChipErase") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_CHIP_ERASE) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_CHIP_ERASE] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_CHIP_ERASE] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdBlockErase") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_BLOCK_ERASE) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_BLOCK_ERASE] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_BLOCK_ERASE] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdSectorErase") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_SECTOR_ERASE) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_SECTOR_ERASE] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_SECTOR_ERASE] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdWriteStatus") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_WRITE_STATUS) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_WRITE_STATUS] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_WRITE_STATUS] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdPageProg") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_PAGE_PROG) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_PAGE_PROG] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_PAGE_PROG] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdReadData") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_DATA) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_READ_DATA] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_READ_DATA] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdReadStatus") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_READ_STATUS) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_READ_STATUS] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_READ_STATUS] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceCmdWriteEn") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_CMD_WRITE_EN) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT8, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT8, error))
return FALSE; return FALSE;
priv->cmds[FU_CFI_DEVICE_CMD_WRITE_EN] = tmp; priv->cmds[FU_CFI_DEVICE_CMD_WRITE_EN] = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDevicePageSize") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_PAGE_SIZE) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT32, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT32, error))
return FALSE; return FALSE;
priv->page_size = tmp; priv->page_size = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceSectorSize") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_SECTOR_SIZE) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT32, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT32, error))
return FALSE; return FALSE;
priv->sector_size = tmp; priv->sector_size = tmp;
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "CfiDeviceBlockSize") == 0) { if (g_strcmp0(key, FU_QUIRKS_CFI_DEVICE_BLOCK_SIZE) == 0) {
if (!fu_common_strtoull_full(value, &tmp, 0, G_MAXUINT32, error)) if (!fu_strtoull(value, &tmp, 0, G_MAXUINT32, error))
return FALSE; return FALSE;
priv->block_size = tmp; priv->block_size = tmp;
return TRUE; return TRUE;
@ -455,16 +457,16 @@ fu_cfi_device_to_string(FuDevice *device, guint idt, GString *str)
{ {
FuCfiDevice *self = FU_CFI_DEVICE(device); FuCfiDevice *self = FU_CFI_DEVICE(device);
FuCfiDevicePrivate *priv = GET_PRIVATE(self); FuCfiDevicePrivate *priv = GET_PRIVATE(self);
fu_common_string_append_kv(str, idt, "FlashId", priv->flash_id); fu_string_append(str, idt, "FlashId", priv->flash_id);
for (guint i = 0; i < FU_CFI_DEVICE_CMD_LAST; i++) { for (guint i = 0; i < FU_CFI_DEVICE_CMD_LAST; i++) {
fu_common_string_append_kx(str, idt, fu_cfi_device_cmd_to_string(i), priv->cmds[i]); fu_string_append_kx(str, idt, fu_cfi_device_cmd_to_string(i), priv->cmds[i]);
} }
if (priv->page_size > 0) if (priv->page_size > 0)
fu_common_string_append_kx(str, idt, "PageSize", priv->page_size); fu_string_append_kx(str, idt, "PageSize", priv->page_size);
if (priv->sector_size > 0) if (priv->sector_size > 0)
fu_common_string_append_kx(str, idt, "SectorSize", priv->sector_size); fu_string_append_kx(str, idt, "SectorSize", priv->sector_size);
if (priv->block_size > 0) if (priv->block_size > 0)
fu_common_string_append_kx(str, idt, "BlockSize", priv->block_size); fu_string_append_kx(str, idt, "BlockSize", priv->block_size);
} }
/** /**
@ -486,7 +488,10 @@ fu_cfi_device_chip_select(FuCfiDevice *self, gboolean value, GError **error)
g_return_val_if_fail(FU_IS_CFI_DEVICE(self), FALSE); g_return_val_if_fail(FU_IS_CFI_DEVICE(self), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE); g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
if (klass->chip_select == NULL) { if (klass->chip_select == NULL) {
g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "not supported"); g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"chip select is not implemented on this device");
return FALSE; return FALSE;
} }
return klass->chip_select(self, value, error); return klass->chip_select(self, value, error);

View File

@ -6,8 +6,6 @@
#pragma once #pragma once
#include <glib-object.h>
#include "fu-device.h" #include "fu-device.h"
#define FU_TYPE_CFI_DEVICE (fu_cfi_device_get_type()) #define FU_TYPE_CFI_DEVICE (fu_cfi_device_get_type())

View File

@ -8,8 +8,11 @@
#include "config.h" #include "config.h"
#include "fu-byte-array.h"
#include "fu-cfu-offer.h" #include "fu-cfu-offer.h"
#include "fu-common.h" #include "fu-common.h"
#include "fu-mem.h"
#include "fu-string.h"
/** /**
* FuCfuOffer: * FuCfuOffer:
@ -415,8 +418,7 @@ fu_cfu_offer_set_product_id(FuCfuOffer *self, guint16 product_id)
static gboolean static gboolean
fu_cfu_offer_parse(FuFirmware *firmware, fu_cfu_offer_parse(FuFirmware *firmware,
GBytes *fw, GBytes *fw,
guint64 addr_start, gsize offset,
guint64 addr_end,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
@ -428,33 +430,33 @@ fu_cfu_offer_parse(FuFirmware *firmware,
const guint8 *buf = g_bytes_get_data(fw, &bufsz); const guint8 *buf = g_bytes_get_data(fw, &bufsz);
/* component info */ /* component info */
if (!fu_common_read_uint8_safe(buf, bufsz, 0x0, &priv->segment_number, error)) if (!fu_memread_uint8_safe(buf, bufsz, 0x0, &priv->segment_number, error))
return FALSE; return FALSE;
if (!fu_common_read_uint8_safe(buf, bufsz, 0x1, &tmp, error)) if (!fu_memread_uint8_safe(buf, bufsz, 0x1, &tmp, error))
return FALSE; return FALSE;
priv->force_ignore_version = (tmp & 0b1) > 0; priv->force_ignore_version = (tmp & 0b1) > 0;
priv->force_immediate_reset = (tmp & 0b10) > 0; priv->force_immediate_reset = (tmp & 0b10) > 0;
if (!fu_common_read_uint8_safe(buf, bufsz, 0x2, &priv->component_id, error)) if (!fu_memread_uint8_safe(buf, bufsz, 0x2, &priv->component_id, error))
return FALSE; return FALSE;
if (!fu_common_read_uint8_safe(buf, bufsz, 0x3, &priv->token, error)) if (!fu_memread_uint8_safe(buf, bufsz, 0x3, &priv->token, error))
return FALSE; return FALSE;
/* version */ /* version */
if (!fu_common_read_uint32_safe(buf, bufsz, 0x4, &tmp32, G_LITTLE_ENDIAN, error)) if (!fu_memread_uint32_safe(buf, bufsz, 0x4, &tmp32, G_LITTLE_ENDIAN, error))
return FALSE; return FALSE;
fu_firmware_set_version_raw(firmware, tmp32); fu_firmware_set_version_raw(firmware, tmp32);
if (!fu_common_read_uint32_safe(buf, bufsz, 0x8, &priv->hw_variant, G_LITTLE_ENDIAN, error)) if (!fu_memread_uint32_safe(buf, bufsz, 0x8, &priv->hw_variant, G_LITTLE_ENDIAN, error))
return FALSE; return FALSE;
/* product info */ /* product info */
if (!fu_common_read_uint8_safe(buf, bufsz, 0xC, &tmp, error)) if (!fu_memread_uint8_safe(buf, bufsz, 0xC, &tmp, error))
return FALSE; return FALSE;
priv->protocol_revision = (tmp >> 4) & 0b1111; priv->protocol_revision = (tmp >> 4) & 0b1111;
priv->bank = (tmp >> 2) & 0b11; priv->bank = (tmp >> 2) & 0b11;
if (!fu_common_read_uint8_safe(buf, bufsz, 0xD, &tmp, error)) if (!fu_memread_uint8_safe(buf, bufsz, 0xD, &tmp, error))
return FALSE; return FALSE;
priv->milestone = (tmp >> 5) & 0b111; priv->milestone = (tmp >> 5) & 0b111;
if (!fu_common_read_uint16_safe(buf, bufsz, 0xE, &priv->product_id, G_LITTLE_ENDIAN, error)) if (!fu_memread_uint16_safe(buf, bufsz, 0xE, &priv->product_id, G_LITTLE_ENDIAN, error))
return FALSE; return FALSE;
/* success */ /* success */
@ -494,17 +496,22 @@ fu_cfu_offer_build(FuFirmware *firmware, XbNode *n, GError **error)
FuCfuOffer *self = FU_CFU_OFFER(firmware); FuCfuOffer *self = FU_CFU_OFFER(firmware);
FuCfuOfferPrivate *priv = GET_PRIVATE(self); FuCfuOfferPrivate *priv = GET_PRIVATE(self);
guint64 tmp; guint64 tmp;
const gchar *tmpb;
/* optional properties */ /* optional properties */
tmp = xb_node_query_text_as_uint(n, "segment_number", NULL); tmp = xb_node_query_text_as_uint(n, "segment_number", NULL);
if (tmp != G_MAXUINT64 && tmp <= G_MAXUINT8) if (tmp != G_MAXUINT64 && tmp <= G_MAXUINT8)
priv->segment_number = tmp; priv->segment_number = tmp;
tmp = xb_node_query_text_as_uint(n, "force_immediate_reset", NULL); tmpb = xb_node_query_text(n, "force_immediate_reset", NULL);
if (tmp != G_MAXUINT64 && tmp <= G_MAXUINT8) if (tmpb != NULL) {
priv->force_immediate_reset = tmp; if (!fu_strtobool(tmpb, &priv->force_immediate_reset, error))
tmp = xb_node_query_text_as_uint(n, "force_ignore_version", NULL); return FALSE;
if (tmp != G_MAXUINT64 && tmp <= G_MAXUINT8) }
priv->force_ignore_version = tmp; tmpb = xb_node_query_text(n, "force_ignore_version", NULL);
if (tmpb != NULL) {
if (!fu_strtobool(tmpb, &priv->force_ignore_version, error))
return FALSE;
}
tmp = xb_node_query_text_as_uint(n, "component_id", NULL); tmp = xb_node_query_text_as_uint(n, "component_id", NULL);
if (tmp != G_MAXUINT64 && tmp <= G_MAXUINT8) if (tmp != G_MAXUINT64 && tmp <= G_MAXUINT8)
priv->component_id = tmp; priv->component_id = tmp;

View File

@ -8,8 +8,11 @@
#include "config.h" #include "config.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-cfu-payload.h" #include "fu-cfu-payload.h"
#include "fu-common.h" #include "fu-common.h"
#include "fu-mem.h"
/** /**
* FuCfuPayload: * FuCfuPayload:
@ -28,12 +31,10 @@ G_DEFINE_TYPE(FuCfuPayload, fu_cfu_payload, FU_TYPE_FIRMWARE)
static gboolean static gboolean
fu_cfu_payload_parse(FuFirmware *firmware, fu_cfu_payload_parse(FuFirmware *firmware,
GBytes *fw, GBytes *fw,
guint64 addr_start, gsize offset,
guint64 addr_end,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
guint32 offset = 0;
gsize bufsz = 0; gsize bufsz = 0;
const guint8 *buf = g_bytes_get_data(fw, &bufsz); const guint8 *buf = g_bytes_get_data(fw, &bufsz);
@ -45,17 +46,17 @@ fu_cfu_payload_parse(FuFirmware *firmware,
g_autoptr(GBytes) blob = NULL; g_autoptr(GBytes) blob = NULL;
/* read chunk header */ /* read chunk header */
if (!fu_common_read_uint32_safe(buf, if (!fu_memread_uint32_safe(buf,
bufsz, bufsz,
offset, offset,
&chunk_addr, &chunk_addr,
G_LITTLE_ENDIAN, G_LITTLE_ENDIAN,
error)) error))
return FALSE; return FALSE;
if (!fu_common_read_uint8_safe(buf, bufsz, offset + 0x4, &chunk_size, error)) if (!fu_memread_uint8_safe(buf, bufsz, offset + 0x4, &chunk_size, error))
return FALSE; return FALSE;
offset += 0x5; offset += 0x5;
blob = fu_common_bytes_new_offset(fw, offset, chunk_size, error); blob = fu_bytes_new_offset(fw, offset, chunk_size, error);
if (blob == NULL) if (blob == NULL)
return FALSE; return FALSE;
chk = fu_chunk_bytes_new(blob); chk = fu_chunk_bytes_new(blob);

View File

@ -10,8 +10,10 @@
#include <string.h> #include <string.h>
#include "fu-bytes.h"
#include "fu-chunk-private.h" #include "fu-chunk-private.h"
#include "fu-common.h" #include "fu-common.h"
#include "fu-string.h"
/** /**
* FuChunk: * FuChunk:
@ -295,8 +297,7 @@ fu_chunk_export(FuChunk *self, FuFirmwareExportFlags flags, XbBuilderNode *bn)
g_autofree gchar *datastr = NULL; g_autofree gchar *datastr = NULL;
g_autofree gchar *dataszstr = g_strdup_printf("0x%x", (guint)self->data_sz); g_autofree gchar *dataszstr = g_strdup_printf("0x%x", (guint)self->data_sz);
if (flags & FU_FIRMWARE_EXPORT_FLAG_ASCII_DATA) { if (flags & FU_FIRMWARE_EXPORT_FLAG_ASCII_DATA) {
datastr = datastr = fu_strsafe((const gchar *)self->data, MIN(self->data_sz, 16));
fu_common_strsafe((const gchar *)self->data, MIN(self->data_sz, 16));
} else { } else {
datastr = g_base64_encode(self->data, self->data_sz); datastr = g_base64_encode(self->data, self->data_sz);
} }
@ -501,7 +502,7 @@ fu_chunk_array_new_from_bytes(GBytes *blob, guint32 addr_start, guint32 page_sz,
chunks = fu_chunk_array_new(data, (guint32)sz, addr_start, page_sz, packet_sz); chunks = fu_chunk_array_new(data, (guint32)sz, addr_start, page_sz, packet_sz);
for (guint i = 0; i < chunks->len; i++) { for (guint i = 0; i < chunks->len; i++) {
FuChunk *chk = g_ptr_array_index(chunks, i); FuChunk *chk = g_ptr_array_index(chunks, i);
chk->bytes = fu_common_bytes_new_offset(blob, chk->data - data, chk->data_sz, NULL); chk->bytes = fu_bytes_new_offset(blob, chk->data - data, chk->data_sz, NULL);
} }
return chunks; return chunks;
} }

View File

@ -6,7 +6,8 @@
#define G_LOG_DOMAIN "FuCommon" #define G_LOG_DOMAIN "FuCommon"
#include <config.h> #include "config.h"
#include <fnmatch.h> #include <fnmatch.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
@ -15,12 +16,15 @@
GPtrArray * GPtrArray *
fu_common_get_block_devices(GError **error) fu_common_get_block_devices(GError **error)
{ {
g_set_error(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "not supported"); g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"getting block devices is not supported on Darwin");
return NULL; return NULL;
} }
gboolean gboolean
fu_common_fnmatch_impl(const gchar *pattern, const gchar *str) fu_path_fnmatch_impl(const gchar *pattern, const gchar *str)
{ {
return fnmatch(pattern, str, FNM_NOESCAPE) == 0; return fnmatch(pattern, str, FNM_NOESCAPE) == 0;
} }

View File

@ -6,7 +6,8 @@
#define G_LOG_DOMAIN "FuCommon" #define G_LOG_DOMAIN "FuCommon"
#include <config.h> #include "config.h"
#include <gio/gio.h> #include <gio/gio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -16,6 +17,7 @@
#endif #endif
#include "fu-common-private.h" #include "fu-common-private.h"
#include "fu-path-private.h"
/* bsdisks doesn't provide Manager object */ /* bsdisks doesn't provide Manager object */
#define UDISKS_DBUS_PATH "/org/freedesktop/UDisks2" #define UDISKS_DBUS_PATH "/org/freedesktop/UDisks2"
@ -110,7 +112,7 @@ fu_common_get_block_devices(GError **error)
} }
gboolean gboolean
fu_common_fnmatch_impl(const gchar *pattern, const gchar *str) fu_path_fnmatch_impl(const gchar *pattern, const gchar *str)
{ {
#ifdef HAVE_FNMATCH_H #ifdef HAVE_FNMATCH_H
return fnmatch(pattern, str, FNM_NOESCAPE) == 0; return fnmatch(pattern, str, FNM_NOESCAPE) == 0;

View File

@ -6,9 +6,9 @@
#define G_LOG_DOMAIN "FuCommon" #define G_LOG_DOMAIN "FuCommon"
#include "fu-common-guid.h" #include "config.h"
#include <config.h> #include "fu-common-guid.h"
/** /**
* fu_common_guid_is_plausible: * fu_common_guid_is_plausible:

Some files were not shown because too many files have changed in this diff Show More