Skip to content
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

Fixes for RPM related functionality in 1.0.5-M2 #668

Merged
merged 2 commits into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ then
addUser ${{daemon_user}} "${{daemon_user_uid}}" ${{daemon_group}} "${{app_name}} user-daemon" "${{daemon_shell}}"
fi

[ -e /etc/sysconfig/${{app_name}} ] && sed -i 's/PACKAGE_PREFIX\=.*//g' /etc/sysconfig/${{app_name}}
[ -n "$RPM_INSTALL_PREFIX" ] && echo "PACKAGE_PREFIX=${RPM_INSTALL_PREFIX}" >> /etc/sysconfig/${{app_name}}
if [ -e /etc/sysconfig/${{app_name}} ] ;
then
sed -i 's/PACKAGE_PREFIX\=.*//g' /etc/sysconfig/${{app_name}}
fi

if [ -n "$RPM_INSTALL_PREFIX" ] ;
then
echo "PACKAGE_PREFIX=${RPM_INSTALL_PREFIX}" >> /etc/sysconfig/${{app_name}}
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these changes necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, without these changes the preinst script will fail and abort should the if condition turns out to be false.

Without rpmPrefix being specified, the [ -n "$RPM_INSTALL_PREFIX" ] will return false, and the preinst will abort with a failure.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

INSTALL_DIR="${{chdir}}"
[ -n "${PACKAGE_PREFIX}" ] && INSTALL_DIR="${PACKAGE_PREFIX}/${{app_name}}"
cd $INSTALL_DIR

exec="$INSTALL_DIR/bin/${{exec}}"
prog="${{app_name}}"
Expand Down
17 changes: 15 additions & 2 deletions src/sbt-test/rpm/sysvinit-rpm/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ TaskKey[Unit]("unzipAndCheck") <<= (baseDirectory, packageBin in Rpm, streams) m
assert(scriptlets contains "deleteUser rpm-test", "deleteUser rpm not present in \n" + scriptlets)

val startupScript = IO.read(baseDir / "etc" / "init.d" / "rpm-test")
assert(startupScript contains
"""
|INSTALL_DIR="/usr/share/rpm-test"
|[ -n "${PACKAGE_PREFIX}" ] && INSTALL_DIR="${PACKAGE_PREFIX}/rpm-test"
|cd $INSTALL_DIR
|""".stripMargin, "Ensuring application is running on the install directory is not present in \n" + startupScript)
assert(startupScript contains """RUN_CMD="$exec >> /var/log/rpm-test/test.log 2>&1 &"""", "Setting key rpmDaemonLogFile not present in \n" + startupScript)

// TODO check symlinks
Expand All @@ -46,8 +52,15 @@ TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
assert(spec contains "deleteUser rpm-test", "deleteUser rpm not present in \n" + spec)
assert(spec contains
"""
|[ -e /etc/sysconfig/rpm-test ] && sed -i 's/PACKAGE_PREFIX\=.*//g' /etc/sysconfig/rpm-test
|[ -n "$RPM_INSTALL_PREFIX" ] && echo "PACKAGE_PREFIX=${RPM_INSTALL_PREFIX}" >> /etc/sysconfig/rpm-test
|if [ -e /etc/sysconfig/rpm-test ] ;
|then
| sed -i 's/PACKAGE_PREFIX\=.*//g' /etc/sysconfig/rpm-test
|fi
|
|if [ -n "$RPM_INSTALL_PREFIX" ] ;
|then
| echo "PACKAGE_PREFIX=${RPM_INSTALL_PREFIX}" >> /etc/sysconfig/rpm-test
|fi
|""".stripMargin, "Persisting $RPM_INSTALL_PREFIX not present in \n" + spec)
()
}