Skip to content

Commit

Permalink
Merge pull request #17 from hoobs-org/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mkellsy authored Jun 29, 2021
2 parents e7b9588 + 3f062b0 commit 7b6c8e7
Show file tree
Hide file tree
Showing 7 changed files with 512 additions and 13 deletions.
218 changes: 218 additions & 0 deletions bin/bleeding
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
#!/bin/bash

##################################################################################################
# hoobs-cli #
# Copyright (C) 2020 HOOBS #
# Copyright (C) 2020 NodeSource #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##################################################################################################

export DEBIAN_FRONTEND=noninteractive

SCRSUFFIX="_current.x"
NODENAME="Node.js 16.x"
NODEREPO="node_16.x"
NODEPKG="nodejs"

if test -t 1; then # if terminal
ncolors=$(which tput > /dev/null && tput colors) # supports color

if test -n "$ncolors" && test $ncolors -ge 8; then
termcols=$(tput cols)
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi

bail() {
echo 'Error executing command, exiting'
exit 1
}

exec_cmd_nobail() {
echo "+ $1"
bash -c "$1"
}

exec_cmd() {
exec_cmd_nobail "$1" || bail
}

setup() {
echo "Installing the NodeSource ${NODENAME} repo..."

if $(uname -m | grep -Eq ^armv6); then
echo "You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by HOOBS."

exit 1
fi

PRE_INSTALL_PKGS=""

if [ ! -e /usr/lib/apt/methods/https ]; then
PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} apt-transport-https"
fi

if [ ! -x /usr/bin/lsb_release ]; then
PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} lsb-release"
fi

if [ ! -x /usr/bin/gpg ]; then
PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} gnupg"
fi

exec_cmd 'apt-get update'

if [ "X${PRE_INSTALL_PKGS}" != "X" ]; then
exec_cmd "apt-get install -y${PRE_INSTALL_PKGS} > /dev/null 2>&1"
fi

IS_PRERELEASE=$(lsb_release -d | grep 'Ubuntu .*development' >& /dev/null; echo $?)

if [[ $IS_PRERELEASE -eq 0 ]]; then
echo "Your distribution, identified as \"$(lsb_release -d -s)\", is a pre-release version of Ubuntu. HOOBS does not support pre-release versions."
exit 1
fi

DISTRO=$(lsb_release -c -s)

check_alt() {
if [ "X${DISTRO}" == "X${2}" ]; then
DISTRO="${4}"
fi
}

