Skip to content

Commit 0eaf6bf

Browse files
committed
new build scripts
1 parent 1add3f8 commit 0eaf6bf

File tree

20 files changed

+436
-417
lines changed

20 files changed

+436
-417
lines changed

bin/builder.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
# stop on errors.
4+
set -e
5+
6+
# define starting directory.
7+
PA_SOURCES_PATH=$(pwd)
8+
9+
# load variables from scripts config.
10+
# shellcheck disable=SC1090
11+
source "${PA_SOURCES_PATH}/config.sh"
12+
13+
# source helpers.
14+
# shellcheck disable=SC1090
15+
source "${BASH_SOURCE%/*}/helpers/colors.sh"
16+
# shellcheck disable=SC1090
17+
source "${BASH_SOURCE%/*}/helpers/prepare.sh"
18+
# shellcheck disable=SC1090
19+
source "${BASH_SOURCE%/*}/helpers/flags.sh"
20+
# shellcheck disable=SC1090
21+
source "${BASH_SOURCE%/*}/helpers/build.sh"
22+
23+
# ensure starts on sources path.
24+
# shellcheck disable=SC2164
25+
cd "${PA_SOURCES_PATH}"
26+
27+
# update repositories first.
28+
sudo apk update
29+
30+
# run for extra packages.
31+
if [ "$PA_BUILD_EXTRA" = true ]; then
32+
# verbose.
33+
information "running tasks for:" "extra packages."
34+
# loop and build packages.
35+
build_list "${PA_PHP_EXTRA}";
36+
else
37+
warning "skipping:" "extra packages."
38+
fi
39+
40+
# # run for main php package.
41+
if [ "$PA_BUILD_MAIN" = true ]; then
42+
# verbose.
43+
information "running tasks for:" "main (php)."
44+
# update apk so extra packages are available.
45+
sudo apk update
46+
# build package.
47+
build_package "${PA_PHP_MAIN}"
48+
else
49+
warning "skipping:" "main (php)."
50+
fi
51+
52+
# run for extensions.
53+
if [ "$PA_BUILD_EXTENSIONS" = true ]; then
54+
# verbose.
55+
information "running tasks for:" "extensions."
56+
# update apk so main & extra packages are available.
57+
sudo apk update
58+
# loop and build packages.
59+
build_list "${PA_PHP_EXTENSIONS_PREFIXED}";
60+
else
61+
warning "skipping:" "extensions."
62+
fi
63+
64+
# ensure the final destination is the sources path.
65+
# shellcheck disable=SC2164
66+
cd "$PA_SOURCES_PATH"

bin/helpers/build.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# function for building packages.
4+
function build_package()
5+
{
6+
# alias package name from function input.
7+
PACKAGE_NAME=${1}
8+
9+
# enter package source directory.
10+
# shellcheck disable=SC2164
11+
cd "$PA_SOURCES_PATH/$PACKAGE_NAME"
12+
13+
# give a little feedback about the current package being built.
14+
success "building:" "$PACKAGE_NAME"
15+
16+
# build the package from source.
17+
if [ "$PA_BUILD_CHECKSUM" = true ]; then
18+
abuild checksum
19+
fi
20+
21+
# build the package from source.
22+
if [ "$PA_BUILD_BUILD" = true ]; then
23+
abuild -r
24+
fi
25+
26+
# return shell to previous location for safe scripting!
27+
# shellcheck disable=SC2164
28+
cd "${PA_SOURCES_PATH}"
29+
}
30+
31+
# build all packages in a given list.
32+
function build_list()
33+
{
34+
# define build list variable.
35+
BUILD_PACKAGE_LIST=$*
36+
37+
# verbose.
38+
success "building list:" "$BUILD_PACKAGE_LIST"
39+
40+
# loop packages and build each one.
41+
for PACKAGE in $BUILD_PACKAGE_LIST; do
42+
build_package "$PACKAGE"
43+
done
44+
}

bin/helpers/colors.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
# Source: https://bytefreaks.net/gnulinux/bash/cecho-a-function-to-print-using-different-colors-in-bash
4+
5+
# The following function prints a text using custom color
6+
# -c or --color define the color for the print. See the array colors for the available options.
7+
# -n or --noline directs the system not to print a new line after the content.
8+
# Last argument is the message to be printed.
9+
cecho () {
10+
11+
declare -A colors;
12+
colors=(\
13+
['black']='\E[0;47m'\
14+
['red']='\E[0;31m'\
15+
['green']='\E[0;92m'\
16+
['yellow']='\E[0;33m'\
17+
['blue']='\E[0;34m'\
18+
['magenta']='\E[0;35m'\
19+
['cyan']='\E[0;36m'\
20+
['white']='\E[0;37m'\
21+
);
22+
23+
local defaultMSG="No message passed.";
24+
local defaultColor="black";
25+
local defaultNewLine=true;
26+
27+
while [[ $# -gt 1 ]];
28+
do
29+
key="$1";
30+
31+
case $key in
32+
-c|--color)
33+
color="$2";
34+
shift;
35+
;;
36+
-n|--noline)
37+
newLine=false;
38+
;;
39+
*)
40+
# unknown option
41+
;;
42+
esac
43+
shift;
44+
done
45+
46+
message=${1:-$defaultMSG}; # Defaults to default message.
47+
color=${color:-$defaultColor}; # Defaults to default color, if not specified.
48+
newLine=${newLine:-$defaultNewLine};
49+
50+
echo -en "${colors[$color]}";
51+
echo -en "$message";
52+
if [ "$newLine" = true ] ; then
53+
echo;
54+
fi
55+
tput sgr0; # Reset text attributes to normal without clearing screen.
56+
57+
return;
58+
}
59+
60+
warning () {
61+
cecho -n -c 'yellow' "\n=== ";
62+
cecho -n -c 'white' "$1 ";
63+
cecho -c 'yellow' "$2\n";
64+
}
65+
66+
error () {
67+
cecho -n -c 'red' "\n=== ";
68+
cecho -n -c 'white' "$1 ";
69+
cecho -c 'red' "$2\n";
70+
}
71+
72+
information () {
73+
cecho -n -c 'cyan' "\n=== ";
74+
cecho -n -c 'white' "$1 ";
75+
cecho -c 'cyan' "$2\n";
76+
}
77+
78+
success () {
79+
cecho -n -c 'green' "\n=== ";
80+
cecho -n -c 'white' "$1 ";
81+
cecho -c 'green' "$2\n";
82+
}

