From: SeokYeon Hwang Date: Tue, 23 Jun 2015 14:08:44 +0000 (+0900) Subject: prerun: introduced emulator enviroment generator X-Git-Tag: submit/tizen/20151125.063743~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7ee9411bd39d0b5c00bb7dd4dc1801785924560;p=platform%2Fadaptation%2Femulator%2Fsystem-plugin-emulator.git prerun: introduced emulator enviroment generator Emulator environment variables generated by prerun script. Removed "proxy_setting.sh". Change-Id: I7d59a47322b8b08367726610775c15b7b39d8374 Signed-off-by: SeokYeon Hwang (cherry picked from commit d2ec5e1b8b1ae7178e5ec749b8014a8a4c07bbdd) --- diff --git a/filesystem/etc/emulator/prerun b/filesystem/etc/emulator/prerun index 77333f1..33451de 100644 --- a/filesystem/etc/emulator/prerun +++ b/filesystem/etc/emulator/prerun @@ -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 index 0000000..519f81f --- /dev/null +++ b/filesystem/etc/emulator/prerun.d/generate-emulator-env.sh @@ -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 index 3361e45..0000000 --- a/filesystem/etc/profile.d/proxy_setting.sh +++ /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 diff --git a/packaging/system-plugin-emulator.spec b/packaging/system-plugin-emulator.spec index 6c57aa5..af1135c 100644 --- a/packaging/system-plugin-emulator.spec +++ b/packaging/system-plugin-emulator.spec @@ -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