prerun: introduced emulator enviroment generator 01/52401/1
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 23 Jun 2015 14:08:44 +0000 (23:08 +0900)
committerSooyoung Ha <yoosah.ha@samsung.com>
Mon, 23 Nov 2015 07:26:06 +0000 (16:26 +0900)
Emulator environment variables generated by prerun script.
Removed "proxy_setting.sh".

Change-Id: I7d59a47322b8b08367726610775c15b7b39d8374
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
(cherry picked from commit d2ec5e1b8b1ae7178e5ec749b8014a8a4c07bbdd)

filesystem/etc/emulator/prerun
filesystem/etc/emulator/prerun.d/generate-emulator-env.sh [new file with mode: 0644]
filesystem/etc/profile.d/proxy_setting.sh [deleted file]
packaging/system-plugin-emulator.spec

index 77333f1..33451de 100644 (file)
@@ -11,6 +11,7 @@ if [ ! -z $1 ]; then
         ln -sf /bin/busybox /bin/tr
         ln -sf /bin/busybox /bin/expr
         ln -sf /bin/busybox /bin/readlink
+        ln -sf /bin/busybox /bin/rm
 else
         NEW_ROOT=
 fi
diff --git a/filesystem/etc/emulator/prerun.d/generate-emulator-env.sh b/filesystem/etc/emulator/prerun.d/generate-emulator-env.sh
new file mode 100644 (file)
index 0000000..519f81f
--- /dev/null
@@ -0,0 +1,41 @@
+if [ ! -z $1 ]; then
+    NEW_ROOT=$1
+else
+    NEW_ROOT=
+fi
+
+CMDLINE=/proc/cmdline
+EMULATOR_ENV=$(readlink -f $NEW_ROOT/etc/profile.d/emulator_env.sh)
+
+##### network proxy environments
+echo -e "[${_G} network proxy setting ${C_}]"
+
+if [ -f $EMULATOR_ENV ]; then
+    rm -f $EMULATOR_ENV
+fi
+
+# for busybux ash
+PROXIES0="http_proxy"
+PROXIES1="https_proxy"
+PROXIES2="ftp_proxy"
+PROXIES3="socks_proxy"
+
+URLS0="http"
+URLS1="https"
+URLS2="ftp"
+URLS3="socks"
+
+for index in 0 1 2 3
+do
+    eval PROXY="\$PROXIES$index"
+    eval URL="\$URLS$index"
+    if [ ! -z ${PROXY} ] ; then
+        __PROXY=`sed "s/^.*${PROXY}=\([^, ]*\).*$/\1/g" $CMDLINE`
+        if [ "x${__PROXY}" = "x" ] || ! grep -q ${PROXY} $CMDLINE ; then
+            echo "export ${PROXY}=" >> $EMULATOR_ENV
+        else
+            echo "export ${PROXY}=${URL}://${__PROXY}/" >> $EMULATOR_ENV
+        fi
+    fi
+done
+echo "export no_proxy=localhost,127.0.0.1/8,10.0.0.0/1" >> $EMULATOR_ENV
diff --git a/filesystem/etc/profile.d/proxy_setting.sh b/filesystem/etc/profile.d/proxy_setting.sh
deleted file mode 100755 (executable)
index 3361e45..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-function cmd_get
-{
-       cat /proc/cmdline | tr -s [:space:] '\n' | grep -m1 "^$1=" | cut -d= -f2
-}
-
-__proxy=`cmd_get http_proxy`
-[ -n "${__proxy}" ] && export "http_proxy=http://${__proxy}/"
-
-__proxy=`cmd_get https_proxy`
-[ -n "${__proxy}" ] && export "https_proxy=https://${__proxy}/"
-
-__proxy=`cmd_get ftp_proxy`
-[ -n "${__proxy}" ] && export "ftp_proxy=ftp://${__proxy}/"
-
-__proxy=`cmd_get socks_proxy`
-[ -n "${__proxy}" ] && export "socks_proxy=socks://${__proxy}/"
-
-no_proxy="localhost,127.0.0.1/8,10.0.0.0/16"
-
-# Work around for bug in zypper, not handling netmasks in no_proxy.
-# Exlicitly add default gateway ip to no_proxy.
-__gw=`cmd_get ip | cut -d: -f3`
-[ -n "${__gw}" ] && no_proxy="${no_proxy},${__gw}"
-
-export no_proxy
index 6c57aa5..af1135c 100644 (file)
@@ -46,10 +46,10 @@ cp LICENSE %{buildroot}/usr/share/license/%{name}
 %files
 /etc/emulator/prerun
 /etc/emulator/prerun.d/model-config.sh
+/etc/emulator/prerun.d/generate-emulator-env.sh
 /etc/inittab
 /etc/preconf.d/emulator_ns.preinit
 /etc/preconf.d/systemd_conf.preinit
-/etc/profile.d/proxy_setting.sh
 /etc/rc.d/rc.emul
 /etc/rc.d/rc.firstboot
 /etc/rc.d/rc.shutdown