aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Koglin-Fischer2023-12-21 15:42:17 +0100
committerStephan Koglin-Fischer2023-12-21 15:42:17 +0100
commit7c2f21240f9b8c6a3c7f7f03c00e9df2f639d733 (patch)
tree5923356794f545d971493e1f1ead6bfc7fbbdb6a
parent5047099a408f959a73406c595b6c094c50389cfe (diff)
downloadaur-7c2f21240f9b8c6a3c7f7f03c00e9df2f639d733.tar.gz
fix: still doesn't work
-rw-r--r--PKGBUILD34
-rw-r--r--commands.sh87
2 files changed, 93 insertions, 28 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 3f113e222130..bfda16d0b56a 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -21,6 +21,7 @@ pkgver() {
git describe --long --tags --abbrev=7 | sed 's/^foo-//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
+<<<<<<< Updated upstream
check-for-asdf() {
if ! command -v asdf &> /dev/null
then
@@ -68,39 +69,16 @@ check-for-asdf() {
fi
}
+=======
+>>>>>>> Stashed changes
prepare() {
- check-for-asdf
-
- # Install all plugins stated in .tool-versions
- awk '{print $1}' .tool-versions | xargs -n 1 asdf plugin-add
- asdf install
-
- cd "$srcdir/$pkgname"
- yarn install
+ $SHELL -c "source ./commands.sh && prepare_commands"
}
build() {
- check-for-asdf
-
- cd "$srcdir/$pkgname"
- yarn run build
- # Build linux binary
- yarn pkg:linux
+ $SHELL -c "source ./commands.sh && build_commands"
}
package() {
- check-for-asdf
-
- cd "$srcdir/$pkgname"
-
- # Install the tool-versions file
- install -Dm755 "$srcdir/.tool-versions" "$pkgdir/usr/share/dashlane-cli-git/.tool-versions"
-
- # Install the binary
- install -Dm755 "$srcdir/$pkgname/bundle/dcli-linux" "$pkgdir/usr/share/dashlane-cli-git/dcli"
-
- # Create a symlink to the binary
- mkdir -p "$pkgdir/usr/bin"
- cd "$pkgdir/usr/bin"
- ln -sf "./../share/dashlane-cli-git/dcli" "dcli"
+ $SHELL -c "source ./commands.sh && package_commands"
}
diff --git a/commands.sh b/commands.sh
new file mode 100644
index 000000000000..8fc7143fc703
--- /dev/null
+++ b/commands.sh
@@ -0,0 +1,87 @@
+check-for-asdf() {
+ if ! command -v asdf &> /dev/null
+ then
+ echo "asdf could not be found"
+ echo "Configuring asdf..."
+
+ # Install asdf
+ # for bash, fish, zsh - add more if needed
+ if [[ $SHELL == *"bash"* ]]; then
+ # If the .bashrc file does not contain the asdf source command, we add it
+ if ! grep -q ". /opt/asdf-vm/asdf.sh" ~/.bashrc; then
+ echo -e "\n. /opt/asdf-vm/asdf.sh" >> ~/.bashrc
+ fi
+ source ~/.bashrc
+ elif [[ $SHELL == *"fish"* ]]; then
+ echo "Patching config.fish"
+ # If the config.fish file does not contain the asdf source command, we add it
+ if ! grep -q ". /opt/asdf-vm/asdf.fish" ~/.config/fish/config.fish; then
+ echo -e "\n. /opt/asdf-vm/asdf.fish" >> ~/.config/fish/config.fish
+ fi
+ source ~/.config/fish/config.fish
+ elif [[ $SHELL == *"zsh"* ]]; then
+ echo "Patching .zshrc"
+ # Just to make sure that an existing zsh config is not intervening,
+ # we need to check that the .zshrc file contains the proper shebang #!/usr/bin/env zsh
+ if ! grep -q "#!/usr/bin/env zsh" ~/.zshrc; then
+ echo "The .zshrc file does not contain the proper shebang #!/usr/bin/env zsh"
+ echo "This script is likely to fail."
+ echo "For convenience, we will add it for you."
+ echo "If you do not want this, please remove it manually after the installation has finished."
+ echo -e "#!/usr/bin/env zsh\n# Shebang added by the dashlane-cli-git package\n\n$(cat ~/.zshrc)" > ~/.zshrc
+ fi
+ # If the .zshrc file does not contain the asdf source command, we add it
+ if ! grep -q ". /opt/asdf-vm/asdf.sh" ~/.zshrc; then
+ echo -e "\n. /opt/asdf-vm/asdf.sh" >> ~/.zshrc
+ fi
+ source ~/.zshrc
+ # Check if asdf is available now
+ if ! command -v asdf &> /dev/null then
+ echo "asdf could not be found"
+ echo "You need to add asdf to your shell's initialization file manually."
+ fi
+ else
+ echo "Unsupported shell. Please add asdf to your shell's initialization file manually."
+ echo "Consider opening an issue or contribute a pull request to add support for your shell."
+ echo "https://github.com/skf-funzt/dashlane-cli-git"
+ exit 1
+ fi
+ fi
+}
+
+prepare_command() {
+ check-for-asdf
+
+ # Install all plugins stated in .tool-versions
+ awk '{print $1}' .tool-versions | xargs -n 1 asdf plugin-add
+ asdf install
+
+ cd "$srcdir/$pkgname"
+ yarn install
+}
+
+build_command() {
+ check-for-asdf
+
+ cd "$srcdir/$pkgname"
+ yarn run build
+ # Build linux binary
+ yarn pkg:linux
+}
+
+package_command() {
+ check-for-asdf
+
+ cd "$srcdir/$pkgname"
+
+ # Install the tool-versions file
+ install -Dm755 "$srcdir/.tool-versions" "$pkgdir/usr/share/dashlane-cli-git/.tool-versions"
+
+ # Install the binary
+ install -Dm755 "$srcdir/$pkgname/bundle/dcli-linux" "$pkgdir/usr/share/dashlane-cli-git/dcli"
+
+ # Create a symlink to the binary
+ mkdir -p "$pkgdir/usr/bin"
+ cd "$pkgdir/usr/bin"
+ ln -sf "./../share/dashlane-cli-git/dcli" "dcli"
+} \ No newline at end of file