Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Rename aktualizr-repo to uptane-generator. #1279

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ These tools all link with libaktualizr, although they do not necessary use the A
- [x] Print snapshot (aktualizr_info_test.cc)
- [x] Print timestamp (aktualizr_info_test.cc)

### aktualizr-repo
### uptane-generator

`aktualizr-repo` is used in testing to simulate the generation of Uptane repositories.
`uptane-generator` is used in testing to simulate the generation of Uptane repositories.

- [x] Generate images and director repos (repo_test.cc)
- [x] Add an image to the images repo (repo_test.cc)
Expand Down
2 changes: 1 addition & 1 deletion ci/gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ xenial-pkg-test:
script:
- ./scripts/test_install_garage_deploy.sh
- ./scripts/test_install_aktualizr_and_update.sh
- ./scripts/test_aktualizr_repo.sh
- ./scripts/test-uptane-generator.sh

# -- yocto tests

Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ INPUT = @CMAKE_SOURCE_DIR@/docs \
@CMAKE_SOURCE_DIR@/tests \
@CMAKE_SOURCE_DIR@/src/aktualizr_info \
@CMAKE_SOURCE_DIR@/src/aktualizr_primary \
@CMAKE_SOURCE_DIR@/src/aktualizr_repo \
@CMAKE_SOURCE_DIR@/src/uptane_generator \
@CMAKE_SOURCE_DIR@/src/aktualizr_secondary \
@CMAKE_SOURCE_DIR@/src/cert_provider \
@CMAKE_SOURCE_DIR@/src/hmi_stub \
Expand Down
8 changes: 4 additions & 4 deletions docs/debugging-tips.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ sudo tcpdump tcp port 443 -w upload.pcap

Fetch both of these down. In wireshark preferences set ssl.keylog_file to point to premaster.txt. If your https traffic not on port 443, then add the port to http.ssl.port. Now open upload.pcap.

== Serve repo generated by aktualizr-repo
== Serve repo generated by uptane-generator

aktualizr can be tested against a dummy repository containing fake images.

First, generate a repository using link:../src/aktualizr_repo/main.cc[aktualizr-repo] tool:
First, generate a repository using link:../src/uptane_generator/main.cc[uptane-generator] tool:

```
aktualizr-repo generate <repo_dir>
uptane-generator generate <repo_dir>
```

Then, serve the generated directory using a web server such as the link:../tests/fake_http_server/fake_test_server.py[fake test server].

For more information about using aktualizr-repo, see link:./aktualizr-repo.adoc[aktualizr-repo.adoc].
For more information about using uptane-generator, see link:./uptane-generator.adoc[uptane-generator.adoc].

Here is an example configuration for nginx:

Expand Down
40 changes: 20 additions & 20 deletions docs/aktualizr-repo.adoc → docs/uptane-generator.adoc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
= Aktualizr repo

The aktualizr-repo directory contains a basic implementation of an Uptane server. It is comprised of three tools:
The uptane-generator directory contains a basic implementation of an Uptane server. It is comprised of three tools:

. link:../src/aktualizr_repo/run/create_repo.sh[`create_repo.sh`] is a script to generate a new Uptane metadata repository, an OSTree repository, and all associated credentials and configuration.
. link:../src/aktualizr_repo/run/serve_repo.py[`serve_repo.py`] is a script for running a minimalistic Uptane server.
. link:../src/aktualizr_repo/main.cc[`aktualizr-repo`] is a low-level tool to generate and control an Uptane repository. It can be used to manipulate the repo created with `create_repo.sh`, or it can be used entirely independently.
. link:../src/uptane_generator/run/create_repo.sh[`create_repo.sh`] is a script to generate a new Uptane metadata repository, an OSTree repository, and all associated credentials and configuration.
. link:../src/uptane_generator/run/serve_repo.py[`serve_repo.py`] is a script for running a minimalistic Uptane server.
. link:../src/uptane_generator/main.cc[`uptane-generator`] is a low-level tool to generate and control an Uptane repository. It can be used to manipulate the repo created with `create_repo.sh`, or it can be used entirely independently.

