Update GUIDE.md to reflect the change in ISU format from TPK to RPK 50/304250/3 accepted/tizen_unified_riscv accepted/tizen/8.0/unified/20240117.162915 accepted/tizen/unified/20240117.163222 accepted/tizen/unified/riscv/20240118.054550
authorAdam Michalski <a.michalski2@partner.samsung.com>
Fri, 12 Jan 2024 16:20:48 +0000 (17:20 +0100)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Mon, 15 Jan 2024 09:43:17 +0000 (10:43 +0100)
Change-Id: I98dc36eb81363ad41bba8e5c7dca63c357c500c5

doc/GUIDE.md
packaging/isu.spec

index 91d9343..a5fb126 100644 (file)
@@ -490,7 +490,7 @@ Please consult the following real-life use cases to understand how the method wa
 |muse-server | isu-sandbox | Works properly |
 |pulseaudio | isu-sandbox | Works properly |
 
-### Build ISU Package
+### Building ISU Packages
 
 `ISU packages` are generated from platform images containing ISU configuration found in `/etc/isu/`
 sub-directories - one for each sub-directory.
@@ -500,42 +500,184 @@ The process of generating `ISU package` from platform image consists of the foll
 1. Mount platform images from the `tar.gz` archive.
 2. Search for all directories in `/etc/isu/` which contains `isu.cfg` file.
 3. Copy all files listed in the `[files]` section from the images to the
-   temporary directory.
+   temporary directory. Additionally, copy all files listed in the `[files]`
+   section listed in the `/etc/isu/[pkg_name]/isu.cfg.d/*.cfg` files if `isu.cfg.d`
+   subdirectory exists.
 4. Create a `SquashFS` image of the temporary directory.
 5. Complete the `isu.cfg` configuration file with the data on the image
    from which the package is generated.
 6. Compute a checksum of the image, the configuration file and services files.
 7. Sign the checksum
-8. Create a TPK archive
+8. Create an RPK archive
 
 The `isu_pkgs_maker.py` script has been prepared to automate this process.
-Usage of the script:
+To build ISU packages you need to follow these steps:
 
-    sudo ./isu_pkgs_maker.py --src <src_dir> --out <out_dir> --map <map_file> --key <priv_key>
+1. Get the latest ISU:
 
-* `src_dir`  - Directory containing the generated image as a `.tar.gz` archive.
-* `out_dir`  - Directory where ISU packages will be saved as `.tpk` archives.
+    $ mkdir /opt/isu/
+    $ git clone git://git.tizen.org/platform/core/system/isu /opt/isu
+    $ cd /opt/isu
+    $ git checkout tizen
+
+2. Create a working directory with structure:
+
+    $ mkdir /opt/isu_work
+    $ cd /opt/isu_work
+    $ mkdir src
+    $ mkdir out
+
+3. Download an image to the current directory, e.g.:
+
+    $ wget -P ./src http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/tizen-unified_20231206.050628/images/standard/tizen-headless-aarch64/tizen-unified_20231206.050628_tizen-headless-aarch64.tar.gz
+
+4. Copy the `isu_pkgs_maker_py2.py` to the current directory, e.g.:
+
+    $ cp /opt/isu/src/pkg_maker/isu_pkgs_maker_py2.py .
+
+5. Copy certificates to the current directory:
+
+    $ cp /opt/certs/author.p12 .
+    $ cp /opt/certs/distributor.p12 .
+
+6. Prepare the `map.ini` file in the current directory with the following content:
+
+    [map]
+    rootfs.img=/
+    system-data.img=/opt/
+
+7. Install `xmlsec1` library:
+
+    sudo apt install xmlsec1
+
+8. Run `isu_pkgs_maker`:
+
+    sudo ./isu_pkgs_maker.py --src <src_dir> --out <out_dir> --rpk-author-key <author_priv_key> \
+        --rpk-author-key-pass <author_priv_key_passcode> --rpk-dist-key <distrib_key> --rpk-dist-key_pass <distrib_key_passcode>
+        --rpk -u --map <map_file>
+
+9. Generated ISU packages in the RPK format, should be in the ./isu_out directory
+
+* `src_dir`                  - Directory containing the generated image as a `.tar.gz` archive.
+* `out_dir`                  - Directory where ISU packages will be saved as `.rpk` archives.
+* `author_priv_key`          - Author's private key with which the checksum will be signed.
+* `author_priv_key_passcode` - Author's private key passcode.
+* `distrib_key`              - Distributor's key passcode.
 * `map_file` - File which contains the image-to-path mapping. Example:
 
                   [map]
                   rootfs.img=/
                   system-data.img=/opt/
 
-* `priv_key` - Private key with which the checksum will be signed.
-               Example of key generation:
-
-                  host$ openssl genrsa -out key.pem 2048
-                  host$ openssl rsa -in key.pem -pubout -out key.pub
-
 Since the script must mount the images, the root permissions are required. The
 script will create ISU packages for all configuration files found in the
 sub-directories of the `/etc/isu/` directory.
 