bin/helpers/flags.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
# alias build options.
4+
PA_BUILD_OPTIONS=$*
5+
6+
# flags for package groups to build.
7+
PA_BUILD_EXTRA=false
8+
PA_BUILD_MAIN=false
9+
PA_BUILD_EXTENSIONS=false
10+
# actually build packages.
11+
PA_BUILD_BUILD=false
12+
# run checksum first.
13+
PA_BUILD_CHECKSUM=false
14+
15+
# check for --full flag.
16+
if [[ "$PA_BUILD_OPTIONS" == *"--full"* ]]; then
17+
PA_BUILD_EXTRA=true
18+
PA_BUILD_MAIN=true
19+
PA_BUILD_EXTENSIONS=true
20+
fi
21+
22+
# check for --no-update flag.
23+
if [[ "$PA_BUILD_OPTIONS" == *"--no-update"* ]]; then
24+
# shellcheck disable=SC2034
25+
PA_BUILD_UPDATE=false
26+
fi
27+
28+
# check for --build flag.
29+
if [[ "$PA_BUILD_OPTIONS" == *"--build"* ]]; then
30+
# shellcheck disable=SC2034
31+
PA_BUILD_BUILD=true
32+
fi
33+
34+
# check for --checksum flag.
35+
if [[ "$PA_BUILD_OPTIONS" == *"--checksum"* ]]; then
36+
# shellcheck disable=SC2034
37+
PA_BUILD_CHECKSUM=true
38+
fi
39+
40+
# check for --dep
41+
if [[ "$PA_BUILD_OPTIONS" == *"--extra"* ]]; then
42+
# shellcheck disable=SC2034
43+
PA_BUILD_EXTRA=true
44+
fi
45+
# check for --php flag.
46+
if [[ "$PA_BUILD_OPTIONS" == *"--main"* ]]; then
47+
# shellcheck disable=SC2034
48+
PA_BUILD_MAIN=true
49+
fi
50+
# check for --ext flag.
51+
if [[ "$PA_BUILD_OPTIONS" == *"--extensions"* ]]; then
52+
# shellcheck disable=SC2034
53+
PA_BUILD_EXTENSIONS=true
54+
fi

bin/helpers/prepare.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
# failsafe $PACKAGES and $EXTENSIONS variables.
4+
PA_PHP_EXTRA=${PA_PHP_EXTRA:-""}
5+
PA_PHP_MAIN=${PA_PHP_MAIN:-""}
6+
PA_PHP_EXTENSIONS=${PA_PHP_EXTENSIONS:-""}
7+
8+
# define prefixed version of extensions list, start empty.
9+
PA_PHP_EXTENSIONS_PREFIXED=""
10+
11+
# loop extensions.
12+
for PA_EXT_NAME in $PA_PHP_EXTENSIONS; do
13+
PA_PHP_EXTENSIONS_PREFIXED="$PA_PHP_EXTENSIONS_PREFIXED ${PA_PHP_MAIN}-${PA_EXT_NAME}"
14+
done

sandbox/start.sh renamed to sandbox/entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
export PATH=/opt/php-alpine/bin:$PATH
4+
35
# trust the locally mounted public key.
46
sudo cp /home/sandbox/.abuild/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub
57

scripts/v3.10/php-7.3/build.sh

Lines changed: 0 additions & 60 deletions
This file was deleted.

scripts/v3.10/php-7.3/config.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# export php package name.
2+
export PA_PHP_MAIN="php7"
3+
4+
# dependencies to build.
5+
export PA_PHP_EXTRA="argon2 secp256k1"
6+
7+
# extensions to build.
8+
export PA_PHP_EXTENSIONS="
9+
amqp
10+
apcu
11+
ast
12+
ds
13+
hashids
14+
imagick
15+
libsodium
16+
memcached
17+
mongodb
18+
msgpack
19+
phalcon
20+
psr
21+
redis
22+
scalar_objects
23+
secp256k1
24+
swoole
25+
timecop
26+
xdebug
27+
"

0 commit comments

Comments
 (0)