== create_repo.sh

`create_repo.sh` generates the whole Uptane repo together with client and server certificates and OSTree repo that can be used both by meta-updater and by the device. `create_repo.sh` uses `aktualizr-repo`, so make sure it's in `PATH`.
`create_repo.sh` generates the whole Uptane repo together with client and server certificates and OSTree repo that can be used both by meta-updater and by the device. `create_repo.sh` uses `uptane-generator`, so make sure it's in `PATH`.

=== Usage

Expand All @@ -28,90 +28,90 @@ Make sure that the repository path doesn't already exist and the machine where `

`serve_repo.py <port number> <repo path>`

== aktualizr-repo
== uptane-generator

`aktualizr-repo` can generate and control Uptane metadata. It is used by `create_repo.sh` and many aktualizr tests, but can also be used manually. See `aktualizr-repo --help` for basic usage details or the examples below for greater detail.
`uptane-generator` can generate and control Uptane metadata. It is used by `create_repo.sh` and many aktualizr tests, but can also be used manually. See `uptane-generator --help` for basic usage details or the examples below for greater detail.

=== Basic usage example

1. Generate a new Uptane repository:
+
```
aktualizr-repo --path <repo path> --command generate
uptane-generator --path <repo path> --command generate
```

2. Add a target to the images metadata:
+
```
aktualizr-repo --path <repo path> --command image --filename <image name> --targetname <target name> --hwid <hardware ID>
uptane-generator --path <repo path> --command image --filename <image name> --targetname <target name> --hwid <hardware ID>
```
+
This step can be repeated as many times as necessary for each target. `--targetname` is optional. If it is not provided, it is assumed to be the same as the image name provided to `--filename`.

3. Prepare director targets metadata for a given device:
+
```
aktualizr-repo --path <repo path> --command addtarget --targetname <image name> --hwid <hardware ID> --serial <ECU serial>
uptane-generator --path <repo path> --command addtarget --targetname <image name> --hwid <hardware ID> --serial <ECU serial>
```
+
This step can be repeated as many times as necessary for each target and ECU.

4. Sign the director targets metadata and schedule the prepared update:
+
```
aktualizr-repo --path <repo path> --command signtargets
uptane-generator --path <repo path> --command signtargets
```

=== Advanced usage examples

==== Delegations

`aktualizr-repo` supports first-order delegations. All delegations are therefore marked as terminating. To add a delegated role, use this:
`uptane-generator` supports first-order delegations. All delegations are therefore marked as terminating. To add a delegated role, use this:
```
aktualizr-repo --path <repo path> --command adddelegation --dname <delegated role name> --dpattern <delegated path pattern>
uptane-generator --path <repo path> --command adddelegation --dname <delegated role name> --dpattern <delegated path pattern>
```

To add a target to a delegated role, add the `--dname` parameter to the `image` command. The targetname must match the pattern supplied in `--dpattern` to the `adddelegation` command.
```
aktualizr-repo --path <repo path> --command image --filename <image name> --targetname <target name> --hwid <hardware ID> --dname <delegated role name>
uptane-generator --path <repo path> --command image --filename <image name> --targetname <target name> --hwid <hardware ID> --dname <delegated role name>
```

==== Generating metadata without a real file

To add a target to the images metadata without providing an actual file, you can supply alternative parameters to the `image` command:
```
aktualizr-repo --path <repo path> --command image --targetname <target name> --targetsha256 <target SHA256 hash> --targetsha512 <target SHA512 hash> --targetlength <target length> --hwid <hardware ID>
uptane-generator --path <repo path> --command image --targetname <target name> --targetsha256 <target SHA256 hash> --targetsha512 <target SHA512 hash> --targetlength <target length> --hwid <hardware ID>
```

