Skip to content

Commit

Permalink
✨ Finish WSL2 Linux Kernel Install
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Jul 25, 2024
1 parent ebfb2e5 commit 62efae5
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 137 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ target/
*/**/messages/

app.config.json
*.msi
3 changes: 3 additions & 0 deletions assets/i18n/en_US/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ install.auto_install: Auto Install (Admin)
install.install_linux_distro: Install Linux Distribution
install.online: Install Online
install.file: Import from File
install.upgrade_wsl2_kernel: Upgrade WSL2 Linux Kernel
install.manual: Manual Install
install.automate: Automate Install
3 changes: 3 additions & 0 deletions assets/i18n/zh_CN/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ install.auto_install: 自动安装 (管理员)
install.install_linux_distro: 安装 Linux 发行版
install.online: 在线安装
install.file: 从文件导入
install.upgrade_wsl2_kernel: 更新 WSL2 Linux 内核
install.manual: 手动安装
install.automate: 自动安装
5 changes: 5 additions & 0 deletions lib/models/config.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:arche/arche.dart';
import 'package:flutter/material.dart';
import 'package:system_info2/system_info2.dart';

class AppConfigs {
final ConfigEntryGenerator _generator;
Expand All @@ -20,4 +21,8 @@ class AppConfigs {

static const defaultDistroInfoUrl =
"https://raw.githubusercontent.com/microsoft/WSL/master/distributions/DistributionInfo.json";
static String wslLinuxKernelUpdateInstallerUrl = SysInfo.kernelArchitecture ==
ProcessorArchitecture.arm
? "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_arm64.msi"
: "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi";
}
291 changes: 154 additions & 137 deletions lib/views/pages/install.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:system_info2/system_info2.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:wslconfigurer/i18n/i18n.dart';
import 'package:wslconfigurer/models/config.dart';
import 'package:wslconfigurer/models/distribution.dart';
import 'package:wslconfigurer/views/widgets/basic.dart';
import 'package:wslconfigurer/views/widgets/divider.dart';
import 'package:wslconfigurer/views/widgets/optfeat.dart';
import 'package:wslconfigurer/views/widgets/process.dart';
import 'package:wslconfigurer/windows/ms_open.dart';
import 'package:wslconfigurer/windows/msi.dart';
import 'package:wslconfigurer/windows/utf16.dart';

class InstallPage extends StatefulWidget {
Expand All @@ -25,165 +29,178 @@ class _InstallPageState extends State<InstallPage> {
Widget build(BuildContext context) {
return CheckOptionalFeatureWidget(
nextWidget: ScrollableContainer(
padding: const EdgeInsets.all(8),
key: const ValueKey(true),
children: [
ListTile(
leading: const Icon(FontAwesomeIcons.section),
title: context.i18nText("install.install_linux_distro"),
title: context.i18nText("install.upgrade_wsl2_kernel"),
trailing: Text(SysInfo.rawKernelArchitecture),
),
Padding(
padding: const EdgeInsets.all(8),
Card.filled(
child: Column(
children: [
ListTile(
title: context.i18nText("install.online"),
trailing: IconButton(
onPressed: () => LinuxDistribution.distributions
.reload()
.then((_) => setState(() {})),
icon: const Icon(Icons.refresh))),
FutureBuilder(
future: LinuxDistribution.distributions.getValue(),
builder: (context, snapshot) {
var data = snapshot.data;
if (data == null) {
return const CircularProgressIndicator();
}
title: context.i18nText("install.manual"),
trailing: IconButton(
onPressed: () => launchUrlString(
AppConfigs.wslLinuxKernelUpdateInstallerUrl),
icon: const Icon(Icons.open_in_browser),
),
),
ListTile(
title: context.i18nText("install.automate"),
trailing: IconButton(
onPressed: () {
ComplexDialog.instance
.withContext(context: context)
.withChild(
DownloadMSIProgressDialog(
AppConfigs.wslLinuxKernelUpdateInstallerUrl,
logPath: "installer.log",
),
)
.copy(barrierDismissible: false)
.prompt();
},
icon: const Icon(Icons.install_desktop),
),
)
],
),
),
divider8,
ListTile(
leading: const Icon(FontAwesomeIcons.section),
title: context.i18nText("install.install_linux_distro"),
),
Column(
children: [
ListTile(
title: context.i18nText("install.online"),
trailing: IconButton(
onPressed: () => LinuxDistribution.distributions
.reload()
.then((_) => setState(() {})),
icon: const Icon(Icons.refresh))),
FutureBuilder(
future: LinuxDistribution.distributions.getValue(),
builder: (context, snapshot) {
var data = snapshot.data;
if (data == null) {
return const CircularProgressIndicator();
}

return Card.filled(
child: AnimationLimiter(
child: Column(
children: AnimationConfiguration.toStaggeredList(
duration: const Duration(milliseconds: 375),
childAnimationBuilder: (widget) => SlideAnimation(
horizontalOffset: 50.0,
child: FadeInAnimation(
child: widget,
),
return Card.filled(
child: AnimationLimiter(
child: Column(
children: AnimationConfiguration.toStaggeredList(
duration: const Duration(milliseconds: 375),
childAnimationBuilder: (widget) => SlideAnimation(
horizontalOffset: 50.0,
child: FadeInAnimation(
child: widget,
),
children: data
.map(
(distro) => ListTile(
title: Text(distro.friendlyName),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
onPressed: () {
var messager =
ScaffoldMessenger.of(context);
messager.clearSnackBars();
messager.showSnackBar(
const SnackBar(
content: Text("Copyied!"),
),
);
),
children: data
.map(
(distro) => ListTile(
title: Text(distro.friendlyName),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
onPressed: () {
var messager =
ScaffoldMessenger.of(context);
messager.clearSnackBars();
messager.showSnackBar(
const SnackBar(
content: Text("Copyied!"),
),
);

Clipboard.setData(ClipboardData(
text:
"wsl.exe --install -d ${distro.name} --no-launch"));
},
icon: const Icon(Icons.copy),
),
IconButton(
onPressed: () => ComplexDialog
.instance
.copy(barrierDismissible: false)
.text(
context: context,
content:
ProcessCommandRunWidget(
executable: "wsl.exe",
arguments: [
"--install",
"-d",
distro.name,
"--no-launch"
],
codec: utf16,
),
Clipboard.setData(ClipboardData(
text:
"wsl.exe --install -d ${distro.name} --no-launch"));
},
icon: const Icon(Icons.copy),
),
IconButton(
onPressed: () => ComplexDialog.instance
.copy(barrierDismissible: false)
.text(
context: context,
content: ProcessCommandRunWidget(
executable: "wsl.exe",
arguments: [
"--install",
"-d",
distro.name,
"--no-launch"
],
codec: utf16,
),
icon: const Icon(Icons.terminal),
),
IconButton(
onPressed: () => openMSStoreProduct(
distro.storeAppId),
icon: const Icon(Icons.store),
),
],
),
),
icon: const Icon(Icons.terminal),
),
IconButton(
onPressed: () => openMSStoreProduct(
distro.storeAppId),
icon: const Icon(Icons.store),
),
],
),
)
.toList(),
),
),
)
.toList(),
),
),
);
},
),
ListTile(
title: context.i18nText("install.file"),
trailing: const Text("TODO"),
),
const Card.filled(
child: Column(
children: [
ListTile(
title: Text("Import from tar"),
trailing: IconButton(
onPressed: null, icon: Icon(Icons.file_open)),
),
ListTile(
title: Text("Import from vhdx"),
trailing: IconButton(
onPressed: null, icon: Icon(Icons.file_open)),
)
],
),
),
divider8,
const ListTile(
leading: Icon(FontAwesomeIcons.section),
title: Text("Upgrade to WSL2"),
trailing: Text("TODO"),
),
);
},
),
ListTile(
title: context.i18nText("install.file"),
trailing: const Text("TODO"),
),
const Card.filled(
child: Column(
children: [
ListTile(
title: Text("Import from tar"),
trailing: IconButton(
onPressed: null, icon: Icon(Icons.file_open)),
),
ListTile(
title: Text("Import from vhdx"),
trailing: IconButton(
onPressed: null, icon: Icon(Icons.file_open)),
)
],
),
const Card.filled(
child: Column(
children: [
ListTile(
title: Text("Mannual"),
),
ListTile(
title: Text("Automate"),
)
],
),
)
],
),
),
],
),
divider8,
ListTile(
leading: const Icon(FontAwesomeIcons.section),
title: context.i18nText("Install Essential Packages(Optional)"),
),
Padding(
padding: const EdgeInsets.all(8),
child: Card.filled(
child: Column(
children: [
ListTile(
title: const Text("C (GCC)"),
trailing: IconButton(
onPressed: () {}, icon: const Icon(Icons.copy)),
),
ListTile(
title: const Text("C (Clang)"),
trailing: IconButton(
onPressed: () {}, icon: const Icon(Icons.copy)),
),
],
),
Card.filled(
child: Column(
children: [
ListTile(
title: const Text("C (GCC)"),
trailing: IconButton(
onPressed: () {}, icon: const Icon(Icons.copy)),
),
ListTile(
title: const Text("C (Clang)"),
trailing: IconButton(
onPressed: () {}, icon: const Icon(Icons.copy)),
),
],
),
),
],
Expand Down
Loading

0 comments on commit 62efae5

Please sign in to comment.