From 4824aa16c9bd9fac8e2580009035862dd4bcf05d Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sat, 8 Apr 2023 22:18:02 -0500 Subject: [PATCH] stream line linux install scripts and make reusable templates; update drone: sha512, android pkg name, use commit date; dpeloy to same dir --- .drone.yml | 39 +++++++++---------- linux/cwtch | 2 + linux/cwtch.home.sh | 3 -- linux/cwtch.sys.desktop | 10 ----- linux/cwtch.sys.sh | 3 -- linux/cwtch.tails.sh | 3 -- ...ch.home.desktop => cwtch.template.desktop} | 2 +- linux/cwtch.template.sh | 3 ++ linux/install-home.sh | 17 +------- linux/install-sys.sh | 14 +------ linux/install-tails.sh | 18 ++------- linux/install.sh | 36 +++++++++++++++++ linux/package-release.sh | 6 +-- 13 files changed, 69 insertions(+), 87 deletions(-) delete mode 100755 linux/cwtch.home.sh delete mode 100755 linux/cwtch.sys.desktop delete mode 100755 linux/cwtch.sys.sh delete mode 100755 linux/cwtch.tails.sh rename linux/{cwtch.home.desktop => cwtch.template.desktop} (89%) create mode 100755 linux/cwtch.template.sh create mode 100755 linux/install.sh diff --git a/.drone.yml b/.drone.yml index e35cb8eb..32609d65 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,7 +31,7 @@ steps: commands: - ./fetch-tor.sh - echo `git describe --tags --abbrev=1` > VERSION - - echo `date +%G-%m-%d-%H-%M` > BUILDDATE + - echo `git log -1 --format=%cd --date=format:%G-%m-%d-%H-%M` > COMMIT_DATE - flutter pub get - mkdir deploy - ./fetch-libcwtch-go.sh @@ -52,7 +52,7 @@ steps: - name: deps path: /root/.pub-cache commands: - - flutter build linux --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat BUILDDATE` + - flutter build linux --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat COMMIT_DATE` - linux/package-release.sh - mkdir -p deploy/cwtch - cp -r build/linux/x64/release/bundle/* deploy/cwtch @@ -66,7 +66,6 @@ steps: - name: deps path: /root/.pub-cache commands: - - ./fetch-tor.sh # Run 01_general, 02_global_settings, and 04_profile_mgmt features... - ./run-tests-headless.sh "01_general|02_global_settings|04_profile_mgmt" @@ -96,12 +95,12 @@ steps: - echo $upload_jks_file_b64 > upload-keystore.jks.b64 - base64 -i --decode upload-keystore.jks.b64 > android/app/upload-keystore.jks - sed -i "s/%jks-password%/$upload_jks_pass/g" android/key.properties - - flutter build appbundle --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat BUILDDATE` + - flutter build appbundle --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat COMMIT_DATE` # cant do debug for final release, this is just a stop gap - - flutter build apk --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat BUILDDATE` + - flutter build apk --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat COMMIT_DATE` # or build apk --split-per-abi ? - - cp build/app/outputs/bundle/release/app-release.aab deploy/ - - cp build/app/outputs/apk/release/app-release.apk deploy/ + - cp build/app/outputs/bundle/release/app-release.aab deploy/cwtch-`cat ../VERSION`.aad + - cp build/app/outputs/apk/release/app-release.apk deploy/cwtch-`cat ../VERSION`.apk #- cp build/app/outputs/flutter-apk/app-debug.apk deploy/android - name: widget-tests @@ -128,13 +127,13 @@ steps: - echo $BUILDFILES_KEY > ~/id_rsab64 - base64 -d ~/id_rsab64 > ~/id_rsa - chmod 400 ~/id_rsa - - export DIR=flwtch-`cat BUILDDATE`-`cat VERSION` + - export DIR=flwtch-`cat COMMIT_DATE`-`cat VERSION` - mv deploy $DIR - cp -r coverage/html $DIR/coverage-tests - cp -r test/failures $DIR/test-failures || true - cd $DIR - - find . -type f -exec sha256sum {} \; > ./../sha256s.txt - - mv ./../sha256s.txt . + - find . -type f -exec sha512sum {} \; > ./../sha512s.txt + - mv ./../sha512s.txt . - cd .. - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/ @@ -197,7 +196,7 @@ steps: image: openpriv/flutter-desktop:windows-sdk30-fstable-3.7.1 commands: - git describe --tags --abbrev=1 > VERSION - - powershell -command "Get-Date -Format 'yyyy-MM-dd-HH-mm'" > BUILDDATE + - git log -1 --format=%cd --date=format:'%Y-%m-%d-%H-%M' > COMMIT_DATE - .\fetch-tor-win.ps1 - .\fetch-libcwtch-go.ps1 @@ -206,9 +205,9 @@ steps: commands: - flutter pub get - $Env:version += type .\VERSION - - $Env:builddate += type .\BUILDDATE + - $Env:commitdate += type .\COMMIT_DATE - $Env:releasedir = "build\\windows\\runner\\Release\\" - - flutter build windows --dart-define BUILD_VER=$Env:version --dart-define BUILD_DATE=$Env:builddate + - flutter build windows --dart-define BUILD_VER=$Env:version --dart-define BUILD_DATE=$Env:commitdate - copy windows\libCwtch.dll $Env:releasedir # flutter hasn't worked out it's packaging of required dll's so we have to resort to this manual nonsense # https://github.com/google/flutter-desktop-embedding/issues/587 @@ -233,13 +232,13 @@ steps: from_secret: pfx_pass commands: - $Env:version += type .\VERSION - - $Env:builddate += type .\BUILDDATE + - $Env:commitdate += type .\COMMIT_DATE - $Env:releasedir = "build\\windows\\runner\\Release\\" - $Env:zip = 'cwtch-' + $Env:version + '.zip' - $Env:zipsha = $Env:zip + '.sha512' - $Env:msix = 'cwtch-install-' + $Env:version + '.msix' - $Env:msixsha = $Env:msix + '.sha512' - - $Env:buildname = 'flwtch-win-' + $Env:builddate + '-' + $Env:version + - $Env:buildname = 'flwtch-' + $Env:commitdate + '-' + $Env:version - $Env:builddir = $Env:buildname - echo $Env:pfx > codesign.pfx.b64 - certutil -decode codesign.pfx.b64 codesign.pfx @@ -318,7 +317,7 @@ steps: commands: - ./fetch-tor-macos.sh - echo `git describe --tags --abbrev=1` > VERSION - - echo `date +%G-%m-%d-%H-%M` > BUILDDATE + - echo `git log -1 --format=%cd --date=format:%G-%m-%d-%H-%M` > COMMIT_DATE - export PATH=$PATH:/Users/Dan/development/flutter/bin - flutter pub get - mkdir deploy @@ -331,11 +330,11 @@ steps: - export GEM_HOME=$HOME/.gem - export PATH=$GEM_HOME/ruby/2.6.0/bin:$PATH - flutter config --enable-macos-desktop - - flutter build macos --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat BUILDDATE` + - flutter build macos --dart-define BUILD_VER=`cat VERSION` --dart-define BUILD_DATE=`cat COMMIT_DATE` - export PATH=$PATH:/usr/local/bin #create-dmg - macos/package-release.sh - mkdir -p deploy - - mv Cwtch.dmg deploy + - mv Cwtch.dmg deploy/Cwtch-`cat BUILD_VER`.dmg - name: deploy-buildfiles environment: @@ -348,11 +347,11 @@ steps: - echo $BUILDFILES_KEY > ~/id_rsab64 - base64 -d ~/id_rsab64 > ~/id_rsa - chmod 400 ~/id_rsa - - export DIR=flwtch-macos-`cat BUILDDATE`-`cat VERSION` + - export DIR=flwtch-`cat COMMIT_DATE`-`cat VERSION` - mv deploy $DIR - cd $DIR - find . -type f -exec shasum -a 512 {} \; > ./../sha512s.txt - - mv ./../sha512s.txt . + - mv ./../mac-sha512s.txt . - cd .. - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa $DIR buildfiles@build.openprivacy.ca:/home/buildfiles/buildfiles/ diff --git a/linux/cwtch b/linux/cwtch index 358bd37b..3c9e1ec9 100755 --- a/linux/cwtch +++ b/linux/cwtch @@ -1,3 +1,5 @@ #!/bin/sh +# Script to run cwtch directly from package tarball directory + exec env LD_LIBRARY_PATH=./lib/:./lib/Tor ./lib/cwtch diff --git a/linux/cwtch.home.sh b/linux/cwtch.home.sh deleted file mode 100755 index 3df2ef61..00000000 --- a/linux/cwtch.home.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec env LD_LIBRARY_PATH=~/.local/lib/cwtch/:~/.local/lib/cwtch/Tor ~/.local/lib/cwtch/cwtch diff --git a/linux/cwtch.sys.desktop b/linux/cwtch.sys.desktop deleted file mode 100755 index b944b91e..00000000 --- a/linux/cwtch.sys.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Name=Cwtch -Comment=Metadata Resistant Chat -Exec=/usr/bin/cwtch -Icon=cwtch -Terminal=false -Categories=Network;InstantMessaging; -Keywords=Internet;IM;Instant Messaging;Messaging;Chat diff --git a/linux/cwtch.sys.sh b/linux/cwtch.sys.sh deleted file mode 100755 index c3b43577..00000000 --- a/linux/cwtch.sys.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec env LD_LIBRARY_PATH=/usr/lib/cwtch:/usr/lib/cwtch/Tor /usr/lib/cwtch/cwtch diff --git a/linux/cwtch.tails.sh b/linux/cwtch.tails.sh deleted file mode 100755 index ee3f419b..00000000 --- a/linux/cwtch.tails.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Start Cwtch with Tails -exec env CWTCH_TAILS=true LD_LIBRARY_PATH=~/.local/lib/cwtch/:~/.local/lib/cwtch/Tor ~/.local/lib/cwtch/cwtch \ No newline at end of file diff --git a/linux/cwtch.home.desktop b/linux/cwtch.template.desktop similarity index 89% rename from linux/cwtch.home.desktop rename to linux/cwtch.template.desktop index 16ee3e1d..d17af64c 100755 --- a/linux/cwtch.home.desktop +++ b/linux/cwtch.template.desktop @@ -3,7 +3,7 @@ Version=1.0 Type=Application Name=Cwtch Comment=Metadata Resistant Chat -Exec=~/.local/bin/cwtch +Exec=PREFIX/bin/cwtch Icon=cwtch Terminal=false Categories=Network;InstantMessaging; diff --git a/linux/cwtch.template.sh b/linux/cwtch.template.sh new file mode 100755 index 00000000..79cde3f4 --- /dev/null +++ b/linux/cwtch.template.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec env LD_LIBRARY_PATH=PREFIX/lib/cwtch/:PREFIX/lib/cwtch/Tor PREFIX/lib/cwtch/cwtch diff --git a/linux/install-home.sh b/linux/install-home.sh index 8fd20a30..a3753ef9 100755 --- a/linux/install-home.sh +++ b/linux/install-home.sh @@ -1,18 +1,3 @@ #!/bin/sh -mkdir -p ~/.local/bin -sed "s|~|$HOME|g" cwtch.home.sh > ~/.local/bin/cwtch -chmod a+x ~/.local/bin/cwtch - -mkdir -p ~/.local/share/icons -cp cwtch.png ~/.local/share/icons - -mkdir -p ~/.local/share/cwtch -cp -r data ~/.local/share/cwtch - -mkdir -p ~/.local/lib/cwtch -cp -r lib/* ~/.local/lib/cwtch - -mkdir -p ~/.local/share/applications -sed "s|~|$HOME|g" cwtch.home.desktop > $HOME/.local/share/applications/cwtch.desktop -chmod a+x $HOME/.local/share/applications/cwtch.desktop \ No newline at end of file +INSTALL_PREFIX=$HOME/.local DESKTOP_PREFIX=$INSTALL_PREFIX ./install.sh \ No newline at end of file diff --git a/linux/install-sys.sh b/linux/install-sys.sh index 47f0ff0f..0566bdc8 100755 --- a/linux/install-sys.sh +++ b/linux/install-sys.sh @@ -1,15 +1,3 @@ #!/bin/sh -cp cwtch.sys.sh /usr/bin/cwtch -chmod a+x /usr/bin/cwtch - -cp cwtch.png /usr/share/icons - -mkdir -p /usr/share/cwtch -cp -r data /usr/share/cwtch - -mkdir -p /usr/lib/cwtch -cp -r lib/* /usr/lib/cwtch - -cp cwtch.sys.desktop /usr/share/applications/cwtch.desktop -chmod a+x /usr/share/applications/cwtch.desktop +INSTALL_PREFIX=$HOME/usr DESKTOP_PREFIX=$INSTALL_PREFIX ./install.sh diff --git a/linux/install-tails.sh b/linux/install-tails.sh index 3835cd6b..6df9fcee 100755 --- a/linux/install-tails.sh +++ b/linux/install-tails.sh @@ -1,21 +1,9 @@ #!/bin/sh -mkdir -p ~/.local/bin -sed "s|~|$HOME|g" cwtch.home.sh > ~/.local/bin/cwtch -chmod a+x ~/.local/bin/cwtch +INSTALL_PREFIX=$HOME/.local DESKTOP_PREFIX=$INSTALL_PREFIX ./install.sh -mkdir -p ~/.local/share/icons -cp cwtch.png ~/.local/share/icons - -mkdir -p ~/.local/share/cwtch -cp -r data ~/.local/share/cwtch - -mkdir -p ~/.local/lib/cwtch -cp -r lib/* ~/.local/lib/cwtch - -mkdir -p ~/.local/share/applications -sed "s|~|$HOME|g" cwtch.home.desktop > $HOME/.local/share/applications/cwtch.desktop -chmod a+x $HOME/.local/share/applications/cwtch.desktop +# Add CWTCH_TAILS=true to run script +sed -i "s|env LD|env CWTCH_TAILS=true LD|g" $INSTALL_PREFIX/bin/cwtch # Tails needs to be have been setup up with an Administration account # https://tails.boum.org/doc/first_steps/welcome_screen/administration_password/ diff --git a/linux/install.sh b/linux/install.sh new file mode 100755 index 00000000..aaf96499 --- /dev/null +++ b/linux/install.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# Script to install Cwtch to assigned location, taking the cwtch.template.* files and customizing them appropriately +# Requires args +# INSTALL_PREFIX: the directory to install everything under +# DESKTOP_PREFIX: the directoy to tell the .destkop file things are installed in (usually the same, but could +# differ in cases of chroots or installing to a directory to be packaged and installed later (.deb prep) + +if [ -z ${INSTALL_PREFIX} ]; then + echo "\$INSTALL_PREFIX unset, required" + exit +fi + +if [ -z ${DESKTOP_PREFIX} ]; then + echo "\$DESKTOP_PREFIX unset, required" + exit +fi + +echo "Installing Cwtch to INSTALL_PREFIX: $INSTALL_PREFIX with DESKTOP_PREFIX: $DESKTOP_PREFIX" + +mkdir -p $INSTALL_PREFIX/bin +sed "s|PREFIX|$DESKTOP_PREFIX|g" cwtch.template.sh > $INSTALL_PREFIX/bin/cwtch +chmod a+x $INSTALL_PREFIX/bin/cwtch + +mkdir -p $INSTALL_PREFIX/share/icons +cp cwtch.png $INSTALL_PREFIX/share/icons + +mkdir -p $INSTALL_PREFIX/share/cwtch +cp -r data $INSTALL_PREFIX/share/cwtch + +mkdir -p $INSTALL_PREFIX/lib/cwtch +cp -r lib/* $INSTALL_PREFIX/lib/cwtch + +mkdir -p $INSTALL_PREFIX/share/applications +sed "s|PREFIX|$DESKTOP_PREFIX|g" cwtch.template.desktop > $INSTALL_PREFIX/share/applications/cwtch.desktop +chmod a+x $INSTALL_PREFIX/share/applications/cwtch.desktop diff --git a/linux/package-release.sh b/linux/package-release.sh index 31a5b740..191a4823 100755 --- a/linux/package-release.sh +++ b/linux/package-release.sh @@ -1,9 +1,9 @@ #!/bin/sh mv build/linux/x64/release/bundle/cwtch build/linux/x64/release/bundle/lib/cwtch -cp linux/*.desktop build/linux/x64/release/bundle/ -cp linux/cwtch.*.sh build/linux/x64/release/bundle/ -cp linux/install-*.sh build/linux/x64/release/bundle/ +cp linux/cwtch.template.desktop build/linux/x64/release/bundle/ +cp linux/cwtch.template.sh build/linux/x64/release/bundle/ +cp linux/install*.sh build/linux/x64/release/bundle/ cp linux/cwtch-*.yml build/linux/x64/release/bundle/ cp linux/cwtch build/linux/x64/release/bundle/ cp README.md build/linux/x64/release/bundle/