==== Advanced director metadata control

To reset the director targets metadata or to prepare empty targets metadata, use the `emptytargets` command. If you then sign this metadata with `signtargets`, it will schedule an empty update.
```
aktualizr-repo --path <repo path> --command emptytargets
uptane-generator --path <repo path> --command emptytargets
```

To populate the director targets metadata with the currently signed metadata (with the previous signature removed), use the `oldtargets` command. You can then add more targets with `addtarget` and re-sign with `signtargets`.
```
aktualizr-repo --path <repo path> --command oldtargets
uptane-generator --path <repo path> --command oldtargets
```

==== Sign arbitrary metadata

To sign arbitrary metadata with one of the Uptane keys, use the `sign` command:
```
aktualizr-repo --path <repo path> --command sign --repotype <director|image> --keyname <role name of key> < <input data>
uptane-generator --path <repo path> --command sign --repotype <director|image> --keyname <role name of key> < <input data>
```

==== Add custom URLs

To add a custom URL to an image in the Targets metadata of the Images repository:
```
aktualizr-repo --path <repo path> --command image --filename <image name> --targetname <target name> --hwid <hardware ID> --url <URL>
uptane-generator --path <repo path> --command image --filename <image name> --targetname <target name> --hwid <hardware ID> --url <URL>
```

To add a custom URL to an image in the Targets metadata of the Director:
```
aktualizr-repo --path <repo path> --command addtarget --targetname <image name> --hwid <hardware ID> --serial <ECU serial> --url <URL>
uptane-generator --path <repo path> --command addtarget --targetname <image name> --hwid <hardware ID> --serial <ECU serial> --url <URL>
```

If a custom URL is set in both sets of metadata, libaktualizr will use the URL from the Director.
4 changes: 2 additions & 2 deletions scripts/build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ cp -rf "$GITREPO_ROOT/tests/test_data/prov_selfupdate" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/config/selfupdate.toml" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/scripts/selfupdate_server.py" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/test_data/selfupdate_2.0" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/aktualizr_repo/run/create_repo.sh" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/aktualizr_repo/run/serve_repo.py" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/uptane_generator/run/create_repo.sh" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/uptane_generator/run/serve_repo.py" "$TEST_INSTALL_DESTDIR"

git -C "$GITREPO_ROOT" fetch --tags --unshallow || true
git -C "$GITREPO_ROOT" describe > "$TEST_INSTALL_DESTDIR/aktualizr-version"
2 changes: 1 addition & 1 deletion scripts/selfupdate_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Handler(BaseHTTPRequestHandler):
def do_GET(self):
local_path = self.path
print("GET: " + local_path)
# Fix annoying issue where aktualizr-repo generates metadata for the
# Fix annoying issue where uptane-generator generates metadata for the
# images repository in /image but aktualizr expects /repo.
if local_path.startswith("/repo/"):
local_path = local_path.replace('/repo/', '/image/', 1)
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_aktualizr_deb_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ IMG_TAG=aktualizr-deb-$(cat /proc/sys/kernel/random/uuid)
echo "Building docker for testing aktualizr deb package inside it."
docker build -t "${IMG_TAG}" -f "${INSTALL_DOCKERFILE}" .
echo "Running docker container with aktualizr debian package inside."
docker run --rm -v "${PKG_SRCDIR}":/persistent -t "${IMG_TAG}" /bin/bash -c "/scripts/test_install_aktualizr_and_update.sh && /scripts/test_aktualizr_repo.sh"
docker run --rm -v "${PKG_SRCDIR}":/persistent -t "${IMG_TAG}" /bin/bash -c "/scripts/test_install_aktualizr_and_update.sh && /scripts/test-uptane-generator.sh"
8 changes: 4 additions & 4 deletions scripts/test_install_aktualizr_and_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ dpkg-deb -I "$TEST_INSTALL_DESTDIR"/aktualizr*.deb && dpkg -i "$TEST_INSTALL_DES
akt_version=$(aktualizr --version)
(grep "$(cat "$TEST_INSTALL_DESTDIR"/aktualizr-version)" <<< "$akt_version") || (echo "$akt_version"; false)

