Skip to content

Commit

Permalink
[rpm] Fixes #894. The removal of the symlinks in %preun now is only…
Browse files Browse the repository at this point in the history
… triggered during an uninstall. Before an update of an package removed the symlinks and left the package in a non-functioning state. (#895)
  • Loading branch information
kodemaniak authored and muuki88 committed Oct 30, 2016
1 parent d9bd270 commit 7ca19fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ case class RpmSpec(meta: RpmMetadata,
if (symlinks.isEmpty)
None
else {
val checkUninstall = "if [ $1 -eq 0 ] ;\nthen"
val sourceAppConfig =
s"""[ -e /etc/sysconfig/$appName ] && . /etc/sysconfig/$appName"""
s""" [ -e /etc/sysconfig/$appName ] && . /etc/sysconfig/$appName"""
val cleanupLinks = symlinks.map { symlink =>
s"""rm -rf $$(relocateLink ${symlink.link} $installDir $appName $$PACKAGE_PREFIX)"""
s""" rm -rf $$(relocateLink ${symlink.link} $installDir $appName $$PACKAGE_PREFIX)"""
}.mkString("\n")

Some(relocateLinkFunction + "\n" + sourceAppConfig + "\n" + cleanupLinks)
Some(relocateLinkFunction + "\n" + checkUninstall + "\n" + sourceAppConfig + "\n" + cleanupLinks + "\nfi")
}

private def relocateLinkFunction: String =
Expand Down
7 changes: 5 additions & 2 deletions src/sbt-test/rpm/scriptlets-rpm/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
| echo "$1"
| fi
|}
|[ -e /etc/sysconfig/rpm-test ] && . /etc/sysconfig/rpm-test
|rm -rf $(relocateLink /etc/rpm-test /usr/share/rpm-test rpm-test $PACKAGE_PREFIX)
|if [ $1 -eq 0 ] ;
|then
| [ -e /etc/sysconfig/rpm-test ] && . /etc/sysconfig/rpm-test
| rm -rf $(relocateLink /etc/rpm-test /usr/share/rpm-test rpm-test $PACKAGE_PREFIX)
|fi
|""".stripMargin,
"%postun scriptlet does not contain relocate link"
)
Expand Down

0 comments on commit 7ca19fd

Please sign in to comment.