Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package WSL-DistroLauncher for openSUSE:Factory checked in at 2021-06-27 18:59:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/WSL-DistroLauncher (Old) and /work/SRC/openSUSE:Factory/.WSL-DistroLauncher.new.2625 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "WSL-DistroLauncher" Sun Jun 27 18:59:16 2021 rev:4 rq:902548 version:0.0.1+git20200918.2ed9a93 Changes: -------- --- /work/SRC/openSUSE:Factory/WSL-DistroLauncher/WSL-DistroLauncher.changes 2021-04-10 15:28:44.370474600 +0200 +++ /work/SRC/openSUSE:Factory/.WSL-DistroLauncher.new.2625/WSL-DistroLauncher.changes 2021-06-27 19:00:28.432385776 +0200 @@ -1,0 +2,29 @@ +Fri Jun 25 21:37:41 UTC 2021 - Jeff Kowalczyk <jkowalc...@suse.com> + +- Prepare distro-id and distro_name configure variables using bash + subst method from obs-service-kiwi_metainfo_helper and wsl-appx. + * PRETTY_NAME_BEFORE_PAREN + * PRETTY_NAME_BEFORE_PAREN_DASHED + +------------------------------------------------------------------- +Fri Jun 25 07:17:45 UTC 2021 - Jeff Kowalczyk <jkowalc...@suse.com> + +- Update to version 0.0.1+git20200918.2ed9a93: + * Run yast2-firstboot instead of useradd + * refactor QueryUid to be reusable + * SUSE adjustments + * replace wscanf_s, seems not defined in mingw + * Cross compiling the launcher + * Add Visual Studio 2019 Community support (#74) + * Update platformtoolset to use v142 (#60) + * Update README step 5 to set TargetName instead of ProjectName (#72) + * Update DistroLauncher/DistroLauncher.cpp to better check wsl.exe exit code + * Added prompt for input when wsl.exe fails to launch Linux process +- Drop patch files now obtained from openSUSE git repository + * drop 0001-Cross-compiling-the-launcher.patch + * drop 0002-replace-wscanf_s-seems-not-defined-in-mingw.patch + * drop 0003-SUSE-adjustments.patch + * drop 0004-refactor-QueryUid-to-be-reusable.patch + * drop 0005-Run-yast2-firstboot-instead-of-useradd.patch + +------------------------------------------------------------------- Old: ---- 0001-Cross-compiling-the-launcher.patch 0002-replace-wscanf_s-seems-not-defined-in-mingw.patch 0003-SUSE-adjustments.patch 0004-refactor-QueryUid-to-be-reusable.patch 0005-Run-yast2-firstboot-instead-of-useradd.patch WSL-DistroLauncher-0.0.1+git20200306.f858909.tar.xz New: ---- WSL-DistroLauncher-0.0.1+git20200918.2ed9a93.tar.xz _servicedata ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ WSL-DistroLauncher.spec ++++++ --- /var/tmp/diff_new_pack.mHXyt7/_old 2021-06-27 19:00:28.948386454 +0200 +++ /var/tmp/diff_new_pack.mHXyt7/_new 2021-06-27 19:00:28.952386459 +0200 @@ -18,7 +18,7 @@ Name: WSL-DistroLauncher # no official release yet -Version: 0.0.1+git20200306.f858909 +Version: 0.0.1+git20200918.2ed9a93 Release: 0 Summary: Windows Subsystem for Linux distro launcher License: MIT @@ -27,12 +27,6 @@ Source: WSL-DistroLauncher-%{version}.tar.xz Source1: icon.ico -Patch0: 0001-Cross-compiling-the-launcher.patch -Patch1: 0002-replace-wscanf_s-seems-not-defined-in-mingw.patch -Patch2: 0003-SUSE-adjustments.patch -Patch3: 0004-refactor-QueryUid-to-be-reusable.patch -Patch4: 0005-Run-yast2-firstboot-instead-of-useradd.patch - BuildRequires: autoconf BuildRequires: automake BuildRequires: mingw64-cross-binutils @@ -66,21 +60,37 @@ %build autoreconf -fi if [ -e /usr/lib/os-release ]; then - . /usr/lib/os-release + source /usr/lib/os-release else - . /etc/os-release + source /etc/os-release fi -# During prerelease phases, parens around RC etc. in PRETTY_NAME -# are not properly escaped if passed to mingw configure step. -# Bash substitution requires two steps: -# 1. Keep only alphanumeric characters and spaces -PRETTY_NAME_ALPHANUM="${PRETTY_NAME//[^a-zA-Z0-9- ]/}" -# 2. Replace spaces with hyphen -DISTRO_ID="${PRETTY_NAME_ALPHANUM// /-}" + +# PRETTY_NAME is embedded in WSL launcher executable Windows resource metadata. +# Modify PRETTY_NAME for allowed characters and stable name dropping SLE prerelease. +# During SLE prerelease phases, parens around RC etc. in PRETTY_NAME +# will not not be properly escaped if passed to mingw configure step. +# +# Reuse bash substitution pattern from obs-service-kiwi_metainfo_helper. +# +# PRETTY_NAME: openSUSE Leap 15.3 +# PRETTY_NAME_BEFORE_PAREN: openSUSE Leap 15.3 +# PRETTY_NAME_BEFORE_PAREN_DASHED: openSUSE-Leap-15.3 +# +# PRETTY_NAME: SUSE Linux Enterprise Server 15 SP3 (Snapshot16) +# PRETTY_NAME_BEFORE_PAREN: SUSE Linux Enterprise Server 15 SP3 +# PRETTY_NAME_BEFORE_PAREN_DASHED: SUSE-Linux-Enterprise-Server-15-SP3 +# +# Special case for SLE release labels e.g. RC1. Keep only up to (space) open paren. +# Provides a stable project name for third-party integrations e.g. app store submissions +PRETTY_NAME_BEFORE_PAREN="${PRETTY_NAME// (*/}" + +# Attribute distro-id must not contain spaces, replace with dash +PRETTY_NAME_BEFORE_PAREN_DASHED="${PRETTY_NAME_BEFORE_PAREN//[^[:alnum:].]/-}" + %{_mingw64_configure} --with-windmc=%{_mingw64_windmc} \ --with-windres=%{_mingw64_windres} \ - --with-distro-id="$DISTRO_ID" \ - --with-distro-name="$PRETTY_NAME" \ + --with-distro-id="$PRETTY_NAME_BEFORE_PAREN_DASHED" \ + --with-distro-name="$PRETTY_NAME_BEFORE_PAREN" \ --with-distro-icon="icon.ico" make %{?_smp_mflags} ++++++ WSL-DistroLauncher-0.0.1+git20200306.f858909.tar.xz -> WSL-DistroLauncher-0.0.1+git20200918.2ed9a93.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/.gitignore new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/.gitignore --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/.gitignore 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,298 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + + + +DistroLauncher/MSG*.bin +DistroLauncher/messages.rc +DistroLauncher/messages.h +*.lib +*.dll +*.exe +*.tar.gz \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/COPYING new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/COPYING --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/COPYING 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/COPYING 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistributionInfo.cpp new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistributionInfo.cpp --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistributionInfo.cpp 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistributionInfo.cpp 2020-09-19 03:38:03.000000000 +0200 @@ -9,30 +9,17 @@ { // Create the user account. DWORD exitCode; - std::wstring commandLine = L"/usr/sbin/adduser --quiet --gecos '' "; + std::wstring commandLine = L"/usr/sbin/useradd -m "; commandLine += userName; HRESULT hr = g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode); if ((FAILED(hr)) || (exitCode != 0)) { return false; } - // Add the user account to any relevant groups. - commandLine = L"/usr/sbin/usermod -aG adm,cdrom,sudo,dip,plugdev "; - commandLine += userName; - hr = g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode); - if ((FAILED(hr)) || (exitCode != 0)) { - - // Delete the user if the group add command failed. - commandLine = L"/usr/sbin/deluser "; - commandLine += userName; - g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode); - return false; - } - return true; } -ULONG DistributionInfo::QueryUid(std::wstring_view userName) +static ULONG _QueryUid(std::wstring command) { // Create a pipe to read the output of the launched process. HANDLE readPipe; @@ -40,9 +27,6 @@ SECURITY_ATTRIBUTES sa{sizeof(sa), nullptr, true}; ULONG uid = UID_INVALID; if (CreatePipe(&readPipe, &writePipe, &sa, 0)) { - // Query the UID of the supplied username. - std::wstring command = L"/usr/bin/id -u "; - command += userName; int returnValue = 0; HANDLE child; HRESULT hr = g_wslApi.WslLaunch(command.c_str(), true, GetStdHandle(STD_INPUT_HANDLE), writePipe, GetStdHandle(STD_ERROR_HANDLE), &child); @@ -64,7 +48,6 @@ buffer[bytesRead] = ANSI_NULL; try { uid = std::stoul(buffer, nullptr, 10); - } catch( ... ) { } } } @@ -76,3 +59,28 @@ return uid; } + +ULONG DistributionInfo::QueryUid(std::wstring_view userName) +{ + std::wstring command = L"/usr/bin/id -u "; + command += userName; + return _QueryUid(command); +} + +bool DistributionInfo::FirstBoot() +{ + DWORD exitCode; + std::wstring commandLine = L"/usr/lib/YaST2/startup/YaST2.Firstboot"; + HRESULT hr = g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode); + if ((FAILED(hr)) || (exitCode != 0)) { + return false; + } + + return true; +} + +ULONG DistributionInfo::QueryFistBootUid() +{ + std::wstring command = L"cat /run/wsl_firstboot_uid"; + return _QueryUid(command); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistributionInfo.h new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistributionInfo.h --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistributionInfo.h 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistributionInfo.h 2020-09-19 03:38:03.000000000 +0200 @@ -4,6 +4,7 @@ // #pragma once +#include "config.h" namespace DistributionInfo { @@ -13,14 +14,20 @@ // // WARNING: This value must not change between versions of your app, // otherwise users upgrading from older versions will see launch failures. - const std::wstring Name = L"MyDistribution"; + const std::wstring Name = DISTRO_NAME; // The title bar for the console window while the distribution is installing. - const std::wstring WindowTitle = L"My Distribution"; + const std::wstring WindowTitle = DISTRO_DISPLAY_NAME; // Create and configure a user account. bool CreateUser(std::wstring_view userName); - // Query the UID of the user account. + // Query the UID of a given user account ULONG QueryUid(std::wstring_view userName); -} \ No newline at end of file + + // Query the UID of the user account created on first boot + ULONG QueryFistBootUid(); + + // Configure distribution on first start + bool FirstBoot(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistroLauncher.cpp new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistroLauncher.cpp --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistroLauncher.cpp 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistroLauncher.cpp 2020-09-19 03:38:03.000000000 +0200 @@ -5,11 +5,10 @@ #include "stdafx.h" -// Commandline arguments: +// Commandline arguments: #define ARG_CONFIG L"config" #define ARG_CONFIG_DEFAULT_USER L"--default-user" #define ARG_INSTALL L"install" -#define ARG_INSTALL_ROOT L"--root" #define ARG_RUN L"run" #define ARG_RUN_C L"-c" @@ -17,10 +16,10 @@ // https://msdn.microsoft.com/en-us/library/windows/desktop/mt826874(v=vs.85).aspx WslApiLoader g_wslApi(DistributionInfo::Name); -static HRESULT InstallDistribution(bool createUser); +static HRESULT InstallDistribution(); static HRESULT SetDefaultUser(std::wstring_view userName); -HRESULT InstallDistribution(bool createUser) +HRESULT InstallDistribution() { // Register the distribution. Helpers::PrintMessage(MSG_STATUS_INSTALLING); @@ -36,19 +35,13 @@ return hr; } - // Create a user account. - if (createUser) { - Helpers::PrintMessage(MSG_CREATE_USER_PROMPT); - std::wstring userName; - do { - userName = Helpers::GetUserInput(MSG_ENTER_USERNAME, 32); - - } while (!DistributionInfo::CreateUser(userName)); - - // Set this user account as the default. - hr = SetDefaultUser(userName); - if (FAILED(hr)) { - return hr; + if (DistributionInfo::FirstBoot()) { + ULONG uid = DistributionInfo::QueryFistBootUid(); + if (uid != UID_INVALID) { + HRESULT hr = g_wslApi.WslConfigureDistribution(uid, WSL_DISTRIBUTION_FLAGS_DEFAULT); + if (FAILED(hr)) { + return hr; + } } } @@ -99,9 +92,7 @@ HRESULT hr = S_OK; if (!g_wslApi.WslIsDistributionRegistered()) { - // If the "--root" option is specified, do not create a user account. - bool useRoot = ((installOnly) && (arguments.size() > 1) && (arguments[1] == ARG_INSTALL_ROOT)); - hr = InstallDistribution(!useRoot); + hr = InstallDistribution(); if (FAILED(hr)) { if (hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)) { Helpers::PrintMessage(MSG_INSTALL_ALREADY_EXISTS); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistroLauncher.rc new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistroLauncher.rc --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistroLauncher.rc 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistroLauncher.rc 2020-09-19 03:38:03.000000000 +0200 @@ -51,7 +51,7 @@ // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_ICON1 ICON ".\images\icon.ico" +#include "distro.rc" #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistroLauncher.vcxproj new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistroLauncher.vcxproj --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/DistroLauncher.vcxproj 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/DistroLauncher.vcxproj 2020-09-19 03:38:03.000000000 +0200 @@ -29,27 +29,27 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> + <PlatformToolset>v142</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> + <PlatformToolset>v142</PlatformToolset> <CharacterSet>Unicode</CharacterSet> <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> + <PlatformToolset>v142</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v141</PlatformToolset> + <PlatformToolset>v142</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/Helpers.cpp new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/Helpers.cpp --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/Helpers.cpp 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/Helpers.cpp 2020-09-19 03:38:03.000000000 +0200 @@ -16,16 +16,19 @@ size_t bufferSize = maxCharacters + 1; std::unique_ptr<wchar_t[]> inputBuffer(new wchar_t[bufferSize]); std::wstring input; - if (wscanf_s(L"%s", inputBuffer.get(), (unsigned int)bufferSize) == 1) { + if (fgetws(inputBuffer.get(), (unsigned int)bufferSize, stdin) != NULL) { input = inputBuffer.get(); } +// XXX: check if that if needed. It's blocking as it is ... +#if 0 // Throw away any additional chracters that did not fit in the buffer. wchar_t wch; do { wch = getwchar(); } while ((wch != L'\n') && (wch != WEOF)); +#endif return input; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/Makefile.am new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/Makefile.am --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/Makefile.am 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,41 @@ +bin_PROGRAMS = DistroLauncher + +messages.rc: messages.mc + $(MC) $< + +messages.h: messages.rc + +# Hacky: no winres.h available with mingw, force include of winresrc.h +# to get the LANG_* and SUBLANG_* defines. +winres.h: + echo "#include <winresrc.h>" > winres.h + +DistroLauncher-res.$(OBJEXT): DistroLauncher.rc \ + messages.rc \ + distro.rc \ + resource.h \ + winres.h + $(RC) -D _UNICODE -D UNICODE -l "0x0409" -I $(DISTRO_ID) \ + --input-format rc -i DistroLauncher.rc \ + --output-format coff -o $@ + +BUILT_SOURCES = messages.h + +DistroLauncher_SOURCES = \ + config.h \ + DistroLauncher.cpp \ + DistributionInfo.cpp \ + DistributionInfo.h \ + Helpers.cpp \ + Helpers.h \ + resource.h \ + stdafx.cpp \ + stdafx.h \ + targetver.h \ + WslApiLoader.cpp \ + WslApiLoader.h \ + DistroLauncher.rc + +DistroLauncher_CPPFLAGS = -DMINGW_HAS_SECURE_API -municode -mconsole -m64 -std=c++17 -fpermissive +DistroLauncher_LDFLAGS = -municode -mconsole -m64 -static +DistroLauncher_LDADD = DistroLauncher-res.$(OBJEXT) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/config.h.in new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/config.h.in --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/config.h.in 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/config.h.in 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,4 @@ +#pragma once + +static const wchar_t * DISTRO_NAME = L"@DISTRO_ID@"; +static const wchar_t * DISTRO_DISPLAY_NAME = L"@DISTRO_NAME@"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/distro.rc.in new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/distro.rc.in --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/distro.rc.in 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/distro.rc.in 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1 @@ +IDI_ICON1 ICON "@DISTRO_ICON@" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/messages.mc new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/messages.mc --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/messages.mc 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/messages.mc 2020-09-19 03:38:03.000000000 +0200 @@ -28,10 +28,8 @@ <no args> Launches the user's default shell in the user's home directory. - install [--root] + install Install the distribuiton and do not launch the shell when complete. - --root - Do not create a user account and leave the default user set to root. run <command line> Run the provided command line in the current working directory. If no diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/stdafx.h new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/stdafx.h --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/stdafx.h 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/stdafx.h 2020-09-19 03:38:03.000000000 +0200 @@ -13,7 +13,8 @@ #include <stdio.h> #include <tchar.h> -#include <Windows.h> +#include <sec_api/wchar_s.h> +#include <windows.h> #include <stdio.h> #include <conio.h> #include <io.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/targetver.h new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/targetver.h --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/targetver.h 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/targetver.h 2020-09-19 03:38:03.000000000 +0200 @@ -5,4 +5,4 @@ // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. -#include <SDKDDKVer.h> +#include <sdkddkver.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/wslapi.h new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/wslapi.h --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/DistroLauncher/wslapi.h 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/DistroLauncher/wslapi.h 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,10 @@ +#pragma once + +typedef enum _WSL_DISTRIBUTION_FLAGS { + WSL_DISTRIBUTION_FLAGS_NONE = 0, + WSL_DISTRIBUTION_FLAGS_ENABLE_INTEROP = 1, + WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH = 2, + WSL_DISTRIBUTION_FLAGS_ENABLE_DRIVE_MOUNTING = 4 +} WSL_DISTRIBUTION_FLAGS; + +#define WSL_DISTRIBUTION_FLAGS_DEFAULT WSL_DISTRIBUTION_FLAGS_ENABLE_INTEROP | WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH | WSL_DISTRIBUTION_FLAGS_ENABLE_DRIVE_MOUNTING diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/LICENSE new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/LICENSE --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/LICENSE 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/LICENSE 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/Makefile.am new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/Makefile.am --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/Makefile.am 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1 @@ +SUBDIRS=DistroLauncher diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/NEWS new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/NEWS --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/NEWS 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/NEWS 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,36 @@ +What's NEWs? +===================================================================== +This file comprises a basic version history for the adaptations +created by SUSE for the WSL-DistroLauncher code created by Microsoft. + +- Original Code: https://github.com/Microsoft/WSL-DistroLauncher +- SUSE Adaptations: https://build.opensuse.org/package/show/Virtualization:WSL/wsl-launcher + +The Open Build Service project that SUSE uses to build openSUSE +for Windows Subsystem for Linux can be found at: +https://build.opensuse.org/package/show/Virtualization:WSL + +The versions listed below are listed in reverse chronilogical +order; meaning the newest is at the top. + +> Bon appetit! + - Dennis Ritchie, Anti-Forward to the UNIX-HATERS Handbook + + +Version 1.1.0 +--------------------------------------------------------------------- +`Tue, 13 Aug 2019 07:23:59 -0700`<br> +`sle-ms \at\ suse \dot\ com` + +1. Changed the `NEWS` file to markdown format. +1. Rebased the code from Microsoft; + See "Original Code" reference at top. + +Version 1.0.0 +--------------------------------------------------------------------- +`Wed, 11 Oct 2017 14:00:30 +0200`<br> +Cedric Bosdannat: `<cedric \dot\ bosdonnat \at\ free \dot\ fr>` + +1. Created project +1. Ease build using GNU and mingw toolchain + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/README.md new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/README.md --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/README.md 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/README.md 2020-09-19 03:38:03.000000000 +0200 @@ -1,176 +1,176 @@ -# WSL Distro Launcher Reference Implementation -## Introduction -This is the C++ reference implementation for a Windows Subsystem for Linux (WSL) distribution installer/launcher application. Every distro package must include a launcher app, which is responsible for completing installation & registration of your distro with WSL, and for launching new distro instances atop WSL. - -Once you've built your distro launcher, packaged it along with the required art assets, manifest, and distro.tar.gz, and digitally signed the package, you will be able to sideload your distro on your own machine(s). - -## Important! -Before publishing your distro to the Windows Store, you must first reach-out to and get approval from the WSL team: wslpartn...@microsoft.com. - -Without testing and approval from the WSL team, distros submitted to the store will be rejected. This process is required in order to ensure the quality and integrity of the WSL distro ecosystem, and to safeguard our users. - -## Goals -The goal of this project is to enable: - -* Linux distribution owners to package and submit an application that runs on top of WSL to the Microsoft Store -* Developers to create custom Linux distributions that can be sideloaded onto their dev machine - -## Contents -This reference launcher provides the following functionality: -(where `launcher.exe` is replaced by the distro-specific name) - -* `launcher.exe` - - Launches the user's default shell in the user's home directory. - -* `launcher.exe install [--root]` - - Install the distribution and do not launch the shell when complete. - - `--root`: Do not create a user account and leave the default user set to root. - -* `launcher.exe run <command line>` - - Run the provided command line in the current working directory. If no command line is provided, the default shell is launched. - - Everything after `run` is passed to WslLaunchInteractive. - -* `launcher.exe config [setting [value]]` - - Configure settings for this distribution. - - Settings: - - `--default-user <username>`: Sets the default user to <username>. This must be an existing user. - -* `launcher.exe help` - - Print usage information. - -## Launcher Outline -This is the basic flow of how the launcher code is set up. - -1. If the distribution is not registered with WSL, register it. Registration extracts the tar.gz file that is included in your distribution appx. -2. Once the distro is successfully registered, any other pre-launch setup is performed in `InstallDistribution()`. This is where distro-specific setup can be performed. As an example, the reference implementation creates a user account and sets this user account as the default for the distro. - - Note: The commands used to query and create user accounts in this reference implementation are Ubuntu-specific; change as necessary to match the needs of your distro. -3. Once the distro is configured, parse any other command-line arguments. The details of these arguments are described above, in the [Introduction](#Introduction). - -## Project Structure -The distro launcher is comprised of two Visual Studio projects - `launcher` and `DistroLauncher-Appx`. The `launcher` project builds the actual executable that is run when a user launches the app. The `DistroLauncher-Appx` builds the distro package with all the correctly scaled assets and other dependencies. Code changes will be built in the `launcher` project (under `DistroLauncher/`). Manifest changes are applied in the `DistroLauncher-Appx` project (under `DistroLauncher-Appx/`). - -## Getting Started -1. Generate a test certificate: - 1. In Visual Studio, open `DistroLauncher-Appx/MyDistro.appxmanifest` - 1. Select the Packaging tab - 1. Select "Choose Certificate" - 1. Click the Configure Certificate drop down and select Create test certificate. - -2. Edit your distribution-specific information in `DistributionInfo.h` and `DistributionInfo.cpp`. **NOTE: The `DistributionInfo::Name` variable must uniquely identify your distribution and cannot change from one version of your app to the next.** - > Note: The examples for creating a user account and querying the UID are from an Ubuntu-based system, and may need to be modified to work appropriately on your distribution. - -3. Add an icon (.ico) and logo (.png) to the `/images` directory. The logo will be used in the Start Menu and the taskbar for your launcher, and the icon will appear on the Console window. - > Note: The icon must be named `icon.ico`. - -4. Pick the name you'd like to make this distro callable from the command line. For the rest of the README, I'll be using `mydistro` or `mydistro.exe`. **This is the name of your executable** and should be unique. - -5. Make sure to change the name of the project in the `DistroLauncher-Appx/DistroLauncher-Appx.vcxproj` file to the name of your executable we picked in step 4. By default, the lines should look like: - -``` xml -<PropertyGroup Label="Globals"> - ... - <ProjectName>mydistro</ProjectName> -</PropertyGroup> -``` - -So, if I wanted to instead call my distro "TheBestDistroEver", I'd change this to: -``` xml -<PropertyGroup Label="Globals"> - ... - <ProjectName>TheBestDistroEver</ProjectName> -</PropertyGroup> -``` - -> Note: **DO NOT** change the ProjectName of the `DistroLauncher/DistroLauncher.vcxproj` from the value `launcher`. Doing so will break the build, as the DistroLauncher-Appx project is looking for the output of this project as `launcher.exe`. - -6. Update `MyDistro.appxmanifest`. There are several properties that are in the manifest that will need to be updated with your specific values: - 1. Note the `Identity Publisher` value (by default, `"CN=DistroOwner"`). We'll need that for testing the application. - 1. Ensure `<desktop:ExecutionAlias Alias="mydistro.exe" />` ends in ".exe". This is the command that will be used to launch your distro from the command line and should match the executable name we picked in step 4. - 1. Make sure each of the `Executable` values matches the executable name we picked in step 4. - -7. Copy your tar.gz containing your distro into the root of the project and rename it to `install.tar.gz`. - -## Setting up your Windows Environment -You will need a Windows environment to test that your app installs and works as expected. To set up a Windows environment for testing you can follow the steps from the [Windows Dev Center](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines). - -> Note: If you are using Hyper-V you can use the new VM gallery to easily spin up a Windows instance. - -Also, to allow your locally built distro package to be manually side-loaded, ensure you've enabled Developer Mode in the Settings app (sideloading won't work without it). - -## Build and Test - -To help building and testing the DistroLauncher project, we've included several scripts to automate some tasks. You can either choose to use these scripts from the command line, or work directly in Visual Studio, whatever your preference is. - -> **Note**: some sideloading/deployment steps don't work if you mix and match Visual Studio and the command line for development. If you run into errors while trying to deploy your app after already deploying it once, the easiest step is usually just to uninstall the previously sideloaded version and try again. - -### Building the Project (Command line): -To compile the project, you can simply type `build` in the root of the project to use MSBuild to build the solution. This is useful for verifying that your application compiles. It will also build an appx for you to sideload on your dev machine for testing. - -> Note: We recommend that you build your launcher from the "Developer Command Prompt for Visual Studio" which can be launched from the start menu. This command-prompt sets up several path and environment variables to make building easier and smoother. - -`build.bat` assumes that MSBuild is installed at one of the following paths: -`%ProgramFiles*%\MSBuild\14.0\bin\msbuild.exe` or -`%ProgramFiles*%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe` or -`%ProgramFiles*%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe`. - -If that's not the case, then you will need to modify that script. - -Once you've completed the build, the packaged appx should be placed in a directory like `WSL-DistroLauncher\x64\Release\DistroLauncher-Appx` and should be named something like `DistroLauncher-Appx_1.0.0.0_x64.appx`. Simply double click that appx file to open the sideloading dialog. - -You can also use the PowerShell cmdlet `Add-AppxPackage` to register your appx: -``` powershell -powershell Add-AppxPackage x64\Debug\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Debug.appx -``` - -### Building Project (Visual Studio): - -You can also easily build and deploy the distro launcher from Visual Studio. To sideload your appx on your machine for testing, all you need to do is right-click on the "Solution (DistroLauncher)" in the Solution Explorer and click "Deploy Solution". This should build the project and sideload it automatically for testing. - -In order run your solution under the Visual Studio debugger, you will need to copy your install.tar.gz file into your output folder, for example: `x64\Debug`. **NOTE: If you have registered your distribution by this method, you will need to manually unregister it via wslconfig.exe /unregister** - -### Installing & Testing -You should now have a finished appx sideloaded on your machine for testing. - -To install your distro package, double click on the signed appx and click "Install". Note that this only installs the appx on your system - it doesn't unzip the tar.gz or register the distro yet. - -You should now find your distro in the Start menu, and you can launch your distro by clicking its Start menu tile or executing your distro from the command line by entering its name into a Cmd/PowerShell Console. - -When you first run your newly installed distro, it is unpacked and registered with WSL. This can take a couple of minutes while all your distro files are unpacked and copied to your drive. - -Once complete, you should see a Console window with your distro running inside it. - -### Publishing -If you are a distro vendor and want to publish your distro to the Windows store, you will need to complete some pre-requisite steps to ensure the quality and integrity of the WSL distro ecosystem, and to safeguard our users: - -#### Publishing Pre-Requisites -1. Reach out to the WSL team to introduce your distro, yourself, and your team -1. Agree with the WSL team on a testing and publishing plan -1. Complete any required paperwork -1. Sign up for an "Company" Windows Developer Account https://developer.microsoft.com/en-us/store/register. - > Note: This can take a week or more since you'll be required to confirm your organization's identity with an independent verification service via email and/or telephone. - -#### Publishing Code changes -You'll also need to change a few small things in your project to prepare your distro for publishing to the Windows store - -1. In your appxmanifest, you will need to change the values of the Identity field to match your identity in your Windows Store account: - -``` xml -<Identity Name="1234YourCompanyName.YourAppName" - Version="1.0.1.0" - Publisher="CN=12345678-045C-ABCD-1234-ABCDEF987654" - ProcessorArchitecture="x64" /> -``` - - > **NOTE**: Visual Studio can update this for you! You can do that by right-clicking on "DistroLauncher-Appx (Universal Windows)" in the solution explorer and clicking on "Store... Associate App with the Store..." and following the wizard. - -2. You will either need to run `build rel` from the command line to generate the Release version of your appx or use Visual Studio directly to upload your package to the store. You can do this by right-clicking on "DistroLauncher-Appx (Universal Windows)" in the solution explorer and clicking on "Store... Create App Packages..." and following the wizard. - -Also, make sure to check out the [Notes for uploading to the Store](https://github.com/Microsoft/WSL-DistroLauncher/wiki/Notes-for-uploading-to-the-Store) page on our wiki for more information. - -# Issues & Contact -Any bugs or problems discovered with the Launcher should be filed in this project's Issues list. The team will be notified and will respond to the reported issue within 3 (US) working days. - -You may also reach out to our team alias at wslpartn...@microsoft.com for questions related to submitting your app to the Microsoft Store. - -# Contributing -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [openc...@microsoft.com](mailto:openc...@microsoft.com) with any additional questions or comments. +# WSL Distro Launcher Reference Implementation +## Introduction +This is the C++ reference implementation for a Windows Subsystem for Linux (WSL) distribution installer/launcher application. Every distro package must include a launcher app, which is responsible for completing installation & registration of your distro with WSL, and for launching new distro instances atop WSL. + +Once you've built your distro launcher, packaged it along with the required art assets, manifest, and distro.tar.gz, and digitally signed the package, you will be able to sideload your distro on your own machine(s). + +## Important! +Before publishing your distro to the Windows Store, you must first reach-out to and get approval from the WSL team: wslpartn...@microsoft.com. + +Without testing and approval from the WSL team, distros submitted to the store will be rejected. This process is required in order to ensure the quality and integrity of the WSL distro ecosystem, and to safeguard our users. + +## Goals +The goal of this project is to enable: + +* Linux distribution owners to package and submit an application that runs on top of WSL to the Microsoft Store +* Developers to create custom Linux distributions that can be sideloaded onto their dev machine + +## Contents +This reference launcher provides the following functionality: +(where `launcher.exe` is replaced by the distro-specific name) + +* `launcher.exe` + - Launches the user's default shell in the user's home directory. + +* `launcher.exe install [--root]` + - Install the distribution and do not launch the shell when complete. + - `--root`: Do not create a user account and leave the default user set to root. + +* `launcher.exe run <command line>` + - Run the provided command line in the current working directory. If no command line is provided, the default shell is launched. + - Everything after `run` is passed to WslLaunchInteractive. + +* `launcher.exe config [setting [value]]` + - Configure settings for this distribution. + - Settings: + - `--default-user <username>`: Sets the default user to <username>. This must be an existing user. + +* `launcher.exe help` + - Print usage information. + +## Launcher Outline +This is the basic flow of how the launcher code is set up. + +1. If the distribution is not registered with WSL, register it. Registration extracts the tar.gz file that is included in your distribution appx. +2. Once the distro is successfully registered, any other pre-launch setup is performed in `InstallDistribution()`. This is where distro-specific setup can be performed. As an example, the reference implementation creates a user account and sets this user account as the default for the distro. + - Note: The commands used to query and create user accounts in this reference implementation are Ubuntu-specific; change as necessary to match the needs of your distro. +3. Once the distro is configured, parse any other command-line arguments. The details of these arguments are described above, in the [Introduction](#Introduction). + +## Project Structure +The distro launcher is comprised of two Visual Studio projects - `launcher` and `DistroLauncher-Appx`. The `launcher` project builds the actual executable that is run when a user launches the app. The `DistroLauncher-Appx` builds the distro package with all the correctly scaled assets and other dependencies. Code changes will be built in the `launcher` project (under `DistroLauncher/`). Manifest changes are applied in the `DistroLauncher-Appx` project (under `DistroLauncher-Appx/`). + +## Getting Started +1. Generate a test certificate: + 1. In Visual Studio, open `DistroLauncher-Appx/MyDistro.appxmanifest` + 1. Select the Packaging tab + 1. Select "Choose Certificate" + 1. Click the Configure Certificate drop down and select Create test certificate. + +2. Edit your distribution-specific information in `DistributionInfo.h` and `DistributionInfo.cpp`. **NOTE: The `DistributionInfo::Name` variable must uniquely identify your distribution and cannot change from one version of your app to the next.** + > Note: The examples for creating a user account and querying the UID are from an Ubuntu-based system, and may need to be modified to work appropriately on your distribution. + +3. Add an icon (.ico) and logo (.png) to the `/images` directory. The logo will be used in the Start Menu and the taskbar for your launcher, and the icon will appear on the Console window. + > Note: The icon must be named `icon.ico`. + +4. Pick the name you'd like to make this distro callable from the command line. For the rest of the README, I'll be using `mydistro` or `mydistro.exe`. **This is the name of your executable** and should be unique. + +5. Make sure to change the name of the project in the `DistroLauncher-Appx/DistroLauncher-Appx.vcxproj` file to the name of your executable we picked in step 4. By default, the lines should look like: + +``` xml +<PropertyGroup Label="Globals"> + ... + <TargetName>mydistro</TargetName> +</PropertyGroup> +``` + +So, if I wanted to instead call my distro "TheBestDistroEver", I'd change this to: +``` xml +<PropertyGroup Label="Globals"> + ... + <TargetName>TheBestDistroEver</TargetName> +</PropertyGroup> +``` + +> Note: **DO NOT** change the ProjectName of the `DistroLauncher/DistroLauncher.vcxproj` from the value `launcher`. Doing so will break the build, as the DistroLauncher-Appx project is looking for the output of this project as `launcher.exe`. + +6. Update `MyDistro.appxmanifest`. There are several properties that are in the manifest that will need to be updated with your specific values: + 1. Note the `Identity Publisher` value (by default, `"CN=DistroOwner"`). We'll need that for testing the application. + 1. Ensure `<desktop:ExecutionAlias Alias="mydistro.exe" />` ends in ".exe". This is the command that will be used to launch your distro from the command line and should match the executable name we picked in step 4. + 1. Make sure each of the `Executable` values matches the executable name we picked in step 4. + +7. Copy your tar.gz containing your distro into the root of the project and rename it to `install.tar.gz`. + +## Setting up your Windows Environment +You will need a Windows environment to test that your app installs and works as expected. To set up a Windows environment for testing you can follow the steps from the [Windows Dev Center](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines). + +> Note: If you are using Hyper-V you can use the new VM gallery to easily spin up a Windows instance. + +Also, to allow your locally built distro package to be manually side-loaded, ensure you've enabled Developer Mode in the Settings app (sideloading won't work without it). + +## Build and Test + +To help building and testing the DistroLauncher project, we've included several scripts to automate some tasks. You can either choose to use these scripts from the command line, or work directly in Visual Studio, whatever your preference is. + +> **Note**: some sideloading/deployment steps don't work if you mix and match Visual Studio and the command line for development. If you run into errors while trying to deploy your app after already deploying it once, the easiest step is usually just to uninstall the previously sideloaded version and try again. + +### Building the Project (Command line): +To compile the project, you can simply type `build` in the root of the project to use MSBuild to build the solution. This is useful for verifying that your application compiles. It will also build an appx for you to sideload on your dev machine for testing. + +> Note: We recommend that you build your launcher from the "Developer Command Prompt for Visual Studio" which can be launched from the start menu. This command-prompt sets up several path and environment variables to make building easier and smoother. + +`build.bat` assumes that MSBuild is installed at one of the following paths: +`%ProgramFiles*%\MSBuild\14.0\bin\msbuild.exe` or +`%ProgramFiles*%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe` or +`%ProgramFiles*%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe`. + +If that's not the case, then you will need to modify that script. + +Once you've completed the build, the packaged appx should be placed in a directory like `WSL-DistroLauncher\x64\Release\DistroLauncher-Appx` and should be named something like `DistroLauncher-Appx_1.0.0.0_x64.appx`. Simply double click that appx file to open the sideloading dialog. + +You can also use the PowerShell cmdlet `Add-AppxPackage` to register your appx: +``` powershell +powershell Add-AppxPackage x64\Debug\DistroLauncher-Appx\DistroLauncher-Appx_1.0.0.0_x64_Debug.appx +``` + +### Building Project (Visual Studio): + +You can also easily build and deploy the distro launcher from Visual Studio. To sideload your appx on your machine for testing, all you need to do is right-click on the "Solution (DistroLauncher)" in the Solution Explorer and click "Deploy Solution". This should build the project and sideload it automatically for testing. + +In order run your solution under the Visual Studio debugger, you will need to copy your install.tar.gz file into your output folder, for example: `x64\Debug`. **NOTE: If you have registered your distribution by this method, you will need to manually unregister it via wslconfig.exe /unregister** + +### Installing & Testing +You should now have a finished appx sideloaded on your machine for testing. + +To install your distro package, double click on the signed appx and click "Install". Note that this only installs the appx on your system - it doesn't unzip the tar.gz or register the distro yet. + +You should now find your distro in the Start menu, and you can launch your distro by clicking its Start menu tile or executing your distro from the command line by entering its name into a Cmd/PowerShell Console. + +When you first run your newly installed distro, it is unpacked and registered with WSL. This can take a couple of minutes while all your distro files are unpacked and copied to your drive. + +Once complete, you should see a Console window with your distro running inside it. + +### Publishing +If you are a distro vendor and want to publish your distro to the Windows store, you will need to complete some pre-requisite steps to ensure the quality and integrity of the WSL distro ecosystem, and to safeguard our users: + +#### Publishing Pre-Requisites +1. Reach out to the WSL team to introduce your distro, yourself, and your team +1. Agree with the WSL team on a testing and publishing plan +1. Complete any required paperwork +1. Sign up for an "Company" Windows Developer Account https://developer.microsoft.com/en-us/store/register. + > Note: This can take a week or more since you'll be required to confirm your organization's identity with an independent verification service via email and/or telephone. + +#### Publishing Code changes +You'll also need to change a few small things in your project to prepare your distro for publishing to the Windows store + +1. In your appxmanifest, you will need to change the values of the Identity field to match your identity in your Windows Store account: + +``` xml +<Identity Name="1234YourCompanyName.YourAppName" + Version="1.0.1.0" + Publisher="CN=12345678-045C-ABCD-1234-ABCDEF987654" + ProcessorArchitecture="x64" /> +``` + + > **NOTE**: Visual Studio can update this for you! You can do that by right-clicking on "DistroLauncher-Appx (Universal Windows)" in the solution explorer and clicking on "Store... Associate App with the Store..." and following the wizard. + +2. You will either need to run `build rel` from the command line to generate the Release version of your appx or use Visual Studio directly to upload your package to the store. You can do this by right-clicking on "DistroLauncher-Appx (Universal Windows)" in the solution explorer and clicking on "Store... Create App Packages..." and following the wizard. + +Also, make sure to check out the [Notes for uploading to the Store](https://github.com/Microsoft/WSL-DistroLauncher/wiki/Notes-for-uploading-to-the-Store) page on our wiki for more information. + +# Issues & Contact +Any bugs or problems discovered with the Launcher should be filed in this project's Issues list. The team will be notified and will respond to the reported issue within 3 (US) working days. + +You may also reach out to our team alias at wslpartn...@microsoft.com for questions related to submitting your app to the Microsoft Store. + +# Contributing +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [openc...@microsoft.com](mailto:openc...@microsoft.com) with any additional questions or comments. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/build.bat new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/build.bat --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/build.bat 2020-03-06 22:00:41.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/build.bat 2020-09-19 03:38:03.000000000 +0200 @@ -30,6 +30,10 @@ set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\MSBuild.exe" goto :FOUND_MSBUILD ) +if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" ( + set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" + goto :FOUND_MSBUILD +) if exist "%ProgramFiles(x86)%\MSBuild\14.0\bin" ( set MSBUILD="%ProgramFiles(x86)%\MSBuild\14.0\bin\msbuild.exe" goto :FOUND_MSBUILD diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/configure.ac new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/configure.ac --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/configure.ac 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/configure.ac 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,52 @@ +AC_INIT([DistroLauncher], [1.0.0]) +AM_INIT_AUTOMAKE([foreign]) + +AC_PROG_CXX +AC_CHECK_PROG(ICONV_CHECK, iconv, yes) +if test x"$ICONV_CHECK" != "xyes"; then + AC_MSG_ERROR([iconv could not be found]) +fi + + +AC_ARG_WITH([distro-id], + [AC_HELP_STRING([--with-distro-id="MyDistro.1.0"], + ["Short name of the distribution, to be used as a unique ID."])], + [], [with_distro_id="MyDistro.1.0"]) +AC_SUBST([DISTRO_ID], ["$with_distro_id"]) + +AC_ARG_WITH([distro-name], + [AC_HELP_STRING([--with-distro-name="My Distro Name"], + ["Display name of the distribution."])], + [], [with_distro_name="My Distro Name"]) +AC_SUBST([DISTRO_NAME], ["$with_distro_name"]) + +AC_ARG_WITH([distro-icon], + [AC_HELP_STRING([--with-distro-icon="path/to/distro/icon"], + ["Icon of the distribution in ico format."])], + [], [with_distro_icon="images/icon.ico"]) +AC_SUBST([DISTRO_ICON], ["$with_distro_icon"]) + + +# +# Look for windmc and windres +# +AC_ARG_WITH([windmc], + [AC_HELP_STRING([--with-windmc="/path/to/windmc"], + ["Path to the windmc binary."])], + [], + [with_windmc="windmc"]) +AC_SUBST([MC], ["$with_windmc"]) + +AC_ARG_WITH([windres], + [AC_HELP_STRING([--with-windres="/path/to/windres"], + ["Path to the windres binary."])], + [], + [with_windres="windres"]) +AC_SUBST([RC], ["$with_windres"]) + + +AC_CONFIG_FILES([Makefile + DistroLauncher/Makefile + DistroLauncher/distro.rc + DistroLauncher/config.h]) +AC_OUTPUT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSL-DistroLauncher-0.0.1+git20200306.f858909/update-files.sh new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/update-files.sh --- old/WSL-DistroLauncher-0.0.1+git20200306.f858909/update-files.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/WSL-DistroLauncher-0.0.1+git20200918.2ed9a93/update-files.sh 2020-09-19 03:38:03.000000000 +0200 @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Update ChangeLog file +git log '--pretty=format:%cd %an <%ae>%n%n%s%n%b%n' --date=short > ChangeLog +sed -i '/(cherry picked/d' ChangeLog + +# Update AUTHORS +git log --pretty=format:'%aN <%aE>' | sort | uniq > AUTHORS + ++++++ _service ++++++ --- /var/tmp/diff_new_pack.mHXyt7/_old 2021-06-27 19:00:29.108386664 +0200 +++ /var/tmp/diff_new_pack.mHXyt7/_new 2021-06-27 19:00:29.108386664 +0200 @@ -1,10 +1,11 @@ <services> <service name="tar_scm" mode="disabled"> - <param name="url">https://github.com/microsoft/WSL-DistroLauncher.git</param> + <param name="url">https://github.com/openSUSE/WSL-DistroLauncher.git</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">f858909d675f8d80e0666d2258bc43abf9c5e132</param> + <param name="revision">master</param> <param name="versionformat">0.0.1+git%cd.%h</param> + <param name="changesgenerate">enable</param> </service> <service name="recompress" mode="disabled"> <param name="compression">xz</param> ++++++ _servicedata ++++++ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/openSUSE/WSL-DistroLauncher.git</param> <param name="changesrevision">518b0fcc270fc5f62ddab3ddc84dbb95b729d1f8</param></service></servicedata>