Skip to content

Commit

Permalink
Merge pull request #49 from iscsi-osx/develop
Browse files Browse the repository at this point in the history
1.0.0-beta2
  • Loading branch information
nsinenian committed May 21, 2016
2 parents 34ea478 + f1b46c4 commit 01bb77d
Show file tree
Hide file tree
Showing 71 changed files with 5,662 additions and 1,797 deletions.
66 changes: 48 additions & 18 deletions Distribution/Scripts/Installer/postinstall
@@ -1,35 +1,65 @@
#! /bin/bash

TMP=/tmp
# Define targets
DAEMON=iscsid
TOOL=iscsictl
KEXT=iSCSIInitiator.kext
MAN1=iscsictl.8
MAN2=iscsid.8
FRAMEWORK=iSCSI.framework
DAEMON_PLIST=com.github.iscsi-osx.iscsid.plist
DAEMON_PLIST_NOEXT=com.github.iscsi-osx.iscsid
MAN_TOOL=iscsictl.8
MAN_DAEMON=iscsid.8

# Define install path
DAEMON_DST=/usr/local/libexec
DAEMON_PLIST_DST=/Library/LaunchDaemons
FRAMEWORK_DST=/Library/Frameworks
TOOL_DST=/usr/local/bin
MAN_DST=/usr/share/man/man8

TMP=/tmp

# Get minor version of the OS
OSX_MINOR_VER=$(sw_vers -productVersion | awk -F '.' '{print $2}')

# Minor version of OS X Mavericks
OSX_MAVERICKS_MINOR_VER="9"

if [ "$OSX_MINOR_VER" -ge "$OSX_MAVERICKS_MINOR_VER" ]; then
KEXT_DST=/Library/Extensions
else
KEXT_DST=/System/Library/Extensions
fi

# Copy kernel extensions & load it
sudo cp -R $TMP/$KEXT /Library/Extensions/$KEXT
sudo chmod -R 755 /Library/Extensions/$KEXT
sudo chown -R root:wheel /Library/Extensions/$KEXT
sudo cp -R $TMP/$KEXT $KEXT_DST/$KEXT
sudo chmod -R 755 $KEXT_DST/$KEXT
sudo chown -R root:wheel $KEXT_DST/$KEXT

# Copy framework
sudo cp -R $TMP/$FRAMEWORK $FRAMEWORK_DST/$FRAMEWORK
sudo chown -R root:wheel $FRAMEWORK_DST/$FRAMEWORK
sudo chmod -R 755 $FRAMEWORK_DST/$FRAMEWORK

# Copy daemon & set permissions
sudo cp $TMP/$DAEMON /Library/PrivilegedHelperTools/$DAEMON
sudo cp $TMP/com.github.iscsi-osx.iscsid.plist /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo chmod -R 744 /usr/local/$DAEMON
sudo chmod 644 /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo chown root:wheel /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo mkdir -p $DAEMON_DST
sudo cp $TMP/$DAEMON $DAEMON_DST/$DAEMON
sudo cp $TMP/$DAEMON_PLIST $DAEMON_PLIST_DST/$DAEMON_PLIST
sudo chmod -R 744 $DAEMON_DST/$DAEMON
sudo chmod 644 $DAEMON_PLIST_DST/$DAEMON_PLIST
sudo chown root:wheel $DAEMON_PLIST_DST/$DAEMON_PLIST

# Copy user tool
sudo cp $TMP/$TOOL /usr/local/bin/$TOOL
sudo chmod +x /usr/local/bin/$TOOL
sudo cp $TMP/$TOOL $TOOL_DST/$TOOL
sudo chmod +x $TOOL_DST/$TOOL

# Copy man pages
sudo cp $TMP/$MAN1 /usr/share/man/man8
sudo cp $TMP/$MAN2 /usr/share/man/man8
sudo cp $TMP/$MAN_TOOL $MAN_DST
sudo cp $TMP/$MAN_DAEMON $MAN_DST

# Load kernel extension
sudo kextload /Library/Extensions/$KEXT
sudo kextload $KEXT_DST/$KEXT

# Start daemon
sudo launchctl load /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo launchctl start com.github.iscsi-osx.iscsid
sudo launchctl load $DAEMON_PLIST_DST/$DAEMON_PLIST
sudo launchctl start $DAEMON_PLIST_NOEXT
59 changes: 50 additions & 9 deletions Distribution/Scripts/Installer/preinstall
Expand Up @@ -4,22 +4,63 @@
DAEMON=iscsid
TOOL=iscsictl
KEXT=iSCSIInitiator.kext
FRAMEWORK=iSCSI.framework
DAEMON_PLIST=com.github.iscsi-osx.iscsid.plist
DAEMON_PLIST_NOEXT=com.github.iscsi-osx.iscsid.plist
MAN_TOOL=iscsictl.8
MAN_DAEMON=iscsid.8