check_alt "SolydXK" "solydxk-9" "Debian" "stretch"
check_alt "Kali" "sana" "Debian" "jessie"
check_alt "Kali" "kali-rolling" "Debian" "bullseye"
check_alt "Sparky Linux" "Tyche" "Debian" "stretch"
check_alt "Sparky Linux" "Nibiru" "Debian" "buster"
check_alt "MX Linux 17" "Horizon" "Debian" "stretch"
check_alt "MX Linux 18" "Continuum" "Debian" "stretch"
check_alt "MX Linux 19" "patito feo" "Debian" "buster"
check_alt "Linux Mint" "maya" "Ubuntu" "precise"
check_alt "Linux Mint" "qiana" "Ubuntu" "trusty"
check_alt "Linux Mint" "rafaela" "Ubuntu" "trusty"
check_alt "Linux Mint" "rebecca" "Ubuntu" "trusty"
check_alt "Linux Mint" "rosa" "Ubuntu" "trusty"
check_alt "Linux Mint" "sarah" "Ubuntu" "xenial"
check_alt "Linux Mint" "serena" "Ubuntu" "xenial"
check_alt "Linux Mint" "sonya" "Ubuntu" "xenial"
check_alt "Linux Mint" "sylvia" "Ubuntu" "xenial"
check_alt "Linux Mint" "tara" "Ubuntu" "bionic"
check_alt "Linux Mint" "tessa" "Ubuntu" "bionic"
check_alt "Linux Mint" "tina" "Ubuntu" "bionic"
check_alt "Linux Mint" "tricia" "Ubuntu" "bionic"
check_alt "Linux Mint" "ulyana" "Ubuntu" "focal"
check_alt "Linux Mint" "ulyssa" "Ubuntu" "focal"
check_alt "LMDE" "betsy" "Debian" "jessie"
check_alt "LMDE" "cindy" "Debian" "stretch"
check_alt "LMDE" "debbie" "Debian" "buster"
check_alt "elementaryOS" "luna" "Ubuntu" "precise"
check_alt "elementaryOS" "freya" "Ubuntu" "trusty"
check_alt "elementaryOS" "loki" "Ubuntu" "xenial"
check_alt "elementaryOS" "juno" "Ubuntu" "bionic"
check_alt "elementaryOS" "hera" "Ubuntu" "bionic"
check_alt "elementaryOS" "odin" "Ubuntu" "focal"
check_alt "Trisquel" "toutatis" "Ubuntu" "precise"
check_alt "Trisquel" "belenos" "Ubuntu" "trusty"
check_alt "Trisquel" "flidas" "Ubuntu" "xenial"
check_alt "Trisquel" "etiona" "Ubuntu" "bionic"
check_alt "Uruk GNU/Linux" "lugalbanda" "Ubuntu" "xenial"
check_alt "BOSS" "anokha" "Debian" "wheezy"
check_alt "BOSS" "anoop" "Debian" "jessie"
check_alt "BOSS" "drishti" "Debian" "stretch"
check_alt "BOSS" "unnati" "Debian" "buster"
check_alt "bunsenlabs" "bunsen-hydrogen" "Debian" "jessie"
check_alt "bunsenlabs" "helium" "Debian" "stretch"
check_alt "bunsenlabs" "lithium" "Debian" "buster"
check_alt "Tanglu" "chromodoris" "Debian" "jessie"
check_alt "PureOS" "green" "Debian" "sid"
check_alt "PureOS" "amber" "Debian" "buster"
check_alt "Devuan" "jessie" "Debian" "jessie"
check_alt "Devuan" "ascii" "Debian" "stretch"
check_alt "Devuan" "beowulf" "Debian" "buster"
check_alt "Devuan" "ceres" "Debian" "sid"
check_alt "Deepin" "panda" "Debian" "sid"
check_alt "Deepin" "unstable" "Debian" "sid"
check_alt "Deepin" "stable" "Debian" "buster"
check_alt "Pardus" "onyedi" "Debian" "stretch"
check_alt "Liquid Lemur" "lemur-3" "Debian" "stretch"
check_alt "Astra Linux" "orel" "Debian" "stretch"
check_alt "Ubilinux" "dolcetto" "Debian" "stretch"

if [ "X${DISTRO}" == "Xdebian" ]; then
echo "Unknown Debian-based distribution, checking /etc/debian_version..."
NEWDISTRO=$([ -e /etc/debian_version ] && cut -d/ -f1 < /etc/debian_version)

if [ "X${NEWDISTRO}" == "X" ]; then
echo "Could not determine distribution from /etc/debian_version..."
else
DISTRO=$NEWDISTRO
echo "Found \"${DISTRO}\" in /etc/debian_version..."
fi
fi

echo "Confirming \"${DISTRO}\" is supported..."

exec_cmd_nobail "wget -qO /dev/null -o /dev/null 'https://deb.nodesource.com/${NODEREPO}/dists/${DISTRO}/Release'"
RC=$?

if [[ $RC != 0 ]]; then
echo "Your distribution, identified as \"${DISTRO}\", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support"
exit 1
fi

if [ -f "/etc/apt/sources.list.d/chris-lea-node_js-$DISTRO.list" ]; then
echo 'Removing Launchpad PPA Repository for NodeJS...'

exec_cmd_nobail 'add-apt-repository -y -r ppa:chris-lea/node.js'
exec_cmd "rm -f /etc/apt/sources.list.d/chris-lea-node_js-${DISTRO}.list"
fi

echo "Adding the NodeSource repository"

exec_cmd 'wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -'
exec_cmd "echo 'deb https://deb.nodesource.com/${NODEREPO} ${DISTRO} main' > /etc/apt/sources.list.d/nodesource.list"
exec_cmd "echo 'deb-src https://deb.nodesource.com/${NODEREPO} ${DISTRO} main' >> /etc/apt/sources.list.d/nodesource.list"

echo "Adding the Yarn repository"

exec_cmd "wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -"
exec_cmd "echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list"

echo "Adding the HOOBS repository"