aktualizr-repo generate --path "$TEST_INSTALL_DESTDIR/fake_root"
aktualizr-repo image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "$TEST_INSTALL_DESTDIR/selfupdate_2.0" --hwid selfupdate-device
aktualizr-repo addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66
aktualizr-repo signtargets --path "$TEST_INSTALL_DESTDIR/fake_root"
uptane-generator generate --path "$TEST_INSTALL_DESTDIR/fake_root"
uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "$TEST_INSTALL_DESTDIR/selfupdate_2.0" --hwid selfupdate-device
uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66
uptane-generator signtargets --path "$TEST_INSTALL_DESTDIR/fake_root"

TEMP_DIR=$(mktemp -d)
mkdir -m 700 -p "$TEMP_DIR/import"
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_subdirectory("aktualizr_primary")
add_subdirectory("libaktualizr-posix")
add_subdirectory("aktualizr_secondary")
add_subdirectory("aktualizr_info")
add_subdirectory("aktualizr_repo")
add_subdirectory("uptane_generator")

add_subdirectory("cert_provider")
add_subdirectory("hmi_stub")
Expand Down
2 changes: 1 addition & 1 deletion src/aktualizr_lite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_dependencies(build_tests aktualizr-lite)
add_test(test_aktualizr-lite
${CMAKE_CURRENT_SOURCE_DIR}/test_lite.sh
${CMAKE_BINARY_DIR}/src/aktualizr_lite/aktualizr-lite
${CMAKE_BINARY_DIR}/src/aktualizr_repo/aktualizr-repo
${CMAKE_BINARY_DIR}/src/uptane_generator/uptane-generator
${PROJECT_SOURCE_DIR}/tests
${RUN_VALGRIND}
)
Expand Down
16 changes: 8 additions & 8 deletions src/aktualizr_lite/test_lite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

build_dir=$(pwd)
aklite=$1
akrepo_bin=$2
uptane_gen_bin=$2
tests_dir=$3
#valgrind=$4
valgrind=""
Expand All @@ -21,8 +21,8 @@ cleanup() {
}
trap cleanup EXIT