# Define install path
DAEMON_DST=/usr/local/libexec
DAEMON_PLIST_DST=/Library/LaunchDaemons
FRAMEWORK_DST=/Library/Frameworks
TOOL_DST=/usr/local/bin
MAN_DST=/usr/share/man/man8

# Get minor version of the OS
OSX_MINOR_VER=$(sw_vers -productVersion | awk -F '.' '{print $2}')

# Minor version of OS X Mavericks
OSX_MAVERICKS_MINOR_VER="9"

if [ "$OSX_MINOR_VER" -ge "$OSX_MAVERICKS_MINOR_VER" ]; then
KEXT_DST=/Library/Extensions
else
KEXT_DST=/System/Library/Extensions
fi

# Stop, unload and remove launch daemon
sudo launchctl stop /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid
sudo launchctl unload /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo rm -f /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo launchctl stop $DAEMON_PLIST_NOEXT

if [ -f $DAEMON_PLIST_DST/$DAEMON_PLIST ]; then
sudo launchctl unload $DAEMON_PLIST_DST/$DAEMON_PLIST
fi

sudo rm -f $DAEMON_PLIST_DST/$DAEMON_PLIST
sudo rm -f /usr/sbin/$DAEMON # Old location
sudo rm -f /Library/PrivilegedHelperTools/$DAEMON
sudo rm -f /System/Library/LaunchDaemons/$DAEMON_PLIST # Old location
sudo rm -f $DAEMON_DST/$DAEMON

# Unload & remove kernel extension
sudo kextunload /Library/Extensions/$KEXT
sudo rm -f -R /Library/Extensions/$KEXT
if [ -f $KEXT_DST/$KEXT ]; then
sudo kextunload $KEXT_DST/$KEXT
fi

sudo rm -f -R $KEXT_DST/$KEXT

# Remove user tools
sudo rm -f /usr/bin/$TOOL # Old location
sudo rm -f /usr/local/bin/$TOOL
sudo rm -f $TOOL_DST/$TOOL

# Remove man pages
sudo rm -f /usr/share/man/man8/iscsictl.8
sudo rm -f /usr/share/man/man8/iscsid.8
sudo rm -f $MAN_DST/$MAN_TOOL
sudo rm -f $MAN_DST/$MAN_DAEMON

# Remove framework
sudo rm -f -R $FRAMEWORK_DST/$FRAMEWORK

PKG_RSP="$(pkgutil --pkgs=com.github.iscsi-osx.iSCSIInitiator)"

if [ "$PKG_RSP" == "com.github.iscsi-osx.iSCSIInitiator" ]; then
sudo pkgutil --forget com.github.iscsi-osx.iSCSIInitiator
fi
59 changes: 49 additions & 10 deletions Distribution/Scripts/Uninstaller/postinstall
Expand Up @@ -4,24 +4,63 @@
DAEMON=iscsid
TOOL=iscsictl
KEXT=iSCSIInitiator.kext
FRAMEWORK=iSCSI.framework
DAEMON_PLIST=com.github.iscsi-osx.iscsid.plist
DAEMON_PLIST_NOEXT=com.github.iscsi-osx.iscsid.plist
MAN_TOOL=iscsictl.8
MAN_DAEMON=iscsid.8

# Define install path
DAEMON_DST=/usr/local/libexec
DAEMON_PLIST_DST=/Library/LaunchDaemons
FRAMEWORK_DST=/Library/Frameworks
TOOL_DST=/usr/local/bin
MAN_DST=/usr/share/man/man8

# Get minor version of the OS
OSX_MINOR_VER=$(sw_vers -productVersion | awk -F '.' '{print $2}')

# Minor version of OS X Mavericks
OSX_MAVERICKS_MINOR_VER="9"

if [ "$OSX_MINOR_VER" -ge "$OSX_MAVERICKS_MINOR_VER" ]; then
KEXT_DST=/Library/Extensions
else
KEXT_DST=/System/Library/Extensions
fi

# Stop, unload and remove launch daemon
sudo launchctl stop /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid
sudo launchctl unload /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo rm -f /System/Library/LaunchDaemons/com.github.iscsi-osx.iscsid.plist
sudo launchctl stop $DAEMON_PLIST_NOEXT

if [ -f $DAEMON_PLIST_DST/$DAEMON_PLIST ]; then
sudo launchctl unload $DAEMON_PLIST_DST/$DAEMON_PLIST
fi