+## Making ISU packages during image creation
+
+1. Get the latest ISU:
+
+    $ mkdir /opt/isu/
+    $ git clone git://git.tizen.org/platform/core/system/isu /opt/isu
+    $ cd /opt/isu
+    $ git checkout tizen
+
+2. Get `mic-bootstrap` with `xmlsec1`: https://review.tizen.org/gerrit/#/c/tools/mic-bootstrap/+/302121/
+
+3. Build `mic-bootstrap`:
+
+    $ gbs build -A aarch64
+
+4. Get the `.ks` file:
+
+    $ mkdir /opt/image_build
+    $ cd /opt/image_build
+    $ wget http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/tizen-unified_20231206.050628/images/standard/tizen-headless-aarch64/tizen-unified_20231206.050628_tizen-headless-aarch64.ks
+
+5. Modify the `.ks` file:
+5.1. Add the local repo with the highest priority to use the new `mic-bootstrap`, e.g.:
+
+    [...]
+    repo --name=local --baseurl=file:///home/<USER>/GBS-ROOT/local/repos/tizen/x86_64 --priority=1
+    repo --name=gbs_repo --baseurl=http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/tizen-unified_20231206.050628/repos/standard/packages/ --ssl_verify=no --priority=2
+    repo --name=gbs_base_repo_0 --baseurl=http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Base/tizen-base_20231204.082747/repos/standard/packages/ --ssl_verify=no --priority=99
+    [...]
+
+    Please remember to amend the above path to the local `GBS-ROOT` subdirectory, usually located in your $HOME directory,
+    and the url to the Tizen image snapshots.
+
+5.2. At the end of the file add the command to build the ISU packages (last two lines):
+
+    [...]
+    echo "############### backup-data.nochroot ################"
+
+    date +'[%m/%d %H:%M:%S %Z] backup-data.nochroot nochroot post script - start'
+
+    if [ -e $INSTALL_ROOT/usr/bin/build-backup-data.sh ]; then
+        $INSTALL_ROOT/usr/bin/build-backup-data.sh
+    fi
+
+    date +'[%m/%d %H:%M:%S %Z] backup-data.nochroot nochroot post script - end'
+
+    mkdir -p isu_out
+    /usr/bin/python2 isu_pkgs_maker_py2.py --src $INSTALL_ROOT/  --out isu_out --rpk-author-key author.p12 --rpk-author-key-pass 12345678 --rpk-dist-key distributor.p12 --rpk-dist-key-pass tizenpkcs12passfordsigner --rpk
+
+    %end
+
+6. Copy the `isu_pkgs_maker_py2.py` to the directory with the `.ks` file:
+
+    $ cp /opt/isu/src/pkg_maker/isu_pkgs_maker_py2.py .
+
+7. Copy certificates to the directory with the `.ks` file:
+
+    $ cp /opt/certs/author.p12 .
+    $ cp /opt/certs/distributor.p12 .
+
+8. Run `mic`:
+
+    $ sudo mic -d -v cr tizen-unified_20231205.115112_tizen-headless-aarch64.ks
+
+9. Generated ISU packages in the RPK format should be in the `./isu_out directory`
+
+## Install ISU package in `rpk` format
+
+1. Get latest ISU:
+
+    $ mkdir /opt/isu/
+    $ git clone git://git.tizen.org/platform/core/system/isu /opt/isu
+    $ cd /opt/isu
+    $ git checkout tizen
+
+2. Build and install the latest ISU rpms on the target
+
+    $ cd /opt/isu/
+    $ gbs build -A aarch64
+    $ sdb root on
+    $ sdb push ~/GBS-ROOT/local/repos/tizen/aarch64/RPMS/isu-9.0.0-1.aarch64.rpm /tmp/
+    $ sdb push ~/GBS-ROOT/local/repos/tizen/aarch64/RPMS/isu-plugin-parser-9.0.0-1.aarch64.rpm /tmp/
+    $ sdb push ~/GBS-ROOT/local/repos/tizen/aarch64/RPMS/libisu-9.0.0-1.aarch64.rpm /tmp/
+    $ sdb shell
+    root:~> rpm -Uivh --force /tmp/*isu*rpm
+
+3. Enable ISU feature:
+
+    root:~> system-info-tool --set tizen.org/feature/isu bool 1
+
+4. Make sure that the `/opt/isu` directory exists and the owner of it is `system`:
+
+    root:~> mkdir -p /opt/isu
+    root:~> chown system:system /opt/isu
+
+5. Upload the ISU package to the target and install it:
+
+    $ sdb push dlog.rpk /tmp/
+    $ sdb shell
+    root:~> pkgcmd -i -t rpk -p /tmp/dlog.rpk
 
 # Internals
 
 ## ISU package format
-The ISU package is the TPK archive (which is just a renamed zip) that contains the following structure:
+The ISU package is the RPK archive (which is just a renamed zip) that contains the following structure:
 
     isu.cfg
     system-services/
@@ -576,7 +718,7 @@ The ISU package is the TPK archive (which is just a renamed zip) that contains t
 2. Prepare ISU package based on ISU configuration and binaries from the system image
 
    The `isu_pkgs_maker.py` is responsible for preparing ISU packages, generating
-   them as TPK archives based on the image and configuration files.
+   them as RPK archives based on the image and configuration files.
    For a description see **"Make ISU package"**
 
 3. Download and unpack the ISU package into the appropriate directory.
index 67b8afe..d7e29ca 100644 (file)
@@ -1,7 +1,7 @@
 %define libisu_version 0.0.1
 Summary: Individual Service Upgrade support
 Name:    isu
-Version: 9.0.4.1
+Version: 9.0.5
 Release: 1
 Source0: %{name}-%{version}.tar.gz
 License: MIT