#!/usr/bin/env bash
apt install -y fonts-liberation libappindicator3-1 libdbusmenu-glib4 libdbusmenu-gtk3-4 libindicator3-7

apt install -y dpkg-dev fakeroot lintian apt-utils deb-pkg-tools

# FIXME: change the xpaths to relative paths to the labe
#!/bin/env python3
         URL = 'https://dissenter.com/#download'
     VERSION = '//*[@id="download"]/div[2]/div/span[2]/text()'    # ['v0.70.122']
BUTTON_LABEL = '//*[@id="download"]/div[2]/div/a[2]/text()'       # ['Download deb']
        LINK = '//*[@id="download"]/div[2]/div/a[2]/@href'        # ['https://apps.gab.com/application/5d3f93a29dd49a5b1d9fc27f/resource/5dbdab9853c1056bd98c3525']

import requests
import lxml.html
from lxml import etree

import subprocess

response = requests.get(URL)

print(response.url)
APP_VERSION = tree.xpath(VERSION)
APP_BUTTON_LABEL = tree.xpath(BUTTON_LABEL)
APP_LINK = tree.xpath(LINK)

subprocess.call("(TEMP_DEB="$(mktemp)"; wget -O "${TEMP_DEB}" "${APP_LINK}"; rm -rf "${TEMP_DEB}")", shell=True)
#subprocess.run(['useradd', '-m', '-g {0}'.format(_primarygroup), '-G {0}'.format(_secondarygroup), '-u {0}'.format(_userid)], capture_output=True)
#---------------------------------------------------
TEMP_DEB="$(mktemp)"
wget -O "$TEMP_DEB" "${LINK}"
sudo dpkg -i "${TEMP_DEB}"
rm -f "${TEMP_DEB}"

apt -f install
