Skip to content

Commit

Permalink
post_install.sh marks its completion
Browse files Browse the repository at this point in the history
Summary:
yugabyted uses a marker file post_install.sh.completed to avoid rerunning post install if
it has already been run. In case of docker images, we will run post install during docker build and
avoid running it from yugabyted.

Test Plan:
Make package, run post_install, run yugabyted, verify it does not run post install again

Jenkins: skip

Reviewers: timur, wesley, mikhail

Reviewed By: wesley, mikhail

Subscribers: jason

Differential Revision: https://phabricator.dev.yugabyte.com/D7633
  • Loading branch information
iSignal committed Dec 2, 2019
1 parent d40f0e0 commit 3a15aa9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
12 changes: 0 additions & 12 deletions bin/yugabyted
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,6 @@ class ControlScript(object):
return

post_install_script_path = os.path.join(YUGABYTE_DIR, 'bin', 'post_install.sh')
post_install_completion_bin_path = post_install_script_path + ".completed"
post_install_completion_flag_path = os.path.join(
YUGABYTE_DIR, os.path.basename(post_install_completion_bin_path))

# Check both "bin" and top-level "yugabyte" dir in case post_install was run
# from another source (e.g. yb-ctl).
if os.path.exists(post_install_completion_flag_path) \
or os.path.exists(post_install_completion_bin_path):
return

Output.log("Running the post-installation script {}".format(post_install_script_path))
process = subprocess.Popen(
Expand All @@ -608,9 +599,6 @@ class ControlScript(object):
post_install_script_path, process.returncode, std_out, std_err))
Output.log("Successfully ran the post-installation script.")

with open(post_install_completion_flag_path, 'w'):
# Write an empty file.
pass

# Initialize YW process. Creates all necessary tables. Returns false if init failed.
def init_yw(self):
Expand Down
20 changes: 14 additions & 6 deletions build-support/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ lib_dir="$distribution_dir/lib"
linuxbrew_dir="$distribution_dir/linuxbrew"
rpath="$lib_dir/yb:$lib_dir/yb-thirdparty:$linuxbrew_dir/lib"
patchelf_path=$bin_dir/patchelf
script_name=$(basename "$0")
completion_file="$distribution_dir/.${script_name}.completed"

if [[ -f $completion_file ]];
then
echo "${script_name} was already run (marker at ${completion_file})"
exit
fi

if [[ ! -x $patchelf_path ]]; then
echo >&2 "patchelf not found or is not executable: '$patchelf_path'"
Expand Down Expand Up @@ -66,22 +74,20 @@ done
# We are filtering out warning from stderr which are produced by this bug:
# https://github.com/NixOS/patchelf/commit/c4deb5e9e1ce9c98a48e0d5bb37d87739b8cfee4
# This bug is harmless, it only could unnecessarily increase file size when patching.
find $lib_dir $linuxbrew_dir -name "*.so*" ! -name "ld.so*" -exec "$patchelf_path" \
find "$lib_dir" "$linuxbrew_dir" -name "*.so*" ! -name "ld.so*" -exec "$patchelf_path" \
--set-rpath "$rpath" {} 2> \
>(grep -v 'warning: working around a Linux kernel bug by creating a hole' >&2) \;

ORIG_BREW_HOME=${original_linuxbrew_path_to_patch}
ORIG_LEN=${#ORIG_BREW_HOME}
ORIG_BREW_HOME_DIR=${ORIG_BREW_HOME##*/}
BREW_DIR_NAME=${ORIG_BREW_HOME_DIR%-*}

# Take $ORIG_LEN number of '\0' from /dev/zero, replace '\0' with 'x', then prepend to
# "$distribution_dir/linuxbrew-" and keep first $ORIG_LEN symbols, so we have a path of $ORIG_LEN
# length.
BREW_HOME=$(echo "$distribution_dir/linuxbrew-$(head -c $ORIG_LEN </dev/zero | tr '\0' x)" | \
cut -c-$ORIG_LEN)
BREW_HOME=$(echo "$distribution_dir/linuxbrew-$(head -c "$ORIG_LEN" </dev/zero | tr '\0' x)" | \
cut -c-"$ORIG_LEN")
LEN=${#BREW_HOME}
if [[ $LEN != $ORIG_LEN ]]; then
if [[ "$LEN" != "$ORIG_LEN" ]]; then
echo "Linuxbrew should be linked to a directory having absolute path length of $ORIG_LEN bytes," \
"but actual length is $LEN bytes."
exit 1
Expand All @@ -91,3 +97,5 @@ ln -sfT "$linuxbrew_dir" "$BREW_HOME"

find "$distribution_dir" -type f -not -path "$distribution_dir/yugabyte-logs/*" \
-exec sed -i --binary "s%$ORIG_BREW_HOME%$BREW_HOME%g" {} \;

touch "$completion_file"

0 comments on commit 3a15aa9

Please sign in to comment.