exec_cmd "wget -qO- https://dl.hoobs.org/deb/key.gpg | apt-key add -"
exec_cmd "echo 'deb https://dl.hoobs.org/deb/bleeding/ buster main' | tee /etc/apt/sources.list.d/hoobs.list"

echo "Updating packages"

exec_cmd 'apt-get update'

echo "Run \"${bold}sudo apt install -y hoobs${normal}\" to install HOOBS, node and yarn"
}

setup
16 changes: 9 additions & 7 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Program.command("cli", { isDefault: true })
.option("-l, --lint", "lint the code before building")
.option("-p, --pack", "create pack file for offline testing")
.action((command) => {
const repo = command.repo || "bleeding";

if (command.lint) execSync(`${join(root, "node_modules", ".bin", "eslint")} 'src/**/*.ts'`, { cwd: root, stdio: "inherit" });
if (existsSync(join(root, "lib"))) execSync(`${join(root, "node_modules", ".bin", "rimraf")} ${join(root, "lib")}`, { cwd: root, stdio: "inherit" });

Expand Down Expand Up @@ -77,11 +79,11 @@ Program.command("cli", { isDefault: true })

if (!existsSync(join(root, "../repo/src"))) mkdirSync(join(root, "../repo/src"));
if (existsSync(join(root, "../repo/src", `hoobs-cli-v${pjson.version}.tar.gz`))) unlinkSync(join(root, "../repo/src", `hoobs-cli-v${pjson.version}.tar.gz`))
if (existsSync(join(root, "../repo", "setup"))) unlinkSync(join(root, "../repo", "setup"))
if (existsSync(join(root, "../repo", repo))) unlinkSync(join(root, "../repo", repo))

moveSync(join(root, "dist", `hoobs-cli-v${pjson.version}.tar.gz`), join(root, "../repo/src", `hoobs-cli-v${pjson.version}.tar.gz`));
copyFileSync(join(root, "bin", "setup"), join(root, "../repo", "setup"));
execSync(`chmod 755 ${join(root, "../repo", "setup")}`, { cwd: root, stdio: "inherit" });
copyFileSync(join(root, "bin", repo), join(root, "../repo", repo));
execSync(`chmod 755 ${join(root, "../repo", repo)}`, { cwd: root, stdio: "inherit" });
mkdirSync(join(root, "dist/DEBIAN"));

let control = "";
Expand All @@ -102,11 +104,11 @@ Program.command("cli", { isDefault: true })
execSync(`chmod 755 ${join(root, "dist/DEBIAN", "postinst")}`, { cwd: root, stdio: "inherit" });
execSync("dpkg-deb --build dist", { cwd: root, stdio: "inherit" });

if (!existsSync(join(root, "../repo/deb", command.repo || "edge"))) mkdirSync(join(root, "../repo/deb", command.repo || "edge"));
if (existsSync(join(root, "../repo/deb", command.repo || "edge", `hoobs-cli-v${pjson.version}.deb`))) unlinkSync(join(root, "../repo/deb", command.repo || "edge", `hoobs-cli-v${pjson.version}.deb`));
if (!existsSync(join(root, "../repo/deb", repo))) mkdirSync(join(root, "../repo/deb", repo));
if (existsSync(join(root, "../repo/deb", repo, `hoobs-cli-v${pjson.version}.deb`))) unlinkSync(join(root, "../repo/deb", repo, `hoobs-cli-v${pjson.version}.deb`));

moveSync(join(root, "dist.deb"), join(root, "../repo/deb", command.repo || "edge", `hoobs-cli-v${pjson.version}.deb`));
execSync(`dpkg-sig --sign builder ${join(root, "../repo/deb", command.repo || "edge", `hoobs-cli-v${pjson.version}.deb`)}`, { cwd: root, stdio: "inherit" });
moveSync(join(root, "dist.deb"), join(root, "../repo/deb", repo, `hoobs-cli-v${pjson.version}.deb`));
execSync(`dpkg-sig --sign builder ${join(root, "../repo/deb", repo, `hoobs-cli-v${pjson.version}.deb`)}`, { cwd: root, stdio: "inherit" });

if (existsSync(join(root, "dist"))) execSync(`${join(root, "node_modules", ".bin", "rimraf")} ${join(root, "dist")}`, { cwd: root, stdio: "inherit" });
}
Expand Down
Loading

0 comments on commit 7b6c8e7

Please sign in to comment.