試験運用中なLinux備忘録・旧記事

はてなダイアリーで公開していた2007年5月-2015年3月の記事を保存しています。

hibernate-script 1.97をインストール

1.97が出た後、なかなかebuildが出ないので、過去のバージョンのebuildを再利用して最新版を入れてみた。

hibernate-script-1.96-r1のebuildに書かれているSRC_URI(サーバから取得するURL)に含まれるパッチ(hibernate-script-1.96-patches-2.tar.bz2)には

の3つがあり、内容を確認したところ、hibernate-script-1.96-pre.patchだけは1.97で全て取り込まれている。hibernate-script-1.95-init.d.patchはそのままでもよいが、dashを使用しないようにするパッチ(hibernate-script-1.94-remove-dash-support.patch)に関しては、該当テキストブロック(Hunk)の内容が若干修正されたため、新しく差分を取り直すことになった。

ファイル名: hibernate-script-1.97-remove-dash-support.patch

Don't switch to different shell.
We use bash.
baselayout script will not work.
Why shell switching is required anyway?

---

diff -ur hibernate-script-1.97.orig/hibernate.sh hibernate-script-1.97/hibernate.sh
--- hibernate-script-1.97.orig/hibernate.sh
+++ hibernate-script-1.97/hibernate.sh
@@ -38,21 +38,6 @@
 
 [ -z "$USING_BASH$USING_ZSH" ] && NEED_POSIX=1
 
-# We prefer to use dash if we've got it.
-if [ -z "$NEED_POSIX" ] && [ -z "$TRIED_DASH" ] &&
-	command -v dash > /dev/null 2>&1 ; then
-
-    if [ "${0##*/}" = "$0" ] ; then
-	myself=`command -v $0` || myself=
-    elif [ -x "$0" ] ; then
-	myself=$0
-    fi
-
-    TRIED_DASH=1
-    export TRIED_DASH
-    [ -n "$myself" ] && exec dash $myself $*
-fi
-unset TRIED_DASH
 
 SWSUSP_D="/etc/hibernate"
 SCRIPTLET_PATH="$SWSUSP_D/scriptlets.d /usr/local/share/hibernate/scriptlets.d /usr/share/hibernate/scriptlets.d"

下のパッチは、hibernate-script-1.95-init.d.patchで代用できる(行がずれているだけなので、hibernate-script-1.95-init.d.patchをそのまま使用しても適用される)。
ファイル名: hibernate-script-1.97-init.d.patch

diff -ur hibernate-script-1.97.orig/init.d/hibernate-cleanup.sh hibernate-script-1.97/init.d/hibernate-cleanup.sh
--- hibernate-script-1.97.orig/init.d/hibernate-cleanup.sh
+++ hibernate-script-1.97/init.d/hibernate-cleanup.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/sbin/runscript
 
 # This script invalidates any stale swsusp and Software Suspend 2 images. It
 # searches all swap partitions on your machine, as well as Suspend2's
@@ -91,27 +91,30 @@
 
 
 msg_status() {
-	echo -n "$1"
+	einfon "$1"
 }
 
 msg() {
-	echo "$1"
+	einfo "$1"
 }
 
-case "$1" in
-start)
-	msg_status "Invalidating stale software suspend images... "
+opts="reload"
+
+depend() {
+	after localmount
+	before bootmisc
+}
+
+start() {
+	ebegin "Invalidating stale software suspend images"
 	do_start
-	msg "done."
-	;;
-stop)
+	eend $?
+}
+
+stop() {
 	do_stop
-	;;
-restart|force-reload)
-	do_reload
-	;;
-*)
-	msg "Usage: /etc/init.d/hibernate {start|stop|restart|force-reload}"
-esac
+}
 
-exit 0
+reload() {
+	do_reload
+}

これら2つのファイルを.tar.bz2ファイルにまとめる。
下はインストール例。ebuildファイルはパッチバージョン部分の修正のみのため、ここには貼らない。sedで作成するようにしている。

$ mkdir patches
$ mv *.patch patches/
$ tar jcvf hibernate-script-1.97-patches-1.tar.bz2 patches/
patches/
patches/hibernate-script-1.97-remove-dash-support.patch
patches/hibernate-script-1.97-init.d.patch
$ sudo mv hibernate-script-1.97-patches-1.tar.bz2 /usr/portage/distfiles/

$ mkdir /usr/local/overlays/local/sys-power/hibernate-script/files -p
$ sed -e 's/PATCH_VERSION="2"/PATCH_VERSION="1"/' /usr/portage/sys-power/hibernate-script/hibernate-script-1.96-r1.ebuild > hibernate-script-1.97.ebuild
$ sudo mv hibernate-script-1.97.ebuild /usr/local/overlays/local/sys-power/hibernate-script/
$ sudo ebuild /usr/local/overlays/local/sys-power/hibernate-script/hibernate-script-1.97.ebuild digest
$ sudo emerge -avu hibernate-script