# -*-mic2-options-*- -A i686 -f loop --pack-to=@NAME@.tar.gz -*-mic2-options-*-

# 
# Do not Edit! Generated by:
# kickstarter.py
# 

lang en_US.UTF-8
keyboard us
timezone --utc Asia/Seoul
part / --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-rootfs --extoptions="-O ^64bit,^metadata_csum"
part /opt/ --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-sysdata --extoptions="-O ^64bit,^metadata_csum"


rootpw tizen 
xconfig --startxonboot
bootloader  --timeout=3  --append="rw vga=current splash rootwait rootfstype=ext4 plymouth.enable=0"   --ptable=gpt --menus="install:Wipe and Install:systemd.unit=system-installer.service:test"

desktop --autologinuser=root  
user --name root  --groups audio,video --password 'tizen'


repo --name=unified-emulator --baseurl=http://download.tizen.org/snapshots/tizen/unified/@BUILD_ID@/repos/emulator/packages/ --ssl_verify=no
repo --name=base-standard --baseurl=http://download.tizen.org/snapshots/tizen/base/latest/repos/standard/packages/ --ssl_verify=no


%packages

# @ Generic Base
bash
connman
coreutils
default-ac-domains
e2fsprogs
filesystem
glibc-locale
gum-utils
kmod
kmod-compat
lrzsz
net-tools
pam
pam-locale
procps
psmisc
rpm
rpm-security-plugin
setup
shadow-utils-adm
systemd
tizen-release
tlm
tzdata
util-linux
wpa_supplicant
# @ Wearable Base
account-manager
account-parser
capi-base-utils
deviced
deviced-plugin-profile-wearable
deviced-tools
dlogutil
fsck-msdos
libaccount-service
libopenssl
libstorage
lzo
newfs-msdos
tizen-locale
tizen-release-profile_wearable
tlm-config-common-singleseat
# @ Wearable Console Tools
curl
findutils
gdb
grep
gzip
iptables
strace
tar
unzip
xz
zip
# @ Wearable Packaging
# @ Wearable Adaptation
# @ Wearable Wayland
xkeyboard-config
# @ Wearable Middleware
SDL2
SDL2_ttf
account-common
activationd
ambient-viewer
amd
amd-mod-boost
amd-mod-cooldown
amd-mod-cynara-core
amd-mod-extractor
amd-mod-input
amd-mod-loader-manager
amd-mod-rua
amd-mod-screen-resolution
amd-mod-share
amd-mod-splash-screen
amd-mod-ui-core
amd-mod-watchdog
amd-mod-wayland-core
amd-mod-widget
app-defined-loader
app2sd
appcore-agent
appcore-ui-app-ambient
appcore-widget
argos_watchdog
askuser-notification
askuser-notification-client
audit-trail
aurum
aurum-bootstrap
auth-fw
batterymonitor
batterymonitor-plugins-bluetooth
batterymonitor-plugins-cpu
batterymonitor-plugins-display
batterymonitor-plugins-wifi
boost-date-time
boost-regex
buxton2
cairo
calendar-service
capi-appfw-alarm
capi-appfw-app-common
capi-appfw-app-control
capi-appfw-component-manager
capi-appfw-event
capi-appfw-job-scheduler
capi-appfw-preference
capi-appfw-tizen-theme
capi-context
capi-maps-service
capi-messaging-email
capi-messaging-messages
capi-network-stc
capi-privacy-privilege-manager
capi-system-battery-monitor
capi-system-info-tool
capi-system-media-key
capi-system-resource-monitor
capi-system-runtime-info
capi-system-sensor-profile_wearable
capi-ui-gesture
capi-web-url-download
cert-svc
component-based-application
component-based-efl-widget
component-based-port
contacts-service
context-app-history-profile_wearable
context-job-scheduler
context-sensor-recorder-profile_wearable
context-service
crash-worker
csr-framework
cynara
dali-csharp-binder-profile_wearable
data-control
dbus-tools
device-certificate-manager
device-policy-manager
diagnostics
download-fonts-service
download-provider
dpm-application
dpm-auth
dpm-bluetooth
dpm-browser
dpm-email
dpm-location
dpm-media
dpm-security
dpm-storage
dpm-telephony
dpm-usb
dpm-wifi
drm-service-core-tizen
dummyasm
dumpsys
email-service
esd
eventsystem
feedbackd
feedbackd-conf-level3
fido-asm
fido-client
fido_bt_roaming_agent
fido_silent
frame-broker
frame-provider
gmime
gumd-profile_wearable
hal-api-common
hal-api-common-haltests
hal-api-device
hal-api-location
hal-api-power
hal-api-sensor
hal-api-tbm
hal-api-tdm
heremaps-uc-launcher
iotcon
key-manager
key-manager-pam-plugin
klay
launchpad
launchpad-loader
lbs-server
lbs-server-plugin-replay
libaskuser-notification-common
libaudit-trail
libauth-fw-client
libauth-fw-client-admin
libcalendar-service
libcontacts-service
libcore-sync-client
libcsr-framework-client
libcynara-creds-commons
libcynara-creds-dbus
libcynara-creds-gdbus
libcynara-creds-self
libcynara-creds-socket
libcynara-monitor
libdpm
libdumpsys-system
libeom
libhyphen
libkey-manager-client
libkey-manager-common
libnss-security-manager
liboauth
libode
libpass-resource-monitor
libphonenumber
libscl-core-profile_wearable
libscreen_connector_launcher_service
libscreen_connector_shared_widget_launch
libspeex
libuw-imap-toolkit
libwatchface-complication
libwatchface-complication-provider
libwatchface-editor
libwebappenc
location-lbs-server
lottie-player
memps
minicontrol
mms-plugin
modes-lib
modes-plugins
msg-manager
multi-assistant
murphy
nghttp2
nsjail
oauth2
ode
ode-dummy-ksp
opentk
org.tizen.analog-watch
org.tizen.ode
org.tizen.privacy-setting-popup-profile_wearable
org.tizen.privacy-setting-profile_wearable
org.tizen.secure-erase
org.tizen.setting-location-wearable
org.tizen.vc-engine-default
org.tizen.watch-face-editor
pass
phonenumber-utils
pims-ipc
pkgmgr-server
pkgmgr-tool
privilege-checker
privilege-info
resourced
rive-tizen
rpc-port
sdbd
security-config
security-config-profile_wearable
security-license-manager
security-privilege-manager
security-privilege-manager-extension-wearable
sensord-profile_wearable
sessiond
sms-plugin
stc-iptables
stc-manager
stc-manager-plugin-appstatus
stc-manager-plugin-exception
stc-manager-plugin-procfs
storaged
storaged-module_storage
stt
svi-data-profile_wearable
sync-service
system-plugin-feature-namespace
system-plugin-feature-session-bind
system-servant
system-servant-extension-circle-profile_wearable
tcpdump
tef-libteec
thorvg
tizen-debug
tizen-default-modes
tizen-theme-manager
toybox
toybox-symlinks-dhcp
toybox-symlinks-dhcpd
ttrace
tts-engine-rsc
tzsh
ui-gadget-1
vc-webview
vc-webview-js
vconf-internal-keys
vconf-internal-keys-config-profile_wearable
voice-control
voice-control-elm
watch-holder
webapi-plugins-teec
xdelta3
yaca
# @ Wearable Applications
app-core-ui
app-installers
aul
aul-exec-checker-plugin
boot-animation
ca-certificates
data-provider-master
libpush
libwidget_service
libwidget_viewer_dali
libwidget_viewer_evas
my-account-profile_wearable
org.tizen.accessibility-setting-profile_wearable
org.tizen.app-selector-profile_wearable
org.tizen.apptray-widget
org.tizen.askuser-popup-profile_wearable
org.tizen.autofilld
org.tizen.bluetooth
org.tizen.bt-syspopup
org.tizen.callmgr-popup
org.tizen.classic-watch
org.tizen.crash-syspopup
org.tizen.default-dark-theme
org.tizen.default-light-theme
org.tizen.dpm-syspopup
org.tizen.gesture-engine-default
org.tizen.heremaps-uc
org.tizen.idle-clock-digital
org.tizen.inputdelegator
org.tizen.inputdelegator-profile_wearable
org.tizen.inputmethod-setting-profile_wearable
org.tizen.multi-assistant-service
org.tizen.net-popup
org.tizen.powerkey-syspopup.wearable
org.tizen.privacy-setting-profile_wearable
org.tizen.screen-reader-profile_wearable
org.tizen.stt-engine-default
org.tizen.stt-engine-embedded
org.tizen.system-syspopup.wearable
org.tizen.telephony-syspopup
org.tizen.tts-engine-default
org.tizen.w-call-ui
org.tizen.w-ciss
org.tizen.w-clock-viewer
org.tizen.w-contacts
org.tizen.w-home
org.tizen.w-message
org.tizen.w-wifi
org.tizen.watch-setting
org.tizen.widget_viewer_sdk
push-bin
starter
starter-profile_wearable
tpk-backend
unified-backend
wakeup-engine-default
wgt-backend
# @ Wearable TPK Applications
org.tizen.sketch
org.tizen.w-call-setting
org.tizen.w-task-mgr
# @ Wearable Bluetooth
bluetooth-agent
bluetooth-agent-hfp_ag
bluetooth-agent-hfp_hf
bluetooth-agent-hid
bluetooth-frwk-core
bluetooth-frwk-plugin-headed
bluetooth-frwk-profile_wearable
bluetooth-frwk-service
bluez
bluez-mesh
bluez-profile_wearable
hal-api-bluetooth
obexd
org.tizen.bt-syspopup-profile_wearable
# @ Generic Multimedia
GraphicsMagick-c++
alsa-utils
gst-plugins-bad
gst-plugins-base
gst-plugins-good
gstreamer
gstreamer-utils
pulseaudio
pulseaudio-module-bluetooth
pulseaudio-modules-tizen
pulseaudio-utils
# @ Wearable Multimedia Emulator
alure
camera-hal-v4l2
capi-media-camera
capi-media-codec
capi-media-editor
capi-media-metadata-editor
capi-media-player
capi-media-player-utils
capi-media-radio
capi-media-recorder
capi-media-sound-pool
capi-media-streamer
capi-media-streamrecorder
capi-media-thumbnail-util
capi-media-tone-player
capi-media-tool
capi-media-vision
capi-media-webrtc
capi-mediademuxer
capi-mediamuxer
dcm-service
esplusplayer
freealut
gst-libav
gst-plugins-tizen
gst-plugins-ugly
inference-engine-interface-common
inference-engine-opencv
inference-engine-tflite
libmm-camcorder
libmm-common
libmm-display
libmm-evas-renderer
libmm-fileinfo
libmm-imgp-gstcs
libmm-player
libmm-radio
libmm-sound
libmm-streamrecorder
libtrackrenderer
media-config-simulator
media-thumbnail-server
mediacontroller
mmsvc-camera
mmsvc-player
mmsvc-recorder
murphy-glib
mused
openal-soft
opencv
pulseaudio-modules-tizen
soundtouch
taglib
zbar
zint
# @ Wearable Crosswalk
# @ Wearable Dali
dali
dali-adaptor
dali-adaptor-profile_wearable
dali-csharp-binder
dali-extension
dali-extension-key-extension
dali-extension-vector-animation-renderer-plugin
dali-extension-video-player-plugin
dali-toolkit
dali-toolkit-resources_360x360
dali2
dali2-adaptor
dali2-adaptor-profile_wearable
dali2-csharp-binder
dali2-csharp-binder-profile_wearable
dali2-extension
dali2-extension-camera-player-plugin
dali2-extension-color-controller-plugin
dali2-extension-key-extension
dali2-extension-rive-animation-view
dali2-extension-vector-animation-renderer-plugin
dali2-extension-vector-image-renderer-plugin
dali2-extension-video-player-plugin
dali2-extension-web-engine-chromium-plugin
dali2-extension-web-engine-lwe-plugin
dali2-toolkit
dali2-toolkit-resources_360x360
vulkan-wsi-tizen
# @ Wearable EFL
at-spi2-core
capi-ui-efl-util
default-fonts-fc-sdk
default-fonts-sdk
ecore-buffer
efl-config
efl-locale
efl-misc-profile_wearable
efl-modules-profile_wearable
efl-theme-tizen-wearable
elementary-tizen
libatk
libatk-bridge-2_0-0
libatspi0
typelib-1_0-Atspi-2_0
# @ Wearable Enlightenment
e-mod-tizen-devicemgr
e-mod-tizen-gesture
e-mod-tizen-keyrouter
e-mod-tizen-processmgr
e-mod-tizen-screen-reader
e-mod-tizen-wl-textinput
e-mod-tizen-wm-policy
e-tizen-data-profile_wearable
enlightenment
# @ Wearable Input Framework
anthy
autofill-config-wearable
capi-ui-autofill
capi-ui-autofill-common
capi-ui-autofill-manager
capi-ui-autofill-service
capi-ui-inputmethod
capi-ui-inputmethod-manager
capi-ui-sticker
ise-default
ise-default-profile_wearable
ise-engine-default
ise-engine-loader
isf
isf-config-wearable
libhangul
libscl-ui
org.tizen.autofill-setting-wearable
org.tizen.inputmethod-setting
smartreply
smartreply-service
# @ Wearable Connectivity Framework
asp-manager
capi-network-asp
capi-network-http
capi-network-inm
capi-network-nfc
capi-network-smartcard
capi-network-softap
capi-network-ua
capi-network-vine
capi-network-wifi
capi-network-wifi-aware
capi-network-wifi-manager
clat
hal-api-wifi
inm-manager
libbpf
libdns_sd
libnsd-dns-sd
libnsd-ssdp
libtfeature
mdnsresponder
mobileap-agent
mobileap-agent-extension-headed
nan-manager
net-config-plugin-battery
net-config-plugin-headed
net-config-plugin-stc
net-config-profile_wearable
ua-manager
ua-plugin-wifi-dummy
# @ Wearable Connectivity Framework Emulator
hal-api-nfc
nfc-common-lib
nfc-manager
nfc-plugin-emul
ug-nfc-efl
ug-nfc-efl-profile_wearable
# @ Wearable Security
libsecurity-manager-client
security-manager
# @ Wearable Web Framework
chromium-efl
cordova-api
libre2
libwebsockets
org.tizen.webapp-addon-setting_wearable
web-widget-runtime
webapi-plugins
webapi-plugins-profile_wearable
wrtjs
# @ Wearable Telephony
call-manager
capi-telephony
libcall-manager
libtcore
tel-plugin-database
tel-plugin-dbus_tapi
tel-plugin-indicator
tel-plugin-manager
tel-plugin-nitz
tel-plugin-packetservice
tel-plugin-packetservice-dbinit-profile_common
tel-plugin-syspopup
tel-plugin-vconf
telephony-daemon
telephony-daemon-profile_common
# @ Wearable dotNet
csapi-tizenfx-wearable
dotnet-launcher
elm-sharp-theme-wearable
keyutils
krb5
libkeyutils
xsf
# @ Wearable dotNet Runtime
coreclr
coreclr-diagnostics
corefx-managed
corefx-native
crossgen2-mic
mscorlib
patchelf
# @ Wearable Machine Learning
capi-machine-learning-inference
capi-machine-learning-service
capi-machine-learning-training
nnstreamer
nnstreamer-flatbuf
nnstreamer-nnfw
nnstreamer-protobuf
nnstreamer-tensorflow-lite
nnstreamer-tensorflow2-lite
nntrainer
# @ Wearable Adaptation Emulator Circle
audio-hal-emul
boot-animation-extension_emulator
coregl
emulator-yagl
emuld
gssdp
gst-plugins-emulator
hal-backend-device-emulator
hal-backend-sensor-emulator
ise-default-profile_wearable-extension-circle
libtbm-vigs
libtdm-client
libtdm-drm
model-config-emulator-profile_wearable
org.tizen.inputmethod-setting-profile_wearable-extension-circle
sdbd-extension-emulator
swap-manager
swap-modules-emulator32
swap-probe
swap-probe-elf
system-plugin
system-plugin-emulator
system-plugin-feature-init_wrapper
tel-plugin-atmodem
tel-plugin-vmodem
vmodemd-emul
webapi-plugins-wearable-extension-emulator
# Others



lightweight-web-engine-profile_wearable

%end



%post
#!/bin/sh
echo "#################### generic-base.post ####################"

test ! -e /opt/var && mkdir -p /opt/var
test -d /var && cp -arf /var/* /opt/var/
rm -rf /var
ln -snf opt/var /var

test ! -e /opt/usr/home && mkdir -p /opt/usr/home
test -d /home && cp -arf /home/* /opt/usr/home/
rm -rf /home
ln -snf opt/usr/home /home

build_ts=$(date -u +%s)
build_date=$(date -u --date @$build_ts +%Y%m%d_%H%M%S)
build_time=$(date -u --date @$build_ts +%H:%M:%S)

sed -ri \
	-e 's|@BUILD_ID[@]|@BUILD_ID@|g' \
	-e "s|@BUILD_DATE[@]|$build_date|g" \
	-e "s|@BUILD_TIME[@]|$build_time|g" \
	-e "s|@BUILD_TS[@]|$build_ts|g" \
	/etc/tizen-build.conf

# setup systemd default target for user session
cat <<'EOF' >>/usr/lib/systemd/user/default.target
[Unit]
Description=User session default target
EOF
mkdir -p /usr/lib/systemd/user/default.target.wants

# sdx: fix smack labels on /var/log
chsmack -a '*' /var/log

# create appfw dirs inside homes
function generic_base_user_exists() {
	user=$1
	getent passwd | grep -q ^${user}:
}

function generic_base_user_home() {
	user=$1
	getent passwd | grep ^${user}: | cut -f6 -d':'
}

function generic_base_fix_user_homedir() {
	user=$1
	generic_base_user_exists $user || return 1

	homedir=$(generic_base_user_home $user)
	mkdir -p $homedir/apps_rw
	for appdir in desktop manifest dbspace; do
		mkdir -p $homedir/.applications/$appdir
	done
	find $homedir -type d -exec chsmack -a User {} \;
	chown -R $user:users $homedir
	return 0
}

# fix TC-320 for SDK
. /etc/tizen-build.conf
[ "${TZ_BUILD_WITH_EMULATOR}" == "1" ] && generic_base_fix_user_homedir developer

# Add info.ini for system-info CAPI (TC-2047)
/etc/make_info_file.sh

#!/bin/sh
echo "#################### generic-users.post ####################"

if ! generic_base_user_exists owner; then
        # By default GUM will create users in /opt/etc/passwd, which is
        # additional users database suitable for end-user created accounts.
        # However, the 'owner' user is shipped by Tizen system itself and
        # it's its default user.  Consequently, it should always be available
        # and thus, it should be added to /etc/passwd.
        conf=/etc/gumd/gumd.conf
        origf=${conf}.orig
        mv -v $conf $origf
        sed -e 's,^\(PASSWD_FILE\).*,\1=/etc/passwd,' -e 's,^\(SHADOW_FILE\).*,\1=/etc/shadow,' <$origf >$conf
        gum-utils --offline --add-user --username=owner --usertype=admin --usecret=""
        mv -v $origf $conf
fi



#!/bin/sh
echo "#################### generic-console-tools.post ####################"

# customize bash prompt
cat >/etc/profile.d/bash_prompt_custom.sh <<'EOF'
if [ "$PS1" ]; then

	function proml {
		# set a fancy prompt (overwrite the one in /etc/profile)
		local default="\[\e[0m\]"
		local usercol='\[\e[1;34m\]' # blue
		local hostcol='\[\e[1;32m\]' # green
		local pathcol='\[\e[1;33m\]' # yellow
		local gitcol='\[\e[1;31m\]' # light red
		local termcmd=''
		local _p="$";

		if [ "`id -u`" -eq 0 ]; then
			usercol='\[\e[1;31m\]'
			_p="#"
		fi

		PS1="${usercol}\u${default}@${hostcol}\h${default}:${pathcol}\w${default}${gitcol}${default}${_p} ${termcmd}"
	}

	proml

	function rcd () {
      [ "${1:0:1}" == "/" ] && { cd $1; } || { cd $(pwd -P)/$1; }
   }

	alias ll="ls -lZ"
	alias lr="ls -ltrZ"
	alias la="ls -alZ"

	function get_manifest () {
		rpm -qa --queryformat="%{name} %{Version} %{Release} %{VCS}\n" | sort
	}
fi
EOF


#!/bin/sh
echo "############### wearable-packaging.post ################"

# generate repo files for zypper
function genrepo() {
	local url=$1
	local reponame=$2
	local filename=${3:-$2}
	local enabled=${4:-0}

	local prefix=${TZ_BUILD_VENDOR}-${TZ_BUILD_PROFILE}-${TZ_BUILD_REPO}

	# remove double slashes if any
	url=$(sed -e  's|/\+|/|g' -e 's|:/|://|' <<<$url)

	cat >> /etc/zypp/repos.d/$prefix-${filename}.repo << EOF
[$prefix-${reponame}]
name=$prefix-${reponame}
enabled=$enabled
autorefresh=0
baseurl=${url}?ssl_verify=no
type=rpm-md
gpgcheck=0
 
EOF
}

# source /etc/tizen-build.conf to get more infos about project, repos etc.
. /etc/tizen-build.conf 

# adjust build_id if this scripts executes before the replacement in /etc/tizen-build.conf
TZ_BUILD_ID=$(echo $TZ_BUILD_ID | sed 's|@BUILD_ID[@]|@BUILD_ID@|')

# snapshot repo
genrepo ${TZ_BUILD_SNAPSHOT_URL}/${TZ_BUILD_ID}/repos/${TZ_BUILD_REPO}/packages snapshot snapshot 1
genrepo ${TZ_BUILD_SNAPSHOT_URL}/${TZ_BUILD_ID}/repos/${TZ_BUILD_REPO}/debug snapshot-debug snapshot 1

# latest repo
genrepo ${TZ_BUILD_SNAPSHOT_URL}/latest/repos/${TZ_BUILD_REPO}/packages update update 0
genrepo ${TZ_BUILD_SNAPSHOT_URL}/latest/repos/${TZ_BUILD_REPO}/debug update-debug update 0

# daily repo
genrepo ${TZ_BUILD_DAILY_URL}/latest/repos/${TZ_BUILD_REPO}/packages daily daily 0
genrepo ${TZ_BUILD_DAILY_URL}/latest/repos/${TZ_BUILD_REPO}/debug daily-debug daily 0

# weekly repo
genrepo ${TZ_BUILD_WEEKLY_URL}/latest/repos/${TZ_BUILD_REPO}/packages weekly weekly 0
genrepo ${TZ_BUILD_WEEKLY_URL}/latest/repos/${TZ_BUILD_REPO}/debug weekly-debug weekly 0

# remove libzypp history
rm -rf /var/log/zypp

#!/bin/sh
echo "############### wearable-adaptation.post ################"


#!/bin/sh
echo "############### wearable-middleware.post ################"


#!/bin/sh
echo "#################### generic-bluetooth.post ####################"


#!/bin/sh
echo "#################### generic-multimedia.post ####################"


#!/bin/sh
echo "#################### generic-desktop-applications.post ####################"

# depends on generic-base functions
function generic_desktop_applications_fix_userhome() {
	user=$1

	generic_base_user_exists $user || return 1
	homedir=$(generic_base_user_home $user)

	echo "Fix app_info.db of $user"
	chown -R $user:users $homedir/.applications/dbspace/
}

# fix TC-320 for SDK
. /etc/tizen-build.conf
# Disable to run below line because this results in always failure, so it can be regarded as useless.
#[ "${TZ_BUILD_WITH_EMULATOR}" == "1" ] && generic_desktop_applications_fix_userhome developer


#!/bin/sh
echo "############### wearable-desktop-applications.post ################"

# call function defined in meta-generic
for user in alice bob carol guest developer; do
	generic_desktop_applications_fix_userhome $user
done



#!/bin/sh
echo "#################### generic-crosswalk.post ####################"


#!/bin/sh
echo "############### wearable-crosswalk.post ################"


#!/bin/sh
echo "############### wearable-license.post ################"

LICENSE_DIR=/usr/share/licenses
LICENSE_FILE=/usr/share/license.html
MD5_TEMP_FILE=/usr/share/temp_license_md5

if [[ -f $LICENSE_FILE ]]; then
	rm -f $LICENSE_FILE
fi

if [[ -f $MD5_TEMP_FILE ]]; then
	rm -f $MD5_TEMP_FILE
fi


cd $LICENSE_DIR
LICENSE_LIST=`ls */*`

for INPUT in $LICENSE_LIST; do
	if [[ -f $INPUT ]]; then
		PKG_NAME=`echo $INPUT|cut -d'/' -f1`
		echo `md5sum $INPUT` $PKG_NAME >> $MD5_TEMP_FILE
	fi
done

MD5_LIST=`cat $MD5_TEMP_FILE|awk '{print $1}'|sort -u`

echo "<html>" >> $LICENSE_FILE
echo "<head>" >> $LICENSE_FILE
echo "<meta name=\"viewport\" content=\"initial-scale=1.0\">" >> $LICENSE_FILE
echo "</head>" >> $LICENSE_FILE
echo "<body>" >> $LICENSE_FILE
echo "<xmp>" >> $LICENSE_FILE

for INPUT in $MD5_LIST; do
	PKG_LIST=`cat $MD5_TEMP_FILE|grep $INPUT|awk '{print $3}'`
	FILE_LIST=`cat $MD5_TEMP_FILE|grep $INPUT|awk '{print $2}'`
	PKG_FILE=`echo $FILE_LIST |awk '{print $1}'`

	echo "$PKG_LIST :" >> $LICENSE_FILE
	cat $PKG_FILE >> $LICENSE_FILE
	echo  >> $LICENSE_FILE
	echo  >> $LICENSE_FILE
	echo  >> $LICENSE_FILE
done

echo "</xmp>" >> $LICENSE_FILE
echo "</body>" >> $LICENSE_FILE
echo "</html>" >> $LICENSE_FILE

rm -rf $LICENSE_DIR/* $MD5_TEMP_FILE

#!/bin/sh
echo "#################### generic-security.post ####################"

if [ -e /usr/share/security-config/set_capability ]; then
	echo 'Give capabilities to daemons via set_capability from security-config package'
	/usr/share/security-config/set_capability
fi
if [ -e /opt/share/security-config/test/image_test.sh ]; then
	echo 'Run security-test'
	/opt/share/security-config/test/image_test.sh
fi

# 04-15-2019 : This is to create security-manager DB backup file.
security-manager-cmd -b
 

#!/bin/sh
echo "#################### generic-dbus-policychecker.post ####################"
if [ -x /usr/bin/dbuspolicy-checker ] ; then
	fail_cnt=0
	for f in /etc/dbus-1/system.d/*.conf /usr/share/dbus-1/system.d/*.conf; do
		echo
		echo "$0: Checking D-Bus policy file: $f"
		result=$(/usr/bin/dbuspolicy-checker "$f")
		fail=$(echo "$result" | grep FAILED | wc -l)
		echo "$result"
		if [ $fail -gt 0 ]; then
			echo "Found $fail Fails"
			echo "Remove conf file : mv $f $f.fail"
			mv "$f" "${f}.fail"
			fail_cnt=$(( ${fail_cnt} + 1 ))
		fi
	done
	if [ $fail_cnt -gt 0 ]; then
		echo "Error: MIC build exits due to failed cases on dbus policy checker.(${fail_cnt} errors)"
		exit 1
	fi

fi

#!/bin/sh
echo "############### wearable-dotnet-generate-ni.post ################"

DLL_LIST="
        /usr/share/dotnet.tizen/netcoreapp/System.Private.CoreLib.dll
        /usr/share/dotnet.tizen/netcoreapp/SOS.NETCore.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Collections.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Collections.Concurrent.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Console.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Diagnostics.Debug.dll
        /usr/share/dotnet.tizen/netcoreapp/System.IO.FileSystem.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Linq.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Linq.Expressions.dll
        /usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Private.DataContractSerialization.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Private.Uri.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Private.Xml.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Reflection.Extensions.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Reflection.Metadata.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Runtime.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Runtime.Extensions.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Runtime.InteropServices.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Algorithms.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Primitives.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Text.RegularExpressions.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Threading.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Threading.Tasks.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Threading.Thread.dll
        /usr/share/dotnet.tizen/netcoreapp/System.Threading.Timer.dll
        /usr/share/dotnet.tizen/framework/ElmSharp.dll
        /usr/share/dotnet.tizen/framework/XSF.dll
        /usr/share/dotnet.tizen/framework/Tizen.dll
        /usr/share/dotnet.tizen/framework/Tizen.Applications.Common.dll
        /usr/share/dotnet.tizen/framework/Tizen.Applications.UI.dll
        /usr/share/dotnet.tizen/framework/Tizen.Applications.Service.dll
        /usr/share/dotnet.tizen/framework/Tizen.System.Information.dll
"

# remove previous native image
dotnettool --ni-reset-system

# set the patchelf
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
export MIC_CROSSGEN2_ENABLED=1

DOTNET_MIC_DIR=/opt/usr/dotnet/mic

chmod 755 /usr/bin/patchelf
chmod 755 $DOTNET_MIC_DIR/*

/usr/bin/patchelf --set-interpreter $DOTNET_MIC_DIR/ld-linux-x86-64.so.2 $DOTNET_MIC_DIR/crossgen2
/usr/bin/patchelf --set-rpath $DOTNET_MIC_DIR $DOTNET_MIC_DIR/crossgen2

for file in $( find $DOTNET_MIC_DIR -type f \( -name "*.so" -or -name "*.so.*" \) -not -name "*.dbg" -not -name "ld-*.so*" )
do
    /usr/bin/patchelf --set-rpath $DOTNET_MIC_DIR ${file}
done

# generate native image
for target in $DLL_LIST;
do
    dotnettool --ni-dll $target --inputbubble;
done;

# generate native image for all app
dotnettool --ni-regen-all-app
dotnettool --tac-regen-all

# remove files and package related to dotnet used only in MIC
rm -rf $DOTNET_MIC_DIR
rpm -e patchelf
rpm -e crossgen2-mic


%end

%post --nochroot
# buildname.nochroot 
if [ -n "$IMG_NAME" ]; then
    echo "BUILD_ID=$IMG_NAME" >> $INSTALL_ROOT/etc/tizen-release
    echo "BUILD_ID=$IMG_NAME" >> $INSTALL_ROOT/etc/os-release
fi


%end




