2022-01-05 02:25:46 +01:00
#!/bin/bash
2022-08-31 01:01:56 +02:00
# SPDX-FileCopyrightText: 2022 debgerme <fossgerme@tuta.io>
#
# SPDX-License-Identifier: GPL-3.0-or-later
2022-06-14 02:14:26 +02:00
# define the colors
2022-01-05 02:25:46 +01:00
info_color = "\e[1;34m" # tasks color
comple_color = "\e[1;32m" # Ok color
reset_colors = "\e[0m" # this resets the coloring
2022-06-14 02:14:26 +02:00
2022-07-08 20:10:50 +02:00
# Check dependencies
2022-07-08 21:30:05 +02:00
# If you are having trobule with a dependency that IS in your system but
# the script can't continue, please add this to your command: --ignore-dependency-check
2022-08-17 00:33:25 +02:00
case " $@ " in *-k*| *--ignore-deps*)
2022-07-08 21:30:05 +02:00
IGNOREDEPS = ok
esac
# this checks for that option and if it is ok, skip this process
if [ " $IGNOREDEPS " != ok ]
then
2022-07-08 20:10:50 +02:00
# It mutes the output but verifies if the command returns an error
# if that's true, then the process can't continue
2022-07-28 05:29:36 +02:00
command -v inkscape >/dev/null 2>& 1 || { echo >& 2 "Missing dependency: inkscape" ; DEPSCOMPLETE = n; }
command -v parallel >/dev/null 2>& 1 || { echo >& 2 "Missing dependency: parallel" ; DEPSCOMPLETE = n; }
command -v bash >/dev/null 2>& 1 || { echo >& 2 "Missing dependency: bash" ; DEPSCOMPLETE = n; }
2022-07-08 20:10:50 +02:00
fi
2022-06-14 02:14:26 +02:00
2022-07-08 20:10:50 +02:00
# Check for --help
# This is the help message
2022-08-17 03:29:19 +02:00
case " $@ " in *-h*| *help*)
2022-07-08 20:10:50 +02:00
printf " ${ info_color } Aleta's build script help ${ reset_colors } \\n\
2022-08-16 21:15:33 +02:00
Usage: ./tasks/build.sh [ args] ...
2022-07-08 20:10:50 +02:00
2022-08-16 20:37:23 +02:00
${ info_color } Examples:${ reset_colors }
2022-08-17 01:15:32 +02:00
./tasks/build.sh -r -e Start the build from cero
2022-10-01 21:18:16 +02:00
./tasks/build.sh -r -e -i Same but now it autoinstalls ( recommended)
2022-08-17 01:15:32 +02:00
./tasks/build.sh -e Continue building. useful if you cancelled the build
2022-08-16 20:37:23 +02:00
2022-08-16 21:15:33 +02:00
${ info_color } Arguments:${ reset_colors }
2022-08-17 00:33:25 +02:00
-h --help help Show this help.
-e --export Export the remaining icons
2022-10-01 21:18:16 +02:00
-o --use-optipng Launch optipng process*
2022-10-01 19:11:07 +02:00
-v --verbose Show more info. useful for debugging
2022-08-17 00:33:25 +02:00
-r --from-cero Copy the SVG again and start the build again
-i --autoinstall Autoinstall to User directory
-k --ignore-deps Don' t check for dependencies.
2022-08-16 21:15:33 +02:00
2022-07-08 20:10:50 +02:00
This software is licensed under the GPLv3 and the CC-BY-SA 4.0 licenses.
2022-07-11 01:28:05 +02:00
See README and LICENSE for more information\\ n"
2022-07-08 20:10:50 +02:00
exit 0;
esac
2022-08-16 21:52:39 +02:00
# check if you written verbose and set that variable
2022-08-17 00:33:25 +02:00
case " $@ " in *-v*| *--verbose*)
2022-08-16 21:52:39 +02:00
VERBOSE = yes
esac
2022-08-16 21:15:33 +02:00
# here is the checking. it is sepparated for practicy
2022-10-01 19:09:30 +02:00
if [ " $DEPSCOMPLETE " = n ] ; then
2022-08-16 21:15:33 +02:00
echo Please install the missing dependencies to start building
2022-10-01 19:11:07 +02:00
exit 1
2022-08-16 21:15:33 +02:00
fi
2022-07-08 20:10:50 +02:00
# begin exportation and stuff
2022-06-14 02:14:26 +02:00
printf " ${ info_color } This script runs the build tasks and performs an install (or an update) of aleta to your home ${ reset_colors } \\n\\n "
2022-01-05 02:25:46 +01:00
2022-08-16 21:39:49 +02:00
# check if there is a valid option, if it is, continue. if not, mark the variable NOTOPTIONS and stop the process
2022-08-17 00:33:25 +02:00
case " $@ " in *-e*| *--export*| *-h*| *--help*| *help*| *-r*| *--from-cero*| *-o*| *--use-optipng*| *-i*| *--autoinstall*)
2022-08-16 21:39:49 +02:00
NOTOPTIONS = thereis
esac
2022-10-01 19:11:07 +02:00
# if there is no options, say that and stop with an error
2022-10-01 19:09:30 +02:00
if [ " $NOTOPTIONS " != thereis ] ; then
printf " please add at least one argument. (-k does not count.)
type ${ comple_color } ./tasks/build.sh --help${ reset_colors } to see all the arguments available
2022-08-16 21:45:17 +02:00
ERROR: there is no options, exit.\\ n"
2022-08-16 21:39:49 +02:00
exit 1
fi
2022-08-17 03:29:19 +02:00
case " $@ " in *-r*| *--from-cero*)
2022-07-08 20:34:07 +02:00
RESTART = yes
2022-10-01 19:09:30 +02:00
if [ " $VERBOSE " = yes ] ; then
2022-10-01 19:13:42 +02:00
printf " ${ info_color } Detected \"restart\" option, this will remove the last build and start agin... ${ reset_colors } \\n "
2022-10-01 19:09:30 +02:00
fi
2022-07-08 20:34:07 +02:00
esac
2022-10-01 19:09:30 +02:00
if [ " $RESTART " = yes ] ; then
# this deletes the build directory
printf " ${ info_color } cleaning up the build directory... ${ reset_colors } \\n "
rm _build/aleta -rf
2022-09-10 23:38:17 +02:00
2022-10-01 19:09:30 +02:00
# this creates the folder structure used in the build and while the building
printf " ${ info_color } rebuilding folder structure... ${ reset_colors } \\n "
./tasks/rebuildfolders.sh
# this copies the "SVG in" to the build folders
printf " ${ info_color } copying the files to build in the build dir ${ reset_colors } \\n "
if [ " $VERBOSE " = yes ] ; then
./tasks/copysvg.sh
else
./tasks/copysvg.sh >/dev/null 2>& 1
fi
2022-07-08 20:10:50 +02:00
fi
2022-08-16 21:39:49 +02:00
# Check if you written the export option
2022-08-17 00:33:25 +02:00
case " $@ " in *-e*| *--export*)
2022-08-16 21:39:49 +02:00
# I dont want to conflict with the export command XD
EXPOR = yes
esac
2022-01-10 00:20:33 +01:00
2022-08-16 21:39:49 +02:00
if [ " $EXPOR " = yes ] ; then
printf " ${ info_color } exporting all the icons... this will take a long time. ${ reset_colors } \\n "
2022-09-10 21:43:56 +02:00
./tasks/runexport.sh
2022-08-16 21:39:49 +02:00
fi
2022-01-05 02:25:46 +01:00
2022-08-17 00:33:25 +02:00
case " $@ " in *--use-optipng*| *-o*)
2022-08-16 21:52:39 +02:00
OPTIPNG = use
2022-07-08 20:10:50 +02:00
esac
2022-10-01 21:18:16 +02:00
# checks if you have optipng, if you have it, launch opticall. if not, exit
2022-08-17 00:33:25 +02:00
if [ " $OPTIPNG " = use ] ; then
2022-10-01 22:03:17 +02:00
2022-08-17 00:33:25 +02:00
if [ " $IGNOREDEPS " != ok ] ; then
command -v optipng >/dev/null 2>& 1 || { echo >& 2 "Missing dependency: optipng" ; DEPSCOMPLETE = n; }
2022-10-01 22:03:17 +02:00
2022-10-01 22:06:44 +02:00
if [ " $DEPSCOMPLETE " = n ] ; then
2022-08-17 00:33:25 +02:00
echo To optimize the build, please install optipng
2022-09-26 03:16:33 +02:00
exit 2
2022-08-17 00:33:25 +02:00
fi
2022-08-16 21:15:33 +02:00
fi
printf " ${ info_color } Using optipng to reduce the size of the build... ${ reset_colors } \\n "
2022-10-01 22:06:44 +02:00
2022-10-01 22:03:17 +02:00
./tasks/opticall.sh;
2022-07-08 20:10:50 +02:00
fi
2022-06-14 02:14:26 +02:00
2022-09-11 03:30:20 +02:00
# copy the index.theme file to the build. necesary to interpretate the icon pack in the settings
cp other/index.theme _build/aleta/ && printf " ${ info_color } copied index.theme to the build ${ reset_colors } \\n "
2022-01-05 02:25:46 +01:00
2022-06-14 02:14:26 +02:00
printf " ${ info_color } starting link process... ${ reset_colors } \\n "
2022-08-16 21:52:39 +02:00
if [ " $VERBOSE " = yes ] ; then
2022-09-10 20:32:33 +02:00
./tasks/runlink.sh
2022-08-16 21:52:39 +02:00
else
2022-09-10 20:32:33 +02:00
./tasks/runlink.sh >/dev/null 2>& 1
2022-08-16 21:52:39 +02:00
fi
2022-10-01 19:09:30 +02:00
2022-08-17 00:33:25 +02:00
case " $@ " in *--autoinstall*| *-i*)
2022-09-03 02:20:05 +02:00
2022-10-01 19:09:30 +02:00
printf " ${ info_color } Note that the route of the autoinstall has changed from ${ reset_colors } ~/.icons/aleta ${ info_color } to ${ reset_colors } ~/.local/share/icons/aleta\\n "
# checks if the install route is there, if not, creates it.
if [ ! -d ~/.local/share/icons/ ] ; then
mkdir ~/.local/
mkdir ~/.local/share/
mkdir ~/.local/share/icons/
fi
# this makes a copy before removing the installation. this reduces significantly the time without an installation.
cp -r ./_build/aleta _build/tmpaleta
# this two IFs checks if there is an old installation of aleta and then removes them
if [ -d ~/.icons/aleta ] ; then
rm -rf ~/.icons/aleta
PREVIOUSLYINSTALLED = yes
fi
if [ -d ~/.local/share/icons/aleta ] ; then
rm -rf ~/.local/share/icons/aleta
PREVIOUSLYINSTALLED = yes
fi
# if there was a previous installation of aleta, say Updating instead of Installing
if [ " $PREVIOUSLYINSTALLED " = yes ] ; then
printf " ${ info_color } Updating aleta icon pack ${ reset_colors } \\n "
else
printf " ${ info_color } Installing aleta icon pack ${ reset_colors } \\n "
fi
# moves the copy to the actual destination.
mv _build/tmpaleta ~/.local/share/icons/aleta
# updates the icon cache
2022-07-08 20:34:07 +02:00
printf " ${ info_color } Updating gtk icon cache... ${ reset_colors } \\n "
2022-10-01 19:09:30 +02:00
if [ " $VERBOSE " = yes ] ; then
gtk-update-icon-cache ~/.local/share/icons/aleta
else
gtk-update-icon-cache ~/.local/share/icons/aleta >/dev/null 2>& 1
fi
2022-07-08 20:34:07 +02:00
2022-07-08 20:10:50 +02:00
esac
2022-01-05 02:25:46 +01:00
2022-07-08 20:10:50 +02:00
printf " ${ comple_color } \\nCOMPLETED! The icon pack is builded. ${ reset_colors } \\n "