akrepo() {
$akrepo_bin --repotype image --path "$dest_dir" "$@"
uptane_gen() {
$uptane_gen_bin --repotype image --path "$dest_dir" "$@"
}

add_target() {
Expand All @@ -40,15 +40,15 @@ add_target() {
"targetFormat": "OSTREE"
}
EOF
akrepo --command image \
--targetname $name --targetsha256 $sha --targetlength 0 \
--hwid hwid-for-test --targetcustom $custom_json
uptane_gen --command image \
--targetname $name --targetsha256 $sha --targetlength 0 \
--hwid hwid-for-test --targetcustom $custom_json
}

akrepo --command generate --expires 2021-07-04T16:33:27Z
uptane_gen --command generate --expires 2021-07-04T16:33:27Z
add_target foo1
add_target foo2
akrepo --command signtargets
uptane_gen --command signtargets

pushd $dest_dir
python3 -m http.server 0&
Expand Down
27 changes: 0 additions & 27 deletions src/aktualizr_repo/CMakeLists.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/aktualizr_secondary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ add_aktualizr_test(NAME aktualizr_secondary_update
if(BUILD_OSTREE)
add_aktualizr_test(NAME aktualizr_secondary_uptane
SOURCES uptane_test.cc
LIBRARIES aktualizr_repo_lib
LIBRARIES uptane_generator_lib
LIBRARIES aktualizr-posix
ARGS ${PROJECT_BINARY_DIR}/ostree_repo PROJECT_WORKING_DIRECTORY)
target_link_libraries(t_aktualizr_secondary_uptane virtual_secondary)
Expand Down Expand Up @@ -134,7 +134,7 @@ set_tests_properties(aktualizr_secondary_help_with_other_options

aktualizr_source_file_checks(${AKTUALIZR_SECONDARY_SRC}
${AKTUALIZR_SECONDARY_LIB_SRC}
${ALL_AKTUALIZR_SECONDARY_HEADERS}
${ALL_AKTUALIZR_SECONDARY_HEADERS}
${TEST_SOURCES})

# vim: set tabstop=4 shiftwidth=4 expandtab:
4 changes: 2 additions & 2 deletions src/libaktualizr/package_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ if(BUILD_OSTREE)
if(BUILD_DOCKERAPP)
target_sources(package_manager PRIVATE dockerappmanager.cc)
add_aktualizr_test(NAME dockerapp SOURCES dockerappmanager_test.cc PROJECT_WORKING_DIRECTORY NO_VALGRIND
ARGS ${PROJECT_BINARY_DIR}/ostree_repo "$<TARGET_FILE:aktualizr-repo>")
ARGS ${PROJECT_BINARY_DIR}/ostree_repo "$<TARGET_FILE:uptane-generator>")
endif(BUILD_DOCKERAPP)
endif(BUILD_OSTREE)

add_aktualizr_test(NAME packagemanager_factory SOURCES packagemanagerfactory_test.cc NO_VALGRIND
ARGS ${PROJECT_BINARY_DIR}/ostree_repo)
add_aktualizr_test(NAME fetcher SOURCES fetcher_test.cc ARGS PROJECT_WORKING_DIRECTORY LIBRARIES PUBLIC aktualizr_repo_lib)
add_aktualizr_test(NAME fetcher SOURCES fetcher_test.cc ARGS PROJECT_WORKING_DIRECTORY LIBRARIES PUBLIC uptane_generator_lib)
add_aktualizr_test(NAME fetcher_death SOURCES fetcher_death_test.cc NO_VALGRIND ARGS PROJECT_WORKING_DIRECTORY)

aktualizr_source_file_checks(fetcher_death_test.cc fetcher_test.cc)
Expand Down
16 changes: 8 additions & 8 deletions src/libaktualizr/package_manager/dockerapp_test_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
set -eEuo pipefail

if [ "$#" -lt 3 ]; then
echo "Usage: $0 <aktualizr-repo> <output directory> <port>"
echo "Usage: $0 <uptane-generator> <output directory> <port>"
exit 1
fi

AKTUALIZR_REPO="$1"
UPTANE_GENERATOR="$1"
DEST_DIR="$2"
PORT="$3"

akrepo() {
"$AKTUALIZR_REPO" --path "$DEST_DIR" "$@"
uptane_gen() {
"$UPTANE_GENERATOR" --path "$DEST_DIR" "$@"
}

mkdir -p "$DEST_DIR"
Expand All @@ -22,10 +22,10 @@ trap 'rm -rf "$IMAGES"' exit
DOCKER_APP="$IMAGES/foo.dockerapp"
echo "fake contents of a docker app" > "$DOCKER_APP"

akrepo --command generate --expires 2021-07-04T16:33:27Z
akrepo --command image --filename "$DOCKER_APP" --targetname foo.dockerapp --hwid primary_hw
akrepo --command addtarget --hwid primary_hw --serial CA:FE:A6:D2:84:9D --targetname foo.dockerapp
akrepo --command signtargets
uptane_gen --command generate --expires 2021-07-04T16:33:27Z
uptane_gen --command image --filename "$DOCKER_APP" --targetname foo.dockerapp --hwid primary_hw
uptane_gen --command addtarget --hwid primary_hw --serial CA:FE:A6:D2:84:9D --targetname foo.dockerapp
uptane_gen --command signtargets

cd $DEST_DIR
echo "Target.json is: "
Expand Down
Loading