mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
ready for more pkg manager
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import 'package:toolbox/data/model/distribution.dart';
|
||||
import 'package:toolbox/data/model/server/dist.dart';
|
||||
|
||||
class UpgradePkgInfo {
|
||||
final String _raw;
|
||||
final Distribution _dist;
|
||||
final Dist _dist;
|
||||
|
||||
late String package;
|
||||
late String nowVersion;
|
||||
@@ -11,12 +11,15 @@ class UpgradePkgInfo {
|
||||
|
||||
UpgradePkgInfo(this._raw, this._dist) {
|
||||
switch (_dist) {
|
||||
case Distribution.debian:
|
||||
case Distribution.unknown:
|
||||
case Dist.debian:
|
||||
case Dist.ubuntu:
|
||||
_parseApt();
|
||||
break;
|
||||
case Distribution.rehl:
|
||||
case Dist.centos:
|
||||
_parseYum();
|
||||
break;
|
||||
default:
|
||||
throw Exception('Unsupported dist: $_dist');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
enum Distribution {
|
||||
unknown,
|
||||
debian,
|
||||
rehl,
|
||||
}
|
||||
|
||||
const debianDistList = [
|
||||
'debian',
|
||||
'ubuntu',
|
||||
'linuxmint',
|
||||
'elementary',
|
||||
'raspbian',
|
||||
'armbian'
|
||||
];
|
||||
|
||||
const rehlDistList = [
|
||||
'redhat',
|
||||
'fedora',
|
||||
'centos',
|
||||
'scientificlinux',
|
||||
'rhel',
|
||||
'oraclelinux'
|
||||
];
|
||||
30
lib/data/model/server/dist.dart
Normal file
30
lib/data/model/server/dist.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
enum Dist {
|
||||
debian,
|
||||
ubuntu,
|
||||
centos,
|
||||
fedora,
|
||||
opensuse,
|
||||
kali,
|
||||
wrt,
|
||||
armbian,
|
||||
arch,
|
||||
freebsd,
|
||||
/// Rocky Linux
|
||||
rocky;
|
||||
|
||||
String? get iconPath {
|
||||
return 'assets/linux/$name.png';
|
||||
}
|
||||
}
|
||||
|
||||
extension StringX on String {
|
||||
Dist? get dist {
|
||||
final lower = toLowerCase();
|
||||
for (final dist in Dist.values) {
|
||||
if (lower.contains(dist.name)) {
|
||||
return dist;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user