From 72299eb93edb6bb6107ca53e2c96564db307aaaa Mon Sep 17 00:00:00 2001 From: Munkyu Im Date: Fri, 8 May 2015 20:45:16 +0900 Subject: [PATCH] install: modify install script Change-Id: I2bee3759862db8ade466b48455eac519d6b96d16 Signed-off-by: Munkyu Im --- package/2.4-emulator-qemu-common.install.macos-64 | 104 ------------- package/2.4-emulator-qemu-x86.install.macos-64 | 177 ++++++++++++++++++++++ package/2.4-emulator-qemu-x86.install.ubuntu-32 | 77 +++++++++- package/2.4-emulator-qemu-x86.install.ubuntu-64 | 83 ++++++++-- tizen/src/Makefile | 23 ++- 5 files changed, 340 insertions(+), 124 deletions(-) delete mode 100755 package/2.4-emulator-qemu-common.install.macos-64 create mode 100755 package/2.4-emulator-qemu-x86.install.macos-64 diff --git a/package/2.4-emulator-qemu-common.install.macos-64 b/package/2.4-emulator-qemu-common.install.macos-64 deleted file mode 100755 index dc2358c..0000000 --- a/package/2.4-emulator-qemu-common.install.macos-64 +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -e - -TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH` -OLD_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax` -SYSCTL_FILE=sysctl.conf -TMP_DIR=~/.installmanager -TIZEN_BIN_PATH=$TIZEN_SDK_INSTALL_PATH/platforms/tizen-2.4/common/emulator/bin -TMP_FILE=$TMP_DIR/setshmmax.sh -TMP_INSTALL_TAP_FILE=$TMP_DIR/install-tap.sh -NEW_SHMMAXSIZE=83886080 -if [ -z $TIZEN_SDK_INSTALL_PATH ] -then - echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log -# exit 2; -fi - -function install_tap { - echo 'make new install-tap.sh file' - - if [ ! -d $TMP_DIR ] - then - mkdir $TMP_DIR - fi - cat << 'EOF' >> $TMP_INSTALL_TAP_FILE -#!/bin/sh -mkdir -p /Library/Extensions -cp -pR tap.kext /Library/Extensions/ -chown -R root:wheel /Library/Extensions/tap.kext -mkdir -p /Library/LaunchDaemons -cp /Library/Extensions/tap.kext/Contents/net.sf.tuntaposx.tap.plist /Library/LaunchDaemons -/sbin/kextload /Library/Extensions/tap.kext -EOF - /bin/chmod +x $TMP_INSTALL_TAP_FILE - echo 'launch install-tap.sh' - $TIZEN_BIN_PATH/cocoasudo "--prompt=Installing tun/tap driver requires that you type your password." sh -x $TMP_INSTALL_TAP_FILE - rm -f $TMP_INSTALL_TAP_FILE -} - -function remove_tmp_file { - if [ -e $TMP_FILE ] - then - echo 'delete ~/tmp/setshmmax.sh' - rm -f $TMP_FILE - fi -} - -function remove_sysctl_file { - if [ -e $TMP_DIR/$SYSCTL_FILE ] - then - echo 'delete ~/tmp/sysctl.conf' - rm -f $TMP_DIR/$SYSCTL_FILE - fi -} - -function makesysctl { - echo 'make new sysctl.conf file to change' - - if [ ! -d $TMP_DIR ] - then - mkdir $TMP_DIR - fi - - remove_sysctl_file; - - echo "kern.sysv.shmmax=83886080" >> $TMP_DIR/$SYSCTL_FILE - echo "kern.sysv.shmmin=1" >> $TMP_DIR/$SYSCTL_FILE - echo "kern.sysv.shmmni=128" >> $TMP_DIR/$SYSCTL_FILE - echo "kern.sysv.shmseg=32" >> $TMP_DIR/$SYSCTL_FILE - echo "kern.sysv.shmall=20480" >> $TMP_DIR/$SYSCTL_FILE - -} - -if [ $OLD_SHMMAXSIZE -lt $NEW_SHMMAXSIZE ] -then - if [ -e /etc/$SYSCTL_FILE ] - then - remove_tmp_file; - makesysctl; - echo "mv -f /etc/sysctl.conf /etc/sysctl.conf.old" >> $TMP_FILE - echo "cp -f $TMP_DIR/$SYSCTL_FILE /etc/." >> $TMP_FILE - echo "sysctl -w kern.sysv.shmmax=$NEW_SHMMAXSIZE" >> $TMP_FILE - chmod +x $TMP_FILE - $TIZEN_BIN_PATH/cocoasudo "--prompt=Changing /etc/sysctl.conf file requires that you type your password.(The original file will be removed to sysctl.conf.old)" sh -x $TMP_FILE - else - remove_tmp_file; - makesysctl; - echo "cp -f $TMP_DIR/$SYSCTL_FILE /etc/." >> $TMP_FILE - echo "sysctl -w kern.sysv.shmmax=$NEW_SHMMAXSIZE" >> $TMP_FILE - chmod +x $TMP_FILE - $TIZEN_BIN_PATH/cocoasudo "--prompt=Make a new /etc/sysctl.conf file requires that you type your password." sh -x $TMP_FILE - fi -fi - -remove_tmp_file; -remove_sysctl_file; -install_tap; -CURRENT_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax` - -if [ ! $OLD_SHMMAXSIZE -eq $CURRENT_SHMMAXSIZE ] -then - echo 'need reboot' - exit 99 -fi - diff --git a/package/2.4-emulator-qemu-x86.install.macos-64 b/package/2.4-emulator-qemu-x86.install.macos-64 new file mode 100755 index 0000000..d892cf0 --- /dev/null +++ b/package/2.4-emulator-qemu-x86.install.macos-64 @@ -0,0 +1,177 @@ +#!/bin/sh -e + +TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH` +OLD_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax` +COCOASUDOPATH="./cocoasudo" +SYSCTL_FILE=sysctl.conf +TMP_DIR=~/.installmanager +TIZEN_BIN_PATH=$TIZEN_SDK_INSTALL_PATH/platforms/tizen-2.4/common/emulator/bin +TIZEN_ETC_PATH=$TIZEN_SDK_INSTALL_PATH/tools/emulator/etc +TMP_FILE=$TMP_DIR/emulator-install.sh +NEW_SHMMAXSIZE=83886080 +if [ -z $TIZEN_SDK_INSTALL_PATH ] +then + echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log +# exit 2; +fi + +function remove_tmp_file { + if [ -e $TMP_FILE ] + then + echo "delete $TMP_FILE" + rm -f $TMP_FILE + fi +} + +function remove_sysctl_file { + if [ -e $TMP_DIR/$SYSCTL_FILE ] + then + echo "delete $TMP_DIR/$SYSCTL_FILE" + rm -f $TMP_DIR/$SYSCTL_FILE + fi +} + +function makesysctl { + echo 'make new sysctl.conf file to change' + + remove_sysctl_file; + + echo "kern.sysv.shmmax=83886080" >> $TMP_DIR/$SYSCTL_FILE + echo "kern.sysv.shmmin=1" >> $TMP_DIR/$SYSCTL_FILE + echo "kern.sysv.shmmni=128" >> $TMP_DIR/$SYSCTL_FILE + echo "kern.sysv.shmseg=32" >> $TMP_DIR/$SYSCTL_FILE + echo "kern.sysv.shmall=20480" >> $TMP_DIR/$SYSCTL_FILE + +} + +function generate_tap_kext_cmd { + echo "mkdir -p /Library/Extensions" >> $TMP_FILE + echo "cp -pR ${TIZEN_ETC_PATH}/tap.kext /Library/Extensions" >> $TMP_FILE + echo "chown -R root:wheel /Library/Extensions/tap.kext" >> $TMP_FILE + echo "mkdir -p /Library/LaunchDaemons" >> $TMP_FILE + echo "cp /Library/Extensions/tap.kext/Contents/net.sf.tuntaposx.tap.plist /Library/LaunchDaemons" >> $TMP_FILE + echo "/sbin/kextload /Library/Extensions/tap.kext" >> $TMP_FILE +} + +function generate_sysctl_cmd { + if [ $OLD_SHMMAXSIZE -lt $NEW_SHMMAXSIZE ] + then + if [ -e /etc/$SYSCTL_FILE ] + then + makesysctl; + echo "mv -f /etc/sysctl.conf /etc/sysctl.conf.old" >> $TMP_FILE + echo "cp -f $TMP_DIR/$SYSCTL_FILE /etc/." >> $TMP_FILE + echo "sysctl -w kern.sysv.shmmax=$NEW_SHMMAXSIZE" >> $TMP_FILE + echo 'echo "Changing /etc/sysctl.conf file. (The original file will be removed to sysctl.conf.old)"' >> $TMP_FILE + else + makesysctl; + echo "cp -f $TMP_DIR/$SYSCTL_FILE /etc/." >> $TMP_FILE + echo "sysctl -w kern.sysv.shmmax=$NEW_SHMMAXSIZE" >> $TMP_FILE + echo 'echo "Make a new /etc/sysctl.conf file."' >> $TMP_FILE + fi + fi +} + +function generate_sudoer_cmd { +cat << 'EOF' >> $TMP_FILE +cp -f ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/emulator-ifup.sh /etc/ +FILE=/etc/sudoers +BACKFILE=/etc/sudoers.bak +TMPFILE=/etc/sudoers.tmp +MESSAGE="# Tizen SDK generated the following script. Do not modify." +LINE1="User_Alias QEMUERS=" +LINE2="Cmnd_Alias QEMU=/etc/emulator-ifup.sh, /etc/emulator-ifdown.sh" +LINE3="QEMUERS ALL=(ALL) NOPASSWD: QEMU" +count=0 + +if [[ "$USER" == "" ]] +then + echo "user is not set. aborting..." + exit 1 +fi + +while read line +do + echo $line + count=$((count+1)) + if [[ $line == $LINE1* ]] + then + echo "find original script" + NAMES=`echo $line | cut -d = -f2` + if [[ "$NAMES"x == ""x ]] + then + cp $FILE $BACKFILE + # in case of blank user + eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE + exit 0 + fi + for i in $(echo $NAMES | tr "," "\n") + do + if [[ "$i" == "$USER" ]] + then + echo "already added the same user" + exit 0 + fi + done + cp $FILE $BACKFILE + # new user is added with comma behind the original users. + eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE + mv $TMPFILE $FILE + exit 0 + fi +done < $FILE + +cp $FILE $BACKFILE +echo "do not find $line" +echo "$MESSAGE" >> $FILE +echo "$LINE1$USER" >> $FILE +echo "$LINE2" >> $FILE +echo "$LINE3" >> $FILE +exit 0 +EOF + +} + +function prepare { + if [ ! -d $TMP_DIR ] + then + echo "make temp directory for emulator install : ( $TMP_DIR )" + mkdir $TMP_DIR + fi + USER=`id -un` + echo "create $TMP_FILE" + echo "#!/bin/bash" > $TMP_FILE + echo "TIZEN_SDK_INSTALL_PATH=$TIZEN_SDK_INSTALL_PATH" >> $TMP_FILE + echo "USER=$USER" >> $TMP_FILE + +} + +function generate { + generate_sysctl_cmd; + generate_tap_kext_cmd; + generate_sudoer_cmd; +} + +function execute { + /bin/chmod +x $TMP_FILE + $TIZEN_BIN_PATH/cocoasudo "--prompt=Please enter your password to install tizen emulator." bash -x $TMP_FILE +} + +function cleanup { + remove_tmp_file; + remove_sysctl_file; +} + +prepare; +generate; +execute; +cleanup; + +CURRENT_SHMMAXSIZE=`sysctl -n kern.sysv.shmmax` + +if [ ! $OLD_SHMMAXSIZE -eq $CURRENT_SHMMAXSIZE ] +then + echo 'need reboot' + exit 99 +fi + diff --git a/package/2.4-emulator-qemu-x86.install.ubuntu-32 b/package/2.4-emulator-qemu-x86.install.ubuntu-32 index 4d51dbb..4d93dfd 100755 --- a/package/2.4-emulator-qemu-x86.install.ubuntu-32 +++ b/package/2.4-emulator-qemu-x86.install.ubuntu-32 @@ -31,30 +31,91 @@ if [ ! -z "${OS_NAME}" ]; then fi echo "Linux Distribution: ${OS_NAME}" -TMP_FILE=init_tizen-kvm.sh -echo "#!/bin/bash -ex" >> ${TMP_FILE} +# need sudo to enable kvm module and set qemu sudoers +TMP_FILE=init_tizen.sh +USER=`id -un` +echo "#!/bin/bash -x" >> ${TMP_FILE} +echo "TIZEN_SDK_INSTALL_PATH=$TIZEN_SDK_INSTALL_PATH" >> ${TMP_FILE} +echo "OS_NAME=$OS_NAME" >> ${TMP_FILE} +echo "USER=$USER" >> ${TMP_FILE} echo "cp ${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/tizen-kvm /etc/init.d/" >> ${TMP_FILE} echo "cp ${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> ${TMP_FILE} echo "/etc/init.d/tizen-kvm start" >> ${TMP_FILE} +cat << 'EOF' >> $TMP_FILE if [ "ubuntu" = "${OS_NAME}" ] ; then - echo "update-rc.d tizen-kvm defaults" >> ${TMP_FILE} + update-rc.d tizen-kvm defaults fi -chmod +x ${TMP_FILE} +cp -f ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/emulator-ifup.sh /etc/ +FILE=/etc/sudoers +BACKFILE=/etc/sudoers.bak +TMPFILE=/etc/sudoers.tmp +MESSAGE="# Tizen SDK generated the following script. Do not modify." +LINE1="User_Alias QEMUERS=" +LINE2="Cmnd_Alias QEMU=/etc/emulator-ifup.sh, /etc/emulator-ifdown.sh, /usr/sbin/openvpn" +LINE3="QEMUERS ALL=(ALL) NOPASSWD: QEMU" +count=0 + +if [[ "$USER" == "" ]] +then + echo "user is not set. aborting..." + exit 1 +fi +while read line +do + echo $line + count=$((count+1)) + if [[ $line == $LINE1* ]] + then + echo "find original script" + NAMES=`echo $line | cut -d = -f2` + if [[ "$NAMES"x == ""x ]] + then + cp $FILE $BACKFILE + # in case of blank user + eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE + exit 0 + fi + for i in $(echo $NAMES | tr "," "\n") + do + if [[ "$i" == "$USER" ]] + then + echo "already added the same user" + exit 0 + fi + done + cp $FILE $BACKFILE + # new user is added with comma behind the original users. + eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE + mv $TMPFILE $FILE + exit 0 + fi +done < $FILE + +cp $FILE $BACKFILE +echo "do not find $line" +echo "$MESSAGE" >> $FILE +echo "$LINE1$USER" >> $FILE +echo "$LINE2" >> $FILE +echo "$LINE3" >> $FILE +exit 0 +EOF + +chmod +x ${TMP_FILE} if [ "${TSUDO}" != "" ] # since installer v2.27 then - TSUDO_MSG="Enter your password to enable kvm module if your machine supports hardware virtualization." + TSUDO_MSG="Enter your password to install Tizen Emulator" TMP_PATH="`pwd`/${TMP_FILE}" - ${TSUDO} -m "${TSUDO_MSG}" sh ${TMP_PATH} + ${TSUDO} -m "${TSUDO_MSG}" bash -x ${TMP_PATH} else GKSUDO=`which gksudo` if [ "${GKSUDO}" = "" ] then echo "there is no gksudo." - sudo ./${TMP_FILE} + sudo bash -x ./${TMP_FILE} else - gksudo ./${TMP_FILE} + gksudo bash -x ./${TMP_FILE} fi fi diff --git a/package/2.4-emulator-qemu-x86.install.ubuntu-64 b/package/2.4-emulator-qemu-x86.install.ubuntu-64 index c6b0fbf..4d93dfd 100755 --- a/package/2.4-emulator-qemu-x86.install.ubuntu-64 +++ b/package/2.4-emulator-qemu-x86.install.ubuntu-64 @@ -31,37 +31,98 @@ if [ ! -z "${OS_NAME}" ]; then fi echo "Linux Distribution: ${OS_NAME}" -TMP_FILE=init_tizen-kvm.sh -echo "#!/bin/bash -ex" >> ${TMP_FILE} -echo "cp ${TIZEN_SDK_INSTALL_PATH}/${PLATFORM_VERSION}/common/emulator/etc/tizen-kvm /etc/init.d/" >> ${TMP_FILE} -echo "cp ${TIZEN_SDK_INSTALL_PATH}/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> ${TMP_FILE} +# need sudo to enable kvm module and set qemu sudoers +TMP_FILE=init_tizen.sh +USER=`id -un` +echo "#!/bin/bash -x" >> ${TMP_FILE} +echo "TIZEN_SDK_INSTALL_PATH=$TIZEN_SDK_INSTALL_PATH" >> ${TMP_FILE} +echo "OS_NAME=$OS_NAME" >> ${TMP_FILE} +echo "USER=$USER" >> ${TMP_FILE} +echo "cp ${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/tizen-kvm /etc/init.d/" >> ${TMP_FILE} +echo "cp ${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> ${TMP_FILE} echo "/etc/init.d/tizen-kvm start" >> ${TMP_FILE} +cat << 'EOF' >> $TMP_FILE if [ "ubuntu" = "${OS_NAME}" ] ; then - echo "update-rc.d tizen-kvm defaults" >> ${TMP_FILE} + update-rc.d tizen-kvm defaults fi -chmod +x ${TMP_FILE} +cp -f ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/emulator-ifup.sh /etc/ +FILE=/etc/sudoers +BACKFILE=/etc/sudoers.bak +TMPFILE=/etc/sudoers.tmp +MESSAGE="# Tizen SDK generated the following script. Do not modify." +LINE1="User_Alias QEMUERS=" +LINE2="Cmnd_Alias QEMU=/etc/emulator-ifup.sh, /etc/emulator-ifdown.sh, /usr/sbin/openvpn" +LINE3="QEMUERS ALL=(ALL) NOPASSWD: QEMU" +count=0 + +if [[ "$USER" == "" ]] +then + echo "user is not set. aborting..." + exit 1 +fi +while read line +do + echo $line + count=$((count+1)) + if [[ $line == $LINE1* ]] + then + echo "find original script" + NAMES=`echo $line | cut -d = -f2` + if [[ "$NAMES"x == ""x ]] + then + cp $FILE $BACKFILE + # in case of blank user + eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE + exit 0 + fi + for i in $(echo $NAMES | tr "," "\n") + do + if [[ "$i" == "$USER" ]] + then + echo "already added the same user" + exit 0 + fi + done + cp $FILE $BACKFILE + # new user is added with comma behind the original users. + eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE + mv $TMPFILE $FILE + exit 0 + fi +done < $FILE + +cp $FILE $BACKFILE +echo "do not find $line" +echo "$MESSAGE" >> $FILE +echo "$LINE1$USER" >> $FILE +echo "$LINE2" >> $FILE +echo "$LINE3" >> $FILE +exit 0 +EOF + +chmod +x ${TMP_FILE} if [ "${TSUDO}" != "" ] # since installer v2.27 then - TSUDO_MSG="Enter your password to enable kvm module if your machine supports hardware virtualization." + TSUDO_MSG="Enter your password to install Tizen Emulator" TMP_PATH="`pwd`/${TMP_FILE}" - ${TSUDO} -m "${TSUDO_MSG}" sh ${TMP_PATH} + ${TSUDO} -m "${TSUDO_MSG}" bash -x ${TMP_PATH} else GKSUDO=`which gksudo` if [ "${GKSUDO}" = "" ] then echo "there is no gksudo." - sudo ./${TMP_FILE} + sudo bash -x ./${TMP_FILE} else - gksudo ./${TMP_FILE} + gksudo bash -x ./${TMP_FILE} fi fi rm ${TMP_FILE} # run check-gl and show pop-up if using gallium driver. -CHECK_GL_CMD=${TIZEN_SDK_INSTALL_PATH}/${PLATFORM_VERSION}/emulator/bin/check-gl +CHECK_GL_CMD=${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/emulator/bin/check-gl GL_WARNING_MSG="You are using invalid graphic card driver for the emulator. You have to use the lastest vendor-provided graphic card driver. diff --git a/tizen/src/Makefile b/tizen/src/Makefile index cf132d7..e20952a 100755 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -212,7 +212,17 @@ endif # give a title name for sdb terminal. ifdef CONFIG_DARWIN cp -pP scripts/sdbscript $(EMUL_DIR)/bin - cp -pP scripts/emulator-ifup.sh $(EMUL_DIR)/bin +endif + +# for bridged network +ifdef CONFIG_LINUX + cp -pP scripts/emulator-ifup-linux.sh $(EMUL_DIR)/etc/emulator-ifup.sh +endif +ifdef CONFIG_DARWIN + cp -pP scripts/emulator-ifup-darwin.sh $(EMUL_DIR)/etc/emulator-ifup.sh +endif +ifdef CONFIG_WIN32 + cp -pP scripts/tap-uninstall.bat $(EMUL_DIR)/bin endif # use shared memory for display framebuffer @@ -313,6 +323,17 @@ ifdef CONFIG_DARWIN cp -pP scripts/sdbscript $(DIBS_COMMON_DIR)/bin endif +# for bridged network +ifdef CONFIG_LINUX + cp -pP scripts/emulator-ifup-linux.sh $(DIBS_X86_DIR)/etc/emulator-ifup.sh +endif +ifdef CONFIG_DARWIN + cp -pP scripts/emulator-ifup-darwin.sh $(DIBS_X86_DIR)/etc/emulator-ifup.sh +endif +ifdef CONFIG_WIN32 + cp -pP scripts/tap-uninstall.bat $(DIBS_COMMON_DIR)/bin +endif + # use shared memory for display framebuffer ifdef CONFIG_USE_SHM ifdef CONFIG_LINUX -- 2.7.4