Skip to content

Commit

Permalink
[Tizen] Add Tizen Studio CLI to docker images
Browse files Browse the repository at this point in the history
This commit adds Tizen Studio CLI into the Tizen docker image. Also, it
setups app's author certificate for signing the application. With that
setup it will be possible to pack Tizen application into the tpk package
as follows:

tizen package -t tpk --sign CHIP -- <TizenAppBuildDir>
  • Loading branch information
arkq committed Apr 13, 2022
1 parent faabdf9 commit fb498b0
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 58 deletions.
17 changes: 12 additions & 5 deletions build/toolchain/tizen/tizen_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,30 @@

import("//build_overrides/build.gni")

import("${build_root}/config/sysroot.gni")
import("${build_root}/toolchain/gcc_toolchain.gni")

declare_args() {
# Location of the Tizen SDK.
tizen_sdk_root = ""
}

template("tizen_toolchain") {
_invoker_toolchain_args = invoker.toolchain_args

_tizen_toolchain_args = {
current_os = "tizen"
is_clang = true
is_clang = false

forward_variables_from(_invoker_toolchain_args, "*")
}

_tizen_toolchain_prefix =
"${tizen_sdk_root}/tools/arm-linux-gnueabi/bin/arm-linux-gnueabi-"

gcc_toolchain(target_name) {
toolchain_args = _tizen_toolchain_args
ar = "$sysroot/bin/arm-linux-gnueabi-ar"
cc = "$sysroot/bin/arm-linux-gnueabi-gcc"
cxx = "$sysroot/bin/arm-linux-gnueabi-g++"
ar = _tizen_toolchain_prefix + "ar"
cc = _tizen_toolchain_prefix + "gcc"
cxx = _tizen_toolchain_prefix + "g++"
}
}
5 changes: 0 additions & 5 deletions config/tizen/chip-gn/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@

import("//build_overrides/chip.gni")

declare_args() {
# Location of the Tizen SDK.
tizen_sdk_root = ""
}

chip_device_platform = "tizen"

chip_build_tests = false
Expand Down
107 changes: 74 additions & 33 deletions integrations/docker/images/chip-build-tizen/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,71 @@ RUN set -x \
&& : # last line

# ------------------------------------------------------------------------------
# Install toolchain
# Install dependencies
RUN set -x \
&& apt-get update \
&& apt-get install -fy --no-install-recommends obs-build=20180831-3ubuntu1 cpio=2.13+dfsg-2 \
&& DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
cpio=2.13+dfsg-2 \
obs-build=20180831-3ubuntu1 \
openjdk-8-jre-headless \
zip \
# Cleanup
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& : # last line

# ------------------------------------------------------------------------------
# Install tizen SDK
ENV TIZEN_HOME /opt/tizen_sdk
ENV TIZEN_ROOTSTRAP_VERSION 6.0
ENV TIZEN_ROOTSTRAPS mobile-$TIZEN_ROOTSTRAP_VERSION-rs-device.core_0.0.123_ubuntu-64
ENV DNS_LIBS libnsd-dns-sd.so*
ENV TIZEN_SDK_ROOT /opt/tizen-sdk
ENV TIZEN_SDK_SYSROOT $TIZEN_SDK_ROOT/sysroot
ENV TIZEN_VERSION 6.0

WORKDIR $TIZEN_HOME
WORKDIR /tmp/workdir

# ------------------------------------------------------------------------------
# Get tizen studio CLI
RUN set -x \
&& mkdir -p $TIZEN_SDK_ROOT \
# Download
&& wget --progress=dot:giga \
http://download.tizen.org/sdk/tizenstudio/official/binary/certificate-encryptor_1.0.7_ubuntu-64.zip \
http://download.tizen.org/sdk/tizenstudio/official/binary/certificate-generator_0.1.3_ubuntu-64.zip \
http://download.tizen.org/sdk/tizenstudio/official/binary/new-common-cli_2.5.7_ubuntu-64.zip \
http://download.tizen.org/sdk/tizenstudio/official/binary/new-native-cli_2.5.7_ubuntu-64.zip \
# Install tizen studio CLI
&& unzip -o '*.zip' \
&& mv data/tools $TIZEN_SDK_ROOT \
&& echo "TIZEN_SDK_INSTALLED_PATH=$TIZEN_SDK_ROOT" > $TIZEN_SDK_ROOT/sdk.info \
&& echo "TIZEN_SDK_DATA_PATH=$USER_HOME/tizen-sdk-data" >> $TIZEN_SDK_ROOT/sdk.info \
&& ln -sf $USER_HOME/.tizen-cli-config $TIZEN_SDK_ROOT/tools/.tizen-cli-config \
# Cleanup
&& rm -rf /tmp/workdir \
&& : # last line

COPY secret-tool.py $TIZEN_SDK_ROOT/tools/certificate-encryptor/secret-tool
ENV PATH="$TIZEN_SDK_ROOT/tools/ide/bin:$PATH"

# ------------------------------------------------------------------------------
# Get toolchain
RUN set -x \
&& wget --progress=dot:giga http://download.tizen.org/sdk/tizenstudio/official/binary/$TIZEN_ROOTSTRAPS.zip \
&& unzip $TIZEN_ROOTSTRAPS.zip \
&& mv data/platforms/tizen-$TIZEN_ROOTSTRAP_VERSION/mobile/rootstraps/mobile-$TIZEN_ROOTSTRAP_VERSION-device.core/usr . \
&& mv data/platforms/tizen-$TIZEN_ROOTSTRAP_VERSION/mobile/rootstraps/mobile-$TIZEN_ROOTSTRAP_VERSION-device.core/lib . \
&& rm -rf usr/lib/$DNS_LIBS \
&& rm -rf data \
&& rm -rf mobile-$TIZEN_ROOTSTRAP_VERSION-rs-device.* \
&& rm pkginfo.manifest \
&& mkdir -p $TIZEN_SDK_ROOT \
# Download
&& wget --progress=dot:giga http://download.tizen.org/sdk/tizenstudio/official/binary/cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip \
# Install toolchain
&& unzip -o '*.zip' \
&& cp -rf data/tools/arm-linux-gnueabi-gcc-9.2 $TIZEN_SDK_ROOT/tools/arm-linux-gnueabi \
# Cleanup
&& rm -rf /tmp/workdir \
&& : # last line

ENV PATH="$TIZEN_SDK_ROOT/tools/arm-linux-gnueabi/bin:$PATH"

# ------------------------------------------------------------------------------
# Get tizen packages
# Get tizen sysroot
RUN set -x \
&& mkdir -p $TIZEN_SDK_SYSROOT \
# Base sysroot
&& wget --progress=dot:giga http://download.tizen.org/sdk/tizenstudio/official/binary/mobile-$TIZEN_VERSION-rs-device.core_0.0.123_ubuntu-64.zip \
# Base packages
&& wget -r -nd --no-parent -q -A 'pcre-devel-*.armv7l.rpm' http://download.tizen.org/releases/milestone/tizen/base/latest/repos/standard/packages/armv7l/ \
&& wget -r -nd --no-parent -q -A 'libffi-devel-*.armv7l.rpm' http://download.tizen.org/releases/milestone/tizen/base/latest/repos/standard/packages/armv7l/ \
Expand All @@ -67,26 +101,33 @@ RUN set -x \
&& wget -r -nd --no-parent -q -A 'capi-network-nsd-*.armv7l.rpm' http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/armv7l/ \
&& wget -r -nd --no-parent -q -A 'libnsd-dns-sd-*.armv7l.rpm' http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/armv7l/ \
&& wget -r -nd --no-parent -q -A 'capi-network-thread-*.armv7l.rpm' http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/armv7l/ \
&& unrpm ./*.rpm \
&& cp usr/lib/pkgconfig/openssl1.1.pc usr/lib/pkgconfig/openssl.pc \
&& rm usr/lib/libdns_sd.so \
&& cp usr/lib/libdns_sd.so.878.* usr/lib/libdns_sd.so \
&& rm ./*.rpm \
&& : # last line

# ------------------------------------------------------------------------------
# Get toolchain
RUN set -x \
&& wget --progress=dot:giga http://download.tizen.org/sdk/tizenstudio/official/binary/cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip \
&& unzip cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip \
&& cp -rf data/tools/arm-linux-gnueabi-gcc-9.2/* . \
&& rm pkginfo.manifest \
&& rm changelog \
&& rm -rf data \
&& rm cross-arm-gcc-9.2_0.1.9_ubuntu-64.zip \
# Install base sysroot
&& unzip -o '*.zip' \
&& mv data/platforms/tizen-$TIZEN_VERSION/mobile/rootstraps/mobile-$TIZEN_VERSION-device.core/lib $TIZEN_SDK_SYSROOT \
&& mv data/platforms/tizen-$TIZEN_VERSION/mobile/rootstraps/mobile-$TIZEN_VERSION-device.core/usr $TIZEN_SDK_SYSROOT \
&& cp $TIZEN_SDK_SYSROOT/usr/lib/pkgconfig/openssl1.1.pc $TIZEN_SDK_SYSROOT/usr/lib/pkgconfig/openssl.pc \
# Install packages
&& unrpm *.rpm \
&& ln -sf libcap.so.2 usr/lib/libcap.so \
&& ln -sf libdns_sd.so.878.70.2 usr/lib/libdns_sd.so \
&& ln -sf libdns_sd.so.878.70.2 usr/lib/libdns_sd.so.878 \
&& cp -rf lib $TIZEN_SDK_SYSROOT \
&& cp -rf usr $TIZEN_SDK_SYSROOT \
# Cleanup
&& rm -rf /tmp/workdir \
&& : # last line

# ------------------------------------------------------------------------------
# Switch to the non-root user
USER $USER_NAME
WORKDIR $USER_HOME

# ------------------------------------------------------------------------------
# Setup tizen studio CLI
RUN set -x \
# Generate author certificate
&& tizen certificate --alias=CHIP --name=CHIP [email protected] --password=chiptizen \
# Add new security profile
&& tizen security-profiles add --active --name=CHIP --author=$HOME/tizen-sdk-data/keystore/author/author.p12 --password=chiptizen \
# Cleanup
&& : # last line
77 changes: 77 additions & 0 deletions integrations/docker/images/chip-build-tizen/secret-tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/python3
# Dummy Password Manager for Tizen Studio CLI

import os
import pickle
import sys
from argparse import ArgumentParser


class Secrets:

def __init__(self, filename: str):
self.filename = filename
self.secrets = {}

@staticmethod
def _build_key(label: str, **kw):
return label + ":" + str(tuple(sorted(kw.items())))

def load(self):
try:
with open(self.filename, "rb") as f:
self.secrets = pickle.load(f)
except (IOError, ValueError) as e:
print("ERROR: " + str(e), file=sys.stderr)

def save(self):
try:
with open(self.filename, "wb") as f:
pickle.dump(self.secrets, f)
except IOError as e:
print("ERROR: " + str(e), file=sys.stderr)

def clear(self, label: str, **kw):
key = self._build_key(label, **kw)
self.secrets.pop(key, None)

def store(self, label: str, password: str, **kw):
key = self._build_key(label, **kw)
self.secrets[key] = password

def lookup(self, label: str, **kw):
key = self._build_key(label, **kw)
return self.secrets.get(key, "")


parser = ArgumentParser()
subparsers = parser.add_subparsers(dest='command', required=True)

parser_clear = subparsers.add_parser("clear")
parser_clear.add_argument("-l", "--label", action='store', required=True)
parser_clear.add_argument("kw", nargs='*')

parser_store = subparsers.add_parser("store")
parser_store.add_argument("-l", "--label", action='store', required=True)
parser_store.add_argument("-p", "--password", action='store', required=True)
parser_store.add_argument("kw", nargs='*')

parser_lookup = subparsers.add_parser("lookup")
parser_lookup.add_argument("-l", "--label", action='store', required=True)
parser_lookup.add_argument("kw", nargs='*')

args = parser.parse_args()
kw = dict(zip(args.kw[:: 2], args.kw[1:: 2]))

secrets = Secrets(os.path.expanduser("~/.secretsdb"))
secrets.load()

if args.command == "clear":
secrets.clear(args.label, **kw)
secrets.save()
elif args.command == "store":
secrets.store(args.label, args.password, **kw)
secrets.save()
elif args.command == "lookup":
password = secrets.lookup(args.label, **kw)
print(password)
4 changes: 2 additions & 2 deletions integrations/docker/images/chip-build-vscode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COPY --from=p6 /opt/ModusToolbox /opt/ModusToolbox
COPY --from=telink /opt/telink/zephyrproject /opt/telink/zephyrproject
COPY --from=telink /opt/telink/zephyr-sdk-0.13.2 /opt/telink/zephyr-sdk-0.13.2

COPY --from=tizen /opt/tizen_sdk /opt/tizen_sdk
COPY --from=tizen /opt/tizen-sdk /opt/tizen-sdk

COPY --from=crosscompile /opt/ubuntu-21.04-aarch64-sysroot /opt/ubuntu-21.04-aarch64-sysroot

Expand Down Expand Up @@ -69,7 +69,7 @@ ENV PW_ENVIRONMENT_ROOT=/home/vscode/pigweed/env
ENV TELINK_ZEPHYR_BASE=/opt/telink/zephyrproject/zephyr
ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.13.2
ENV CY_TOOLS_PATHS="/opt/ModusToolbox/tools_2.4"
ENV TIZEN_HOME /opt/tizen_sdk
ENV TIZEN_SDK_ROOT /opt/tizen-sdk
ENV SYSROOT_AARCH64=/opt/ubuntu-21.04-aarch64-sysroot
ENV AMEBA_PATH=/opt/ameba/ambd_sdk_with_chip_non_NDA
ENV NXP_K32W061_SDK_ROOT=/opt/sdk/sdks
Expand Down
2 changes: 1 addition & 1 deletion integrations/docker/images/chip-build/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.64 Version bump reason: Update nRF Connect SDK
0.5.65 Version bump reason: [Tizen] Add Tizen Studio CLI to Tizen docker image
8 changes: 5 additions & 3 deletions scripts/build/builders/tizen.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ def __init__(self,
raise Exception("TSAN sanitizer not supported by Tizen toolchain")

def GnBuildArgs(self):
if 'TIZEN_HOME' not in os.environ:
if 'TIZEN_SDK_ROOT' not in os.environ:
raise Exception(
"Environment TIZEN_HOME missing, cannot build Tizen target")
"Environment TIZEN_SDK_ROOT missing, cannot build Tizen target")
tizen_sdk_root = os.environ['TIZEN_SDK_ROOT']
return self.extra_gn_options + [
'target_os="tizen"',
'target_cpu="%s"' % self.board.TargetCpuName(),
'sysroot="%s"' % os.environ['TIZEN_HOME'],
'tizen_sdk_root="%s"' % tizen_sdk_root,
'sysroot="%s"' % os.path.join(tizen_sdk_root, "sysroot"),
]

def build_outputs(self):
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def build_actual_output(root: str, out: str, args: List[str]) -> List[str]:
'PW_PROJECT_ROOT': root,
'ANDROID_NDK_HOME': 'TEST_ANDROID_NDK_HOME',
'ANDROID_HOME': 'TEST_ANDROID_HOME',
'TIZEN_HOME': 'TEST_TIZEN_HOME',
'TIZEN_SDK_ROOT': 'TEST_TIZEN_SDK_ROOT',
'TELINK_ZEPHYR_SDK_DIR': 'TELINK_ZEPHYR_SDK_DIR',
'SYSROOT_AARCH64': 'SYSROOT_AARCH64',
'NXP_K32W061_SDK_ROOT': 'TEST_NXP_K32W061_SDK_ROOT',
Expand Down
16 changes: 8 additions & 8 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -918,28 +918,28 @@ source "$ZEPHYR_BASE/zephyr-env.sh";
west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d {root}/examples/lighting-app/telink'

# Generating tizen-arm-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light

# Generating tizen-arm-light-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=is_asan=true target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=is_asan=true target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-asan

# Generating tizen-arm-light-no-ble
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-no-ble
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-no-ble

# Generating tizen-arm-light-no-ble-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false is_asan=true target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-no-ble-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false is_asan=true target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-no-ble-asan

# Generating tizen-arm-light-no-ble-no-wifi
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false chip_enable_wifi=false target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-no-ble-no-wifi
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false chip_enable_wifi=false target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-no-ble-no-wifi

# Generating tizen-arm-light-no-ble-no-wifi-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false chip_enable_wifi=false is_asan=true target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-no-ble-no-wifi-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_config_network_layer_ble=false chip_enable_wifi=false is_asan=true target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-no-ble-no-wifi-asan

# Generating tizen-arm-light-no-wifi
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_enable_wifi=false target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-no-wifi
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_enable_wifi=false target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-no-wifi

# Generating tizen-arm-light-no-wifi-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_enable_wifi=false is_asan=true target_os="tizen" target_cpu="arm" sysroot="TEST_TIZEN_HOME"' {out}/tizen-arm-light-no-wifi-asan
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux '--args=chip_enable_wifi=false is_asan=true target_os="tizen" target_cpu="arm" tizen_sdk_root="TEST_TIZEN_SDK_ROOT" sysroot="TEST_TIZEN_SDK_ROOT/sysroot"' {out}/tizen-arm-light-no-wifi-asan

# Building ameba-amebad-all-clusters
ninja -C {out}/ameba-amebad-all-clusters
Expand Down

0 comments on commit fb498b0

Please sign in to comment.