Refactor code
authorHyunbin Lee <hyunbin.lee@samsung.com>
Wed, 11 Sep 2013 08:05:02 +0000 (17:05 +0900)
committerHyunbin Lee <hyunbin.lee@samsung.com>
Thu, 12 Sep 2013 03:19:37 +0000 (12:19 +0900)
Change-Id: Ia975f1c96424d8b9f51579da3aa279cfb464c659
Signed-off-by: Hyunbin Lee <hyunbin.lee@samsung.com>
CMakeLists.txt
packaging/osp-env-config.spec
src/osp-env-config.c [moved from osp-env-config.c with 95% similarity]

index eb53734..41aa075 100644 (file)
@@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES(
 ) 
 
 SET (${this_target}_SOURCE_FILES
-       ${CMAKE_CURRENT_SOURCE_DIR}/osp-env-config.c
+       src/osp-env-config.c
        )
        
 ADD_SUBDIRECTORY(appinfo)
index e942042..c4fef12 100644 (file)
@@ -28,20 +28,21 @@ osp application environment cofiguration serivce (devel)
 
 %build
 %if 0%{?tizen_build_binary_release_type_eng}
-CXXFLAGS="$CXXFLAGS -D_SECURE_LOG"
+CFLAGS="$CFLAGS -D_SECURE_LOG"
 %endif
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
 %ifarch %{ix86} x86_64
 %if 0%{?simulator}
-CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+CFLAGS="$CFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 %else
-CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+CFLAGS="$CFLAGS -D_OSP_DEBUG_ -D_OSP_X86_" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 %endif
 %else
 %if 0%{?tizen_build_binary_release_type_eng}
-CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_ -D_SECURE_LOG" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+CFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_ -D_SECURE_LOG" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 %else
-CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+CFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 %endif
 %endif
 
similarity index 95%
rename from osp-env-config.c
rename to src/osp-env-config.c
index b4937f6..74526fe 100644 (file)
@@ -76,8 +76,8 @@ get_app_rootpath_from_path(const char* bin_path)
        char* app_rootpath = NULL;
        char* delimiter = NULL;
        size_t length = 0;
-       /* e.g., The specified bin_path is "/opt/apps/com.samsung.basicapp/bin/basicapp" */
 
+       /* e.g., The specified bin_path is "/opt/apps/com.samsung.basicapp/bin/basicapp" */
        length = strlen(bin_path);
        app_rootpath = (char *)malloc(length + 1);
        if(app_rootpath == NULL)
@@ -572,7 +572,7 @@ mount_osp_external_paths(const char* app_rootpath, const char* pkgid)
 }
 
 int
-do_pre_exe(const char* package_name, const char* bin_path, const char* package_id)
+do_pre_exe(const char* bin_path, const char* package_id)
 {
        char* app_rootpath = NULL;
        int mmc_mounted = 0;
@@ -587,8 +587,8 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
        /* e.g., app_rootdir is "/opt/usr/apps/[pkgId] */
        app_rootpath = get_app_rootpath_from_path(bin_path);
 
-       _SECURE_LOGI("[data_caging] do_pre_exe() was called, package name: %s, package id: %s, binary: %s, app root: %s",
-                       package_name, package_id, bin_path, app_rootpath);
+       _SECURE_LOGI("[data_caging] do_pre_exe() was called, package id: %s, binary path: %s, app root: %s",
+                       package_id, bin_path, app_rootpath);
 
        umask(0000);
 
@@ -648,14 +648,14 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
        free(app_rootpath);
        umask(0022);
 
-       LOGI("[data_caging] do_pre_exec() succeeded.");
+       LOGI("[data_caging] do_pre_exe() succeeded.");
        return 0;
 
 ERROR:
        free(app_rootpath);
        umask(0022);
 
-       LOGI("[data_caging] do_pre_exec() failed.");
+       LOGI("[data_caging] do_pre_exe() failed.");
        return -1;
 }
 
@@ -710,7 +710,7 @@ do_pre_exec(const char* package_name, const char* bin_path)
        char osp_app_data_path[PATH_MAX] = { 0, };
        int osp_compat = 0;
 
-       _SECURE_LOGI("do_pre_exec() is called, package name: %s, binary path: %s", package_name, bin_path);
+       _SECURE_LOGI("do_pre_exec() is called, app name: %s, binary path: %s", package_name, bin_path);
 
        app_rootpath = get_app_rootpath_from_path(bin_path);
 
@@ -721,21 +721,9 @@ do_pre_exec(const char* package_name, const char* bin_path)
                osp_compat = 1;
        }
 
-       // XXX: temp code
-       //if (package_name == NULL)
-       {
-               //LOGI("The package name is empty.");
-               get_package_id_from_app_rootpath(app_rootpath, package_id);
-       }
-#if 0
-       else
-       {
-               get_package_id_from_package_name(package_name, package_id);
-       }
-#endif
-       // XXX-end
+       get_package_id_from_app_rootpath(app_rootpath, package_id);
 
-       _SECURE_LOGI("package: %s (%s), binary: %s, OSP compat: %d", package_name, package_id, bin_path, osp_compat);
+       _SECURE_LOGI("package id: %s, binary path: %s, OSP compat: %d", package_id, bin_path, osp_compat);
 
        // FIXME: Temporary code with security risk
        prctl(PR_SET_KEEPCAPS, 1);
@@ -744,7 +732,7 @@ do_pre_exec(const char* package_name, const char* bin_path)
        {
                free(app_rootpath);
                //unshare(CLONE_NEWNS);
-               return do_pre_exe(package_name, bin_path, package_id);
+               return do_pre_exe(bin_path, package_id);
        }
 
        char virtual_root_file[PATH_MAX] = { 0, };