-
Notifications
You must be signed in to change notification settings - Fork 38
bootstrap-tarballs: Document script #1757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f6173ad
9536d56
c574435
629352c
a4cf882
be0f5c0
287b447
83a0329
0bcf793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,106 +1,169 @@ | ||||||||||
#!/bin/bash -x | ||||||||||
#!/bin/bash | ||||||||||
|
||||||||||
# This script is supposed generate tarballs from the core & masterfiles | ||||||||||
# repositories. We also use these tarballs later in the build process to make | ||||||||||
# sure that they actually work. | ||||||||||
# | ||||||||||
# Currently this script also fetches pull request info and installs PHP and | ||||||||||
# javascript dependencies. This core really does not belong here. Created a | ||||||||||
# ticket move it (see ENT-13064). | ||||||||||
# | ||||||||||
# You will first need to run the autogen script. E.g.: | ||||||||||
# PROJECT=community ./buildscripts/build-scripts/autogen | ||||||||||
# Then you can run it like this: | ||||||||||
# BUILD_TYPE=DEBUG ./buildscripts/build-scripts/bootstrap-tarballs | ||||||||||
# | ||||||||||
# The script expects the following repositories to be side by side: | ||||||||||
# . | ||||||||||
# ├── buildscripts | ||||||||||
# ├── core | ||||||||||
# ├── enterprise | ||||||||||
# ├── nova | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if PROJECT=community you don't need all the ent stuff. Maybe clarify that with separate lists? |
||||||||||
# ├── mission-portal | ||||||||||
# ├── libntech | ||||||||||
# └── masterfiles | ||||||||||
# | ||||||||||
|
||||||||||
_dir=$(readlink -e "$(dirname "$0")") | ||||||||||
# refactored a few functions into single file scripts for easier development/debugging, see ENT-12741 and ENT-12595 | ||||||||||
# Easier to add a path to a script than source a file of functions. | ||||||||||
export PATH="$_dir"/bin:$PATH | ||||||||||
. `dirname "$0"`/functions | ||||||||||
. "$(dirname "$0")"/functions | ||||||||||
. detect-environment | ||||||||||
. compile-options | ||||||||||
. version | ||||||||||
|
||||||||||
mkdir -p $BASEDIR/output/tarballs | ||||||||||
mkdir -p "$BASEDIR"/output/tarballs | ||||||||||
|
||||||||||
# the first part of the script is not really critical | ||||||||||
set +e | ||||||||||
|
||||||||||
# Get information about PRs among the used revisions. | ||||||||||
# These PRs will have to be notified of build progress. | ||||||||||
# Get information about PRs among the used revisions. These PRs will have to be | ||||||||||
# notified of build progress. | ||||||||||
# | ||||||||||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I would somewhat prefer a sentence per line honestly. easier for maintenance and editing. |
||||||||||
# Variables such as MISSION_PORTAL_REV may be set by the CI (Jenkins) to build | ||||||||||
# and test multiple PR's together. The variables typically hold a branch name | ||||||||||
# or a pull request ID. PR IDs are preceded by 'pull' or 'origin/pull'. E.g.: | ||||||||||
# - MISSION_PORTAL_REV=pull/1755 | ||||||||||
# - MISSION_PORTAL_REV=origin/pull/1755 | ||||||||||
# where the trailing number is the pull request ID. | ||||||||||
# | ||||||||||
# This loop fetches information about the PRs if the respective variable is set. | ||||||||||
# | ||||||||||
for repo_spec in cfengine/buildscripts cfengine/core cfengine/masterfiles cfengine/enterprise cfengine/nova cfengine/mission-portal NorthernTechHQ/libntech; do | ||||||||||
# remove organization/ from start of repo_spec | ||||||||||
# E.g. 'cfengine/mission-portal' -> 'mission-portal' | ||||||||||
repo="${repo_spec#*/}" | ||||||||||
rev_param_name="$(echo $repo | tr '[:lower:]-' '[:upper:]_')_REV" | ||||||||||
revision="$(echo ${!rev_param_name})" || continue # dereference | ||||||||||
|
||||||||||
# Convert to uppercase, swap hyphens with underscore and append '_REV' | ||||||||||
# E.g. 'mission-portal' -> 'MISSION_PORTAL_REV' | ||||||||||
rev_param_name="$(echo "$repo" | tr '[:lower:]-' '[:upper:]_')_REV" | ||||||||||
|
||||||||||
# Try to dereference the result from above and skip the rest of the loop | ||||||||||
# unless the variable is defined. | ||||||||||
revision="${!rev_param_name}" || continue | ||||||||||
|
||||||||||
# remove "origin/" (if any) | ||||||||||
revision="${revision##origin/}" | ||||||||||
|
||||||||||
# Check to see if the resolved variable starts with 'pull/' | ||||||||||
if expr "$revision" : "pull/" >/dev/null; then | ||||||||||
pr_nr="$(echo $revision | cut -d/ -f2)" | ||||||||||
get-github-pull-request-info "$repo_spec" "$pr_nr" >> $BASEDIR/output/PRs | ||||||||||
# Extract the revision number. E.g. 'pull/1755' -> '1755' | ||||||||||
pr_nr="$(echo "$revision" | cut -d/ -f2)" | ||||||||||
|
||||||||||
get-github-pull-request-info "$repo_spec" "$pr_nr" >> "$BASEDIR"/output/PRs | ||||||||||
fi | ||||||||||
done | ||||||||||
|
||||||||||
# now script failures should fail the script | ||||||||||
set -e | ||||||||||
|
||||||||||
cd $BASEDIR/core | ||||||||||
rm cfengine-3.*.tar.gz || true | ||||||||||
git rev-parse HEAD > $BASEDIR/output/core-commitID | ||||||||||
# Build tarball from core repository | ||||||||||
cd "$BASEDIR"/core | ||||||||||
rm -f cfengine-3.*.tar.gz | ||||||||||
git rev-parse HEAD > "$BASEDIR"/output/core-commitID | ||||||||||
# Configure in order to run "make dist", deleted later. | ||||||||||
./configure -C | ||||||||||
make dist | ||||||||||
mv cfengine-3.*.tar.gz $BASEDIR/output/tarballs/ | ||||||||||
make distclean | ||||||||||
|
||||||||||
cd $BASEDIR/masterfiles | ||||||||||
rm cfengine-masterfiles*.tar.gz || true | ||||||||||
git rev-parse HEAD > $BASEDIR/output/masterfiles-commitID | ||||||||||
echo "$(basename "$0"): Debug: Running configure on core repository..." | ||||||||||
run_and_print_on_failure ./configure -C | ||||||||||
echo "$(basename "$0"): Debug: Running make dist on core repository..." | ||||||||||
run_and_print_on_failure make dist | ||||||||||
mv cfengine-3.*.tar.gz "$BASEDIR"/output/tarballs/ | ||||||||||
echo "$(basename "$0"): Debug: Running make distclean on core repository..." | ||||||||||
run_and_print_on_failure make distclean | ||||||||||
|
||||||||||
# Build tarballs from masterfiles repository | ||||||||||
cd "$BASEDIR"/masterfiles | ||||||||||
rm -f cfengine-masterfiles*.tar.gz | ||||||||||
git rev-parse HEAD > "$BASEDIR"/output/masterfiles-commitID | ||||||||||
# Configure in order to run "make dist", deleted later. | ||||||||||
./configure | ||||||||||
make dist # source tarball | ||||||||||
make tar-package # package tarball | ||||||||||
mv cfengine-masterfiles*.tar.gz $BASEDIR/output/tarballs/ | ||||||||||
make distclean | ||||||||||
|
||||||||||
cd $BASEDIR/output/tarballs | ||||||||||
sha256sum *.tar.gz > sha256sums.txt | ||||||||||
CKSUM=`sum sha256sums.txt | cut -d ' ' -f 1` | ||||||||||
mv sha256sums.txt sha256sums.$CKSUM.txt | ||||||||||
|
||||||||||
echo "$(basename "$0"): Debug: Running configure on masterfiles repository..." | ||||||||||
run_and_print_on_failure ./configure | ||||||||||
echo "$(basename "$0"): Debug: Running make dist on masterfiles repository..." | ||||||||||
run_and_print_on_failure make dist # source tarball | ||||||||||
echo "$(basename "$0"): Debug: Running make tar-package on masterfiles repository..." | ||||||||||
run_and_print_on_failure make tar-package # package tarball (containing all | ||||||||||
# files as if they were installed | ||||||||||
# under "prefix".) | ||||||||||
mv cfengine-masterfiles*.tar.gz "$BASEDIR"/output/tarballs/ | ||||||||||
echo "$(basename "$0"): Debug: Running make distclean on masterfiles repository..." | ||||||||||
run_and_print_on_failure make distclean | ||||||||||
|
||||||||||
# Compute a checksum list that can be used to verify the integrity of the | ||||||||||
# tarballs | ||||||||||
cd "$BASEDIR"/output/tarballs | ||||||||||
sha256sum -- *.tar.gz > sha256sums.txt | ||||||||||
# Add the BSD (16-bit) checksum of the checksum list to it's filename. This way | ||||||||||
# you can verify the integrity of the checksum list itself. | ||||||||||
CKSUM=$(sum sha256sums.txt | cut -d ' ' -f 1) | ||||||||||
mv sha256sums.txt sha256sums."$CKSUM".txt | ||||||||||
|
||||||||||
echo "$(basename "$0"): Debug: Installing javascript dependencies..." | ||||||||||
( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if test -f "$BASEDIR/mission-portal/public/scripts/package.json"; then | ||||||||||
cd $BASEDIR/mission-portal/public/scripts | ||||||||||
if test -f "$BASEDIR"/mission-portal/public/scripts/package.json; then | ||||||||||
cd "$BASEDIR"/mission-portal/public/scripts | ||||||||||
# display node & npm versions | ||||||||||
Comment on lines
+122
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change isn't so needed but is fine. I often prefer to avoid the quotes as if more vars enter the expression things get noisy. |
||||||||||
npm --version | ||||||||||
node --version | ||||||||||
# install dependencies from npmjs | ||||||||||
npm ci --prefix $BASEDIR/mission-portal/public/scripts/ | ||||||||||
run_and_print_on_failure npm ci --prefix "$BASEDIR"/mission-portal/public/scripts/ | ||||||||||
# build react components | ||||||||||
npm run build --prefix $BASEDIR/mission-portal/public/scripts/ | ||||||||||
run_and_print_on_failure npm run build --prefix "$BASEDIR"/mission-portal/public/scripts/ | ||||||||||
# remove the packages specified in devDependencies | ||||||||||
npm prune --omit=dev --prefix $BASEDIR/mission-portal/public/scripts/ | ||||||||||
|
||||||||||
run_and_print_on_failure npm prune --omit=dev --prefix "$BASEDIR"/mission-portal/public/scripts/ | ||||||||||
fi | ||||||||||
) | ||||||||||
|
||||||||||
echo "$(basename "$0"): Debug: Installing PHP dependencies from mission-portal repository..." | ||||||||||
( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if test -f "$BASEDIR/mission-portal/composer.json"; then | ||||||||||
cd $BASEDIR/mission-portal | ||||||||||
if test -f "$BASEDIR"/mission-portal/composer.json; then | ||||||||||
cd "$BASEDIR"/mission-portal | ||||||||||
# install PHP dependencies from composer | ||||||||||
php /usr/bin/composer.phar install --no-dev | ||||||||||
run_and_print_on_failure php /usr/bin/composer.phar install --no-dev | ||||||||||
fi | ||||||||||
) | ||||||||||
|
||||||||||
echo "$(basename "$0"): Debug: Installing PHP dependencies from nova repository..." | ||||||||||
( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if test -f "$BASEDIR/nova/api/http/composer.json"; then | ||||||||||
cd $BASEDIR/nova/api/http | ||||||||||
if test -f "$BASEDIR"/nova/api/http/composer.json; then | ||||||||||
cd "$BASEDIR"/nova/api/http | ||||||||||
# install PHP dependencies from composer | ||||||||||
php /usr/bin/composer.phar install --no-dev --ignore-platform-reqs | ||||||||||
run_and_print_on_failure php /usr/bin/composer.phar install --no-dev --ignore-platform-reqs | ||||||||||
fi | ||||||||||
) | ||||||||||
|
||||||||||
echo "$(basename "$0"): Debug: Compiling Mission Portal styles..." | ||||||||||
( | ||||||||||
if test -f "$BASEDIR/mission-portal/public/themes/default/bootstrap/cfengine_theme.less"; then | ||||||||||
cd $BASEDIR/mission-portal/public/themes/default/bootstrap | ||||||||||
npx -p less lessc --compress ./cfengine_theme.less ./compiled/css/cfengine.less.css | ||||||||||
if test -f "$BASEDIR"/mission-portal/public/themes/default/bootstrap/cfengine_theme.less; then | ||||||||||
cd "$BASEDIR"/mission-portal/public/themes/default/bootstrap | ||||||||||
run_and_print_on_failure npx -p less lessc --compress ./cfengine_theme.less ./compiled/css/cfengine.less.css | ||||||||||
fi | ||||||||||
) | ||||||||||
|
||||||||||
echo "$(basename "$0"): Debug: Installing LDAP API dependencies..." | ||||||||||
( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if test -f "$BASEDIR/mission-portal/ldap/composer.json"; then | ||||||||||
cd $BASEDIR/mission-portal/ldap | ||||||||||
if test -f "$BASEDIR"/mission-portal/ldap/composer.json; then | ||||||||||
cd "$BASEDIR"/mission-portal/ldap | ||||||||||
# install PHP dependencies from composer | ||||||||||
php /usr/bin/composer.phar install --no-dev | ||||||||||
run_and_print_on_failure php /usr/bin/composer.phar install --no-dev | ||||||||||
fi | ||||||||||
) | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.