Skip to content

Commit

Permalink
Add Package Selection Options
Browse files Browse the repository at this point in the history
Add the ability to add Package Management and select it via the GitHub Actions script.

Update linux-script.sh - Fix Syntax Error

Update linux-build.sh - Syntax Corrected and add LogNotes.

Update linux-build.sh - fix lognotes and add package selections as a function

Update linux-build.sh - Clean up deadspace
  • Loading branch information
odysseywestra committed Feb 18, 2024
1 parent dd6fe2d commit 727fe1e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/script-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
linux:
name: Linux
runs-on: ubuntu-22.04
env:
PKG_MANAGER: apt-get
USE_SUDO: true
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
Expand Down
65 changes: 40 additions & 25 deletions scripts/linux-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ SRC_BRANCH=$(git rev-parse --abbrev-ref HEAD)
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | awk '{print $3}')

# These are just here to make the output of the script more readable in the logs.

loginfo() {
echo -ne "${CYAN}"
echo -ne "${CYAN}INFO: "
echo -n "$@"
echo -e "${NC}"
}

logok() {
echo -ne "${GREEN}"
echo -ne "${GREEN}SUCCESS: "
echo -n "$@"
echo -e "${NC}"
}
Expand All @@ -83,30 +82,46 @@ lognote() {
echo -e "${NC}"
}

# TODO: These variables below should be called from the GitHub actions
# environment. Then change this to an if statement incase those environment
# variables are not set.

# Need to make the script for package management flexible so that it can be used
# on other systems. Need to make running sudo optional as well.

PKG_MANAGER="apt-get"
UPDATE_CMD="sudo $PKG_MANAGER update"
UPGRADE_CMD="sudo $PKG_MANAGER upgrade"
INSTALL_CMD="sudo $PKG_MANAGER install -y"
REMOVE_CMD="sudo $PKG_MANAGER remove -y"

# Set a package dependency list incase other OS's are used.

DEP_LIST="g++ gettext intltool gir1.2-gtk-3.0 libgtk-3-dev libjson-c-dev \
liblcms2-dev libpng-dev python3-dev python-gi-dev python3-gi-cairo \
python3-nose python3-numpy python3-setuptools swig git"
if [ $USE_SUDO == "true" ]; then
APPEND_SUDO="sudo"
lognote "Using sudo."
else
APPEND_SUDO=""
lognote "Not using sudo."
$USE_SUDO="false"
fi


select_pkg_manager(){
if [ $PKG_MANAGER == "apt-get" ]; then
lognote "Using apt-get package manager."

UPDATE_CMD="$APPEND_SUDO apt-get update"
UPGRADE_CMD="$APPEND_SUDO apt-get upgrade"
INSTALL_CMD="$APPEND_SUDO apt-get install -y"
REMOVE_CMD="$APPEND_SUDO apt-get remove -y"
DEP_LIST="g++ gettext intltool gir1.2-gtk-3.0 libgtk-3-dev libjson-c-dev \
liblcms2-dev libpng-dev python3-dev python-gi-dev python3-gi-cairo \
python3-nose python3-numpy python3-setuptools swig git"
elif [ $PKG_MANAGER == "pacman" ]; then
lognote "Using msys2 pacman package manager."
UPDATE_CMD="$APPEND_SUDO pacman -Sy"
UPGRADE_CMD="$APPEND_SUDO pacman -Su"
INSTALL_CMD="$APPEND_SUDO pacman -S --noconfirm"
REMOVE_CMD="$APPEND_SUDO pacman -R --noconfirm"
DEP_LIST="base-devel git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake \
mingw-w64-x86_64-gtk3 mingw-w64-x86_64-json-glib mingw-w64-x86_64-lcms2 \
mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-numpy mingw-w64-x86_64-python3-gobject \
mingw-w64-x86_64-python3-cairo mingw-w64-x86_64-python3-setuptools mingw-w64-x86_64-swig"
else
logerror "No package manager found."
exit 1
fi
}

# This function will be used to update the environment and upgrade the packages

prepare_enviroment(){
select_pkg_manager
loginfo "Updating Environment packages"
$UPDATE_CMD
loginfo "Upgradeing Packages"
Expand All @@ -115,17 +130,17 @@ prepare_enviroment(){
}

# This function will be used to install the dependencies for the project.

install_dependencies() {
select_pkg_manager
loginfo "Installing Dependencies"
if ! $INSTALL_CMD $DEP_LIST; then
logerror "Failed to install dependencies"
exit 1
fi
logok "Dependencies installed"

sudo ln -s /usr/lib/*/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders /usr/local/bin/gdk-pixbuf-query-loaders
sudo gdk-pixbuf-query-loaders --update-cache
$APPEND_SUDO ln -s /usr/lib/*/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders /usr/local/bin/gdk-pixbuf-query-loaders
$APPEND_SUDO gdk-pixbuf-query-loaders --update-cache
logok "Pixbuf query loaders cache updated"
}

Expand Down

0 comments on commit 727fe1e

Please sign in to comment.