File wsl-appx.spec of Package wsl-appx

# spec file for package wsl-appx
# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via
# needssslcertforbuild

Name:           wsl-appx
Version:        1.1.0
Release:        0
License:        MIT
Summary:        SUSE on Windows application
Group:          Productivity/Other
Source:         openSUSE.tar.gz
Patch0:         substitutable.patch
BuildRequires:  mingw64-filesystem
BuildRequires:  wsl-launcher
BuildRequires:  wsl-launcher-debug
BuildRequires:  fb-util-for-appx
BuildRequires:  opensuse-leap-image
BuildRequires:  openSUSE-release
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%define exe_name DistroLauncher.exe

Windows Store application providing SLES or openSUSE.

%setup -q -n openSUSE
%patch0 -p1
# This is dirty. The CN of the AppxManifest needs to match the
# signing certificate's CN. In OBS the CN is the project name. The
# project itself may not have a cert so we can't use %_project. So
# we abuse %vendor which is the project whith the key.
eval `grep ^PRETTY_NAME /usr/lib/os-release`
sed -i -e "s/@PRETTY_NAME@/${PRETTY_NAME}/g;s/@APPID@/$APPID/g;s/@PUBLISHER@/$PUBLISHER/g" AppxManifest.xml
cat AppxManifest.xml

if [ -e %{_sourcedir}/_projectcert.pem ]; then
	openssl x509 -in %{_sourcedir}/_projectcert.pem -noout -subject -nameopt multiline


# Get the binary
cp %{_mingw64_bindir}/DistroLauncher.exe .

## Get the rootfs tarball
mkdir docker
tar -xf /usr/share/suse-docker-images/native/*.tar.xz -C docker
tarball=$(find docker -size +10M)
mv ${tarball} install.tar.gz
rm -rf docker

# Create a filemap
find * -type f | awk 'BEGIN { print "[Files]" } /filemap.txt/ { next; } { print "\"" $0 "\" \"" $0 "\"" }' > filemap.txt

# TODO So far .pri files are generated by VS and added to the source
# it would be way better to have them generated here with an opensource tool

eval `grep ^PRETTY_NAME /usr/lib/os-release`

appx -o "$APPXNAME" -f filemap.txt

APPXNAME=(*.appx) # it's an array but we'll only use the first one
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/appx
cp "$APPXNAME" $RPM_BUILD_ROOT%{_datadir}/appx
cp "$APPXNAME" %{_rpmdir}/../OTHER/"$APPXNAME"
if [ -e %{_sourcedir}/_projectcert.pem ]; then
	cp %{_sourcedir}/_projectcert.pem %{_rpmdir}/../OTHER/"$APPXNAME.pem"