Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ymauray committed Oct 9, 2022
0 parents commit bd77e40
Show file tree
Hide file tree
Showing 38 changed files with 1,979 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
RELEASING.md
build_focal.sh
30 changes: 30 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: 18a827f3933c19f51862dde3fa472197683249d6
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
- platform: linux
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
base_revision: 18a827f3933c19f51862dde3fa472197683249d6

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true,
},
"cmake.sourceDirectory": "${workspaceFolder}/linux"
}
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
SHELL := /usr/bin/env bash
VERSION := $(shell cat pubspec.yaml | grep "^version: " | cut -c 10- | sed 's/+/\-/')
SHORT_VERSION := $(shell xx="$(VERSION)"; arrVersion=($${xx//-/ }); echo $${arrVersion[0]};)
BUILD_ROOT := ../build-package
BASE_NAME := quickobs_$(SHORT_VERSION)
BUILD_DIR := $(BUILD_ROOT)/$(BASE_NAME)
BIN_TAR := $(BUILD_ROOT)/$(BASE_NAME).orig.tar
SRC_TAR := $(BUILD_ROOT)/$(BASE_NAME)-src.tar
FLUTTER := /opt/flutter/bin/flutter

version:
@echo VERSION is $(VERSION)
@echo SHORT_VERSION is $(SHORT_VERSION)
@echo BUILD_ROOT is $(BUILD_ROOT)
@echo type "make bin" to create binary package
@echo type "make ppa" to upload to launchpad

spawn:
echo "#! /bin/env bash" > /home/yannick/machines/focal/home/yannick/build.sh
echo "" >> /home/yannick/machines/focal/home/yannick/build.sh
echo "cd /opt/flutter-projects/quickobs" >> /home/yannick/machines/focal/home/yannick/build.sh
echo "make bin" >> /home/yannick/machines/focal/home/yannick/build.sh
sudo systemd-nspawn -D /home/yannick/machines/focal --resolv-conf=off --bind-ro=/home/yannick/machines/resolv.conf:/etc/resolv.conf --bind=/opt/flutter:/opt/flutter --bind=/opt/flutter-projects:/opt/flutter-projects -u yannick /home/yannick/build.sh

distclean:
$(FLUTTER) clean
rm -rf $(BUILD_ROOT)/*

quickobs: distclean
$(FLUTTER) pub get
$(FLUTTER) build linux --release

bin: quickobs
mkdir -p $(BUILD_DIR)
cp -a build/linux/x64/release/bundle/* $(BUILD_DIR)
cp -a assets/resources $(BUILD_DIR)
tar -C $(BUILD_ROOT) -c -v -f $(BIN_TAR) $(BASE_NAME)
xz -z $(BIN_TAR)

ppa: version
cp $(BIN_TAR).xz /mnt/data/dev/debianpackages/quickobs.deb/
cd /mnt/data/dev/debianpackages/quickobs.deb/quickobs ; \
dch -v $(VERSION) "New changelog message" ; \
vi debian/changelog ; \
for dist in focal jammy kinetic; do \
sed -i "1 s/^\(.*\)) UNRELEASED;\(.*\)\$$/\1~xxx1.0) xxx;\2/g" debian/changelog ; \
sed -i "1 s/~.*1\.0) .*;\(.*\)\$$/~$${dist}1.0) $$dist;\1/g" debian/changelog ; \
dpkg-buildpackage -d -S -sa ; \
dput ppa:yannick-mauray/quickobs ../quickobs_$(VERSION)~$${dist}1.0_source.changes ; \
done

download: version
for dist in focal jammy kinetic; do \
aria2c https://launchpad.net/~yannick-mauray/+archive/ubuntu/quickobs/+files/quickobs_$(VERSION)~$${dist}1.0_amd64.deb; \
done

src:
mkdir -p $(BUILD_ROOT)
tar -C .. -c -v -f $(SRC_TAR) --exclude .git --transform 's/^quickobs/$(BASE_NAME)/' quickobs
rm ${SRC_TAR}.xz
xz -z $(SRC_TAR)
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# quickobs

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
30 changes: 30 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
use_build_context_synchronously: false
public_member_api_docs: false

analyzer:
plugins:
- dart_code_metrics

dart_code_metrics:
anti-patterns:
- long-method
- long-parameter-list
metrics:
cyclomatic-complexity: 20
maximum-nesting-level: 5
number-of-parameters: 4
source-lines-of-code: 50
metrics-exclude:
- test/**
rules:
- newline-before-return
- no-boolean-literal-compare
- no-empty-block
- prefer-trailing-comma
- prefer-conditional-expressions
- no-equal-then-else

42 changes: 42 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:form_builder_validators/localization/l10n.dart';
import 'package:quickobs/page/main_page.dart';
import 'package:quickobs/provider/system_info_provider.dart';
import 'package:yaru/yaru.dart';

class App extends ConsumerWidget {
const App({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
final systemInfo = ref.watch(systemInfoProvider);

return YaruTheme(
builder: (context, yaru, _) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: yaru.theme,
darkTheme: yaru.darkTheme,
supportedLocales: const [Locale('en')],
localizationsDelegates: const [
...GlobalMaterialLocalizations.delegates,
GlobalWidgetsLocalizations.delegate,
FormBuilderLocalizations.delegate,
],
home: Builder(
builder: (context) {
return systemInfo.when(
data: (_) => const MainPage(),
error: (_, __) =>
const Center(child: CircularProgressIndicator()),
loading: () => const Center(child: CircularProgressIndicator()),
);
},
),
);
},
);
}
}
1 change: 1 addition & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const kBaseDirectory = 'baseDirectory';
8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:quickobs/app.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const ProviderScope(child: App()));
}
16 changes: 16 additions & 0 deletions lib/model/asset.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/widgets.dart';

@immutable
class Asset {
const Asset({
required String name,
required String browserDownloadUrl,
}) : _name = name,
_browserDownloadUrl = browserDownloadUrl;

final String _name;
final String _browserDownloadUrl;

String get name => _name;
String get browserDownloadUrl => _browserDownloadUrl;
}
19 changes: 19 additions & 0 deletions lib/model/downloaded_file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'dart:io';

import 'package:crypto/crypto.dart';
import 'package:flutter/widgets.dart';

@immutable
class DownloadedFile {
const DownloadedFile({
required File file,
required Digest digest,
}) : _file = file,
_digest = digest;

final File _file;
final Digest _digest;

File get file => _file;
Digest get digest => _digest;
}
55 changes: 55 additions & 0 deletions lib/model/installed_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'dart:convert';
import 'dart:io';

class InstalledVersion {
InstalledVersion({
required Directory directory,
required String version,
required String ubuntuVersion,
required String release,
}) : _directory = directory,
_version = version,
_ubuntuVersion = ubuntuVersion,
_release = release;

final Directory _directory;
final String _version;
final String _ubuntuVersion;
final String _release;

Directory get directory => _directory;
String get version => _version;
String get ubuntuVersion => _ubuntuVersion;
String get release => _release;

static Future<InstalledVersion?> fromDirectory(Directory directory) async {
final files = directory.listSync();
final manifest = files.where((file) => file.path.endsWith('manifest.txt'));
if (manifest.isEmpty) {
return null;
}
final manifestLine = await File(manifest.first.path)
.openRead()
.transform(utf8.decoder)
.transform(const LineSplitter())
.first;

final versionRegex = RegExp(
r'Portable OBS Studio (.*) for Ubuntu (.*) manifest \(r(.*)\)$',
);
final versionFound = versionRegex.hasMatch(manifestLine);
if (!versionFound) {
return null;
}
final version = versionRegex.firstMatch(manifestLine)!.group(1)!;
final ubuntuVersion = versionRegex.firstMatch(manifestLine)!.group(2)!;
final release = versionRegex.firstMatch(manifestLine)!.group(3)!;

return InstalledVersion(
directory: directory,
version: version,
ubuntuVersion: ubuntuVersion,
release: release,
);
}
}
17 changes: 17 additions & 0 deletions lib/model/latest_release.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter/widgets.dart';
import 'package:quickobs/model/asset.dart';

@immutable
class LatestRelease {
const LatestRelease({
required String name,
required List<Asset> assets,
}) : _name = name,
_assets = assets;

final String _name;
final List<Asset> _assets;

String get name => _name;
List<Asset> get assets => _assets;
}
19 changes: 19 additions & 0 deletions lib/model/system_info.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/widgets.dart';
import 'package:quickobs/model/latest_release.dart';

@immutable
class SystemInfo {
const SystemInfo({
required this.distro,
required this.osVersion,
required this.codeName,
required this.latestRelease,
required this.cacheSize,
});

final String distro;
final String osVersion;
final String codeName;
final LatestRelease latestRelease;
final int cacheSize;
}
Loading

0 comments on commit bd77e40

Please sign in to comment.