sudo rm -f $DAEMON_PLIST_DST/$DAEMON_PLIST
sudo rm -f /usr/sbin/$DAEMON # Old location
sudo rm -f /Library/PrivilegedHelperTools/$DAEMON
sudo rm -f /System/Library/LaunchDaemons/$DAEMON_PLIST # Old location
sudo rm -f $DAEMON_DST/$DAEMON

# Unload & remove kernel extension
sudo kextunload /Library/Extensions/$KEXT
sudo rm -f -R /Library/Extensions/$KEXT
if [ -f $KEXT_DST/$KEXT ]; then
sudo kextunload $KEXT_DST/$KEXT
fi

sudo rm -f -R $KEXT_DST/$KEXT

# Remove user tools
sudo rm -f /usr/bin/$TOOL # Old location
sudo rm -f /usr/local/bin/$TOOL
sudo rm -f $TOOL_DST/$TOOL

# Remove man pages
sudo rm -f /usr/share/man/man8/iscsictl.8
sudo rm -f /usr/share/man/man8/iscsid.8
sudo rm -f $MAN_DST/$MAN_TOOL
sudo rm -f $MAN_DST/$MAN_DAEMON

# Remove framework
sudo rm -f -R $FRAMEWORK_DST/$FRAMEWORK

PKG_RSP="$(pkgutil --pkgs=com.github.iscsi-osx.iSCSIInitiator)"

pkgutil --forget com.github.iscsi-osx.iSCSIInitiator
if [ "$PKG_RSP" == "com.github.iscsi-osx.iSCSIInitiator" ]; then
sudo pkgutil --forget com.github.iscsi-osx.iSCSIInitiator
fi
21 changes: 11 additions & 10 deletions Distribution/package.sh
@@ -1,7 +1,7 @@
# Package parameters
NAME="iSCSI Initiator for OS X"
BUNDLE_ID="com.github.iscsi-osx.iSCSIInitiator"
VERSION=$(cd ../ ; agvtool what-version -terse)
VERSION="1.0.0-beta2"

# Output of final DMG
RELEASE="../Release"
Expand Down Expand Up @@ -43,7 +43,7 @@ REQUIREMENTS_PATH="Resources/Requirements.plist"

# Relelase build of all three components
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace \
-scheme iSCSIInitiator -configuration release BUILD_DIR=$XCODE_RELEASE_BUILD_DIR
-scheme iSCSI.kext -configuration release BUILD_DIR=$XCODE_RELEASE_BUILD_DIR
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace \
-scheme iscsid -configuration release BUILD_DIR=$XCODE_RELEASE_BUILD_DIR
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace \
Expand All @@ -68,28 +68,29 @@ pkgbuild --nopayload \
--version $VERSION \
$UNINSTALLER_PATH.tmp


# Put packages inside a product archive
productbuild --distribution $INSTALLER_DIST_XML \
--package-path $TMP_PACKAGE_DIR \
--product $REQUIREMENTS_PATH \
$INSTALLER_PATH
--package-path $TMP_PACKAGE_DIR \
--product $REQUIREMENTS_PATH \
$INSTALLER_PATH

productbuild --distribution $UNINSTALLER_DIST_XML \
--package-path $TMP_PACKAGE_DIR \
--product $REQUIREMENTS_PATH \
$UNINSTALLER_PATH
--package-path $TMP_PACKAGE_DIR \
--product $REQUIREMENTS_PATH \
$UNINSTALLER_PATH

# Cleanup temporary packages, leaving final pacakges for DMG
rm $INSTALLER_PATH.tmp
rm $UNINSTALLER_PATH.tmp

# Build the DMG
hdiutil create -srcfolder $TMP_PACKAGE_DIR -volname "$NAME" -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${DMG_SIZE}k $TMP_ROOT/$DMG_BASE_NAME.dmg
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${DMG_SIZE}k $TMP_ROOT/$DMG_BASE_NAME.dmg

# Load the DMG
device=$(hdiutil attach -readwrite -noverify -noautoopen $TMP_ROOT/$DMG_BASE_NAME.dmg | \
egrep '^/dev/' | sed 1q | awk '{print $1}')
egrep '^/dev/' | sed 1q | awk '{print $1}')

sleep 2

Expand Down
23 changes: 23 additions & 0 deletions LICENSE.md
@@ -0,0 +1,23 @@
Copyright (c) 2016, Nareg Sinenian
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion Scripts/build.sh
@@ -1,3 +1,3 @@
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace -scheme iscsid build
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace -scheme iscsictl build
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace -scheme iSCSIInitiator build
xcodebuild -workspace ../iSCSIInitiator.xcodeproj/project.xcworkspace -scheme iSCSI.kext build

0 comments on commit 01bb77d

Please sign in to comment.