From b604c378d2623b311c4d728e3fc170c0aeef3d56 Mon Sep 17 00:00:00 2001 From: TaYaKi71751 Date: Wed, 13 Dec 2023 14:45:25 +0900 Subject: [PATCH] TEST --- .github/workflows/build.yml | 181 ++++++++++-------- .../database_download_page.dart | 4 +- lib/pages/database_download/decompress.dart | 60 ++++++ 3 files changed, 158 insertions(+), 87 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64c2919b1..361d364f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,53 +6,53 @@ on: merge_group: jobs: - ios-build: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - with: - ref: dev - - uses: subosito/flutter-action@v2 - with: - # flutter-version: '2.5.2' - channel: 'stable' - - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Preprocess - run: | - # cd lib/server - # wget -q ${{ secrets.SECRET_SALT }} - # wget -q ${{ secrets.SECRET_WSALT }} - # cd ../.. - cat << EOF > lib/server/salt.dart - String getValid(foo) {return foo;} - EOF - cat << EOF > lib/server/wsalt.dart - String getValid(foo) {return foo;} - EOF - python3 preprocess-ios.py - - name: Podfile - run: | - cd ios - rm Podfile.lock - flutter clean - flutter pub get - pod install - pod update - cd .. - - name: Build - run: | - flutter build ios --release --no-codesign - mkdir -p Payload - mv ./build/ios/iphoneos/Runner.app Payload - zip -r -y Payload.zip Payload/Runner.app - mv Payload.zip Payload.ipa - - name: Upload IPA - uses: actions/upload-artifact@v2 - with: - name: ipa-build - path: Payload.ipa + # ios-build: + # runs-on: macos-latest + # steps: + # - uses: actions/checkout@v2 + # with: + # ref: dev + # - uses: subosito/flutter-action@v2 + # with: + # # flutter-version: '2.5.2' + # channel: 'stable' + # - uses: actions/setup-python@v2 + # with: + # python-version: '3.8' + # - name: Preprocess + # run: | + # # cd lib/server + # # wget -q ${{ secrets.SECRET_SALT }} + # # wget -q ${{ secrets.SECRET_WSALT }} + # # cd ../.. + # cat << EOF > lib/server/salt.dart + # String getValid(foo) {return foo;} + # EOF + # cat << EOF > lib/server/wsalt.dart + # String getValid(foo) {return foo;} + # EOF + # python3 preprocess-ios.py + # - name: Podfile + # run: | + # cd ios + # rm Podfile.lock + # flutter clean + # flutter pub get + # pod install + # pod update + # cd .. + # - name: Build + # run: | + # flutter build ios --release --no-codesign + # mkdir -p Payload + # mv ./build/ios/iphoneos/Runner.app Payload + # zip -r -y Payload.zip Payload/Runner.app + # mv Payload.zip Payload.ipa + # - name: Upload IPA + # uses: actions/upload-artifact@v2 + # with: + # name: ipa-build + # path: Payload.ipa # https://github.com/AppImageCrafters/appimage-builder-flutter-example/blob/main/.github/workflows/appimage.yml linux-build: @@ -82,6 +82,17 @@ jobs: String getValid(foo) {return foo;} EOF python3 preprocess-linux.py + git clone https://github.com/project-violet/p7zip.git + cd p7zip + make + ls -la + cd .. + ls + mkdir -p ./assets/p7zip/linux/$(uname -m | cut -f1 -d \n) || true + find p7zip/bin/ + echo AAA + find ./assets/p7zip/linux + echo p7zip/bin/7za ./assets/p7zip/linux/$(uname -m | cut -f1 -d \n)/7za flutter build linux find ./build/linux/x64/release/plugins -type f -name '*.so' -exec cp {} ./build/linux/x64/release/bundle/lib/ \; - name: Save build Artifact @@ -109,41 +120,41 @@ jobs: # files: './*.AppImage*' # repo_token: ${{ secrets.GITHUB_TOKEN }} - android-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - ref: dev - - uses: actions/setup-java@v1 - with: - java-version: '12.x' - - uses: subosito/flutter-action@v1 - with: - # flutter-version: '2.5.2' - channel: 'stable' - - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Preprocess - run: | - # cd lib/server - # wget -q ${{ secrets.SECRET_SALT }} - # wget -q ${{ secrets.SECRET_WSALT }} - # cd ../.. - cat << EOF > lib/server/salt.dart - String getValid(foo) {return foo;} - EOF - cat << EOF > lib/server/wsalt.dart - String getValid(foo) {return foo;} - EOF - python3 preprocess-android.py - - name: Build - run: | - flutter clean - flutter build apk --release - - name: Upload APK - uses: actions/upload-artifact@v2 - with: - name: apk-build - path: ./build/app/outputs/apk/release/app-release.apk + # android-build: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # with: + # ref: dev + # - uses: actions/setup-java@v1 + # with: + # java-version: '12.x' + # - uses: subosito/flutter-action@v1 + # with: + # # flutter-version: '2.5.2' + # channel: 'stable' + # - uses: actions/setup-python@v2 + # with: + # python-version: '3.8' + # - name: Preprocess + # run: | + # # cd lib/server + # # wget -q ${{ secrets.SECRET_SALT }} + # # wget -q ${{ secrets.SECRET_WSALT }} + # # cd ../.. + # cat << EOF > lib/server/salt.dart + # String getValid(foo) {return foo;} + # EOF + # cat << EOF > lib/server/wsalt.dart + # String getValid(foo) {return foo;} + # EOF + # python3 preprocess-android.py + # - name: Build + # run: | + # flutter clean + # flutter build apk --release + # - name: Upload APK + # uses: actions/upload-artifact@v2 + # with: + # name: apk-build + # path: ./build/app/outputs/apk/release/app-release.apk diff --git a/lib/pages/database_download/database_download_page.dart b/lib/pages/database_download/database_download_page.dart index 53c6d6020..bd1461382 100644 --- a/lib/pages/database_download/database_download_page.dart +++ b/lib/pages/database_download/database_download_page.dart @@ -104,9 +104,9 @@ class DataBaseDownloadPageState extends State { Future downloadFileLinux() async { try { - await downloadFileLinuxWith('latest', true); + await downloadFileAndroidWith('latest', true); } catch(e){ - await downloadFileLinuxWith('old', false); + await downloadFileAndroidWith('old', false); } } diff --git a/lib/pages/database_download/decompress.dart b/lib/pages/database_download/decompress.dart index 6c710519d..09528a827 100644 --- a/lib/pages/database_download/decompress.dart +++ b/lib/pages/database_download/decompress.dart @@ -1,6 +1,7 @@ // This source code is a part of Project Violet. // Copyright (C) 2020-2023. violet-team. Licensed under the Apache-2.0 License. +import 'dart:convert'; import 'dart:ffi'; import 'dart:io'; import 'dart:isolate'; @@ -49,6 +50,23 @@ class P7zip { final soPath = await _checkSharedLibrary(); print(soPath); if (soPath == null) { + final binPath = await _checkBinary(); + if(binPath == null){ + return null; + } + final filesStr = files.join(' '); + Process process = await Process.start( + "/tmp/7za", + [ + "e $filesStr", + "-o$path" + ], + ); + final result = await process; + if(await result.stderr.transform(utf8.decoder).isEmpty) throw Error(); + await result.stdout + .transform(utf8.decoder) + .forEach(print); return null; } @@ -97,4 +115,46 @@ class P7zip { return libraryFile.path; } + Future _checkBinary() async { + if(!Platform.isLinux){ + return null; + } + + var _arch = await ((()async{ + var _a = ''; + // https://stackoverflow.com/questions/70247458/flutter-dart-print-output-of-all-child-processes-to-stdout + Process process = await Process.start( + "uname", + [ + "-m" + ], + ); + + await process.stdout + .transform(utf8.decoder) + .forEach((value){ + if(_a.isEmpty){ + _a = value.replaceAll('\r', '').replaceAll('\n', ''); + } + }); + if((_a.contains('arm') || _a.contains('aarch')) && (_a.contains('32') || _a.contains('v7'))) return 'armv7'; + if((_a.contains('arm') || _a.contains('aarch')) && (_a.contains('64') || _a.contains('v8'))) return 'armv8'; + if(_a == 'x86_64' || _a == 'amd64') return 'x86_64'; + if((_a.contains('i') || _a.contains('x')) && _a.contains('86') && !_a.contains('64')) return 'x86'; + })()); + final binaryPath = 'assets/p7zip/linux/$_arch/7za'; + final binaryContent = await rootBundle.load(binaryPath); + final tempDir = await getTemporaryDirectory(); + final binaryFile = File('${tempDir}/7za'); + if(await binaryFile.exists()){ + await binaryFile.delete(); + } + final createdFile = await binaryFile.create(); + final openFile = await createdFile.open(mode: FileMode.write); + final writtenFile = + await openFile.writeFrom(Uint8List.view(binaryContent.buffer)); + await writtenFile.close(); + + return binaryFile.path; + } }