[PATCH 03/10] hal: Clean up scripts in tools

Victor Lowther victor.lowther at gmail.com
Tue Mar 25 18:48:41 PDT 2008


hal-luks-setup and hal-luks-teardown are identical.

Two copies of the same code is rather wasteful.  Delete one, and arrange
to have the install process symlink appropriately.
---
 tools/Makefile.am       |    5 +++-
 tools/hal-luks-setup    |   56 -----------------------------------------------
 tools/hal-luks-teardown |    2 +
 3 files changed, 6 insertions(+), 57 deletions(-)

diff --git a/tools/Makefile.am b/tools/Makefile.am
index ae03edd..4525ff5 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -159,7 +159,6 @@ endif
 scriptdir = $(libdir)/hal/scripts
 
 script_SCRIPTS =				\
-	hal-luks-setup                          \
 	hal-luks-teardown                       \
 	hal-luks-remove		                \
 	hal-system-power-suspend		\
@@ -180,6 +179,10 @@ script_SCRIPTS =				\
 
 EXTRA_DIST=$(man_MANS) $(MAN_IN_FILES) gen-libgphoto-hal-fdi $(script_SCRIPTS)
 
+install_data_hook:
+	-mkdir -p $(DESTDIR)$(scriptdir)
+	-ln -s $(scriptdir)/hal-luks-setup $(DESTDIR)$(scriptdir)/hal-luks-teardown
+
 if HAVE_UMOUNT_HAL
 slashsbindir = /sbin
 slashsbin_PROGRAMS = umount.hal
diff --git a/tools/hal-luks-setup b/tools/hal-luks-setup
deleted file mode 100755
index 83bd92c..0000000
--- a/tools/hal-luks-setup
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2005 W. Michael Petullo <mike at flyn.org>
-# Copyright (C) 2006 David Zeuthen <davidz at redhat.com>
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2.
-
-. hal-functions
-
-locked_out() {
-	echo "org.freedesktop.Hal.Device.InterfaceLocked" >&2
-	echo "Enclosing drive/volume is locked" >&2
-	exit 1
-}
-
-unknown_error() {
-        echo "org.freedesktop.Hal.Device.UnknownError" >&2
-        echo "Missing or empty environment variable(s)." >&2
-        echo "This script should be started by hald." >&2
-        exit 1
-}
-
-if [ -z "$HAL_PROP_BLOCK_DEVICE" ] || [ -z "$HAL_PROP_INFO_UDI" ] || [ -z "$HAL_PROP_VOLUME_UUID" ] ; then
-    unknown_error
-fi
-
-# Respect the same locks as Mount()/Unmount() etc.
-if [ -n "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME" ] ; then
-    hal-is-caller-locked-out --udi $HAL_PROP_INFO_UDI \
-        --interface org.freedesktop.Hal.Device.Volume \
-        --caller "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME"
-    RET=$?
-    if [ "$RET" != "0" ] ; then
-        locked_out
-    fi
-    hal-is-caller-locked-out --udi $HAL_PROP_BLOCK_STORAGE_DEVICE \
-        --interface org.freedesktop.Hal.Device.Storage \
-        --caller "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME"
-    RET=$?
-    if [ "$RET" != "0" ] ; then
-        locked_out
-    fi
-fi
-
-IS_HOTPLUGGABLE=`hal-get-property --udi $HAL_PROP_BLOCK_STORAGE_DEVICE --key storage.hotpluggable`
-if [ "$IS_HOTPLUGGABLE" == "true" ] ; then
-    ACTION="org.freedesktop.hal.storage.crypto-setup-removable"
-elif [ "$IS_HOTPLUGGABLE" == "false" ] ; then
-    ACTION="org.freedesktop.hal.storage.crypto-setup-fixed"
-else
-    unknown_error
-fi
-
-hal_check_priv $ACTION
-hal_exec_backend
diff --git a/tools/hal-luks-teardown b/tools/hal-luks-teardown
index 0f531e7..4158a11 100755
--- a/tools/hal-luks-teardown
+++ b/tools/hal-luks-teardown
@@ -6,6 +6,8 @@
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2.
 
+# This file is symlinked to hal-luks-setup.  The code is identical.
+
 . hal-functions
 
 locked_out() {
-- 
1.5.4.3



More information about the hal mailing list