#!/bin/bash

appname="LBRY"
version="0.15.0"
arch="amd64"
url="https://github.com/lbryio/lbry-app/releases/download/v${version}/${appname}_${version}_${arch}.deb"
depends="gnome-keyring nodejs npm binutils xz"
tmpdir="/tmp"
output_file="lbry.deb"
desc="Content distribution platform using blockchain technology"

fetch_deps(){
    sudo dnf install ${depends}
}

fetch_url(){
    if [ ! -f ${tmpdir}/${output_file} ];then
        wget -O ${tmpdir}/${output_file} ${url}
    fi
}

extract_file(){
    cd ${tmpdir}
    sudo ar x ${output_file} data.tar.xz
    sudo tar xvf data.tar.xz
}

install(){
    sudo cp -rv ${tmpdir}/usr/* /usr/
    sudo cp -rv ${tmpdir}/opt/* /opt/
}

fetch_deps
fetch_url
extract_file
install