# -*-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
part /opt/ --size=2000 --ondisk=sda --fstype=ext4 --label=emulator-sysdata


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/4.0-unified/@BUILD_ID@/repos/emulator/packages/ --ssl_verify=no
repo --name=base_ia32 --baseurl=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/ia32/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
rfkill
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-profile_wearable
deviced-tools
dlogutil
fsck-msdos
libaccount-service
libstorage
lzo
newfs-msdos
tizen-locale
tizen-release-profile_wearable
tlm-config-common-singleseat
# @ Wearable Console Tools
curl
findutils
grep
gzip
iptables
tar
unzip
xz
zip
# @ Wearable Packaging
# @ Wearable Adaptation
# @ Wearable Wayland
xkeyboard-config
# @ Wearable Middleware
SDL2
account-common
amd
amd-mod-boost
amd-mod-cooldown
amd-mod-cynara-core
amd-mod-extractor
amd-mod-input
amd-mod-rua
amd-mod-share
amd-mod-splash-screen
amd-mod-ui-core
amd-mod-wayland-core
amd-mod-widget
app2sd
appcore-agent
appcore-widget
argos_watchdog
askuser-notification
askuser-notification-client
auth-fw
boost-date-time
boost-regex
buxton2
cairo
calendar-service
capi-appfw-alarm
capi-appfw-app-common
capi-appfw-app-control
capi-appfw-event
capi-appfw-job-scheduler
capi-appfw-preference
capi-context
capi-maps-service
capi-messaging-email
capi-messaging-messages
capi-network-stc
capi-privacy-privilege-manager
capi-system-media-key
capi-system-runtime-info
capi-system-sensor-profile_wearable
capi-web-url-download
cert-svc
contacts-service
context-app-history-profile_wearable
context-job-scheduler
context-sensor-recorder-profile_wearable
context-service
crash-worker
csr-framework
cynara
dali-adaptor-cxx03
dali-adaptor-profile_wearable-cxx03
dali-cxx03
dali-toolkit-cxx03
data-control
device-policy-manager
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
email-service
esd
eventsystem
feedbackd
feedbackd-profile_wearable
fido-asm
fido-client
fido_bt_roaming_agent
fido_silent
gmime
gumd-profile_wearable
heremaps-uc-launcher
iotcon
key-manager
key-manager-pam-plugin
klay
launchpad
launchpad-loader
lbs-server
lbs-server-plugin-replay
libaskuser-notification-common
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
libeom
libhyphen
libkey-manager-client
libkey-manager-common
libnss-security-manager
liboauth
libode
libphonenumber
libprotobuf-lite9
libscl-core-profile_wearable
libspeex
libuw-imap-toolkit
libwebappenc
location-lbs-server
memps
minicontrol
mms-plugin
msg-manager
murphy
nether
nghttp2
oauth2
ode
ode-dummy-ksp
org.tizen.ode
org.tizen.secure-erase
org.tizen.setting-location-wearable
org.tizen.vc-engine-default
pass
phonenumber-utils
pims-ipc
pkgmgr-server
pkgmgr-tool
privilege-checker
privilege-info
pubkey-pinning
resourced
rpc-port
sdbd
security-config
security-config-profile_wearable
security-license-manager
security-privilege-manager
security-privilege-manager-extension-wearable
sensord-profile_wearable
session-utils
sms-plugin
stc-manager
storaged
storaged-module_block
storaged-module_storage
stt
svi-data-profile_wearable
sync-service
system-rw-update
system-servant
system-servant-extension-circle-profile_wearable
tef-libteec
tizen-debug
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
webapi-plugins-teec
xdelta3
yaca
# @ Wearable Applications
app-core-ui
app-installers
boot-animation
ca-certificates
data-provider-master
libpush
libwidget_service
libwidget_viewer
libwidget_viewer_dali
libwidget_viewer_evas
my-account-profile_wearable
org.tizen.accessibility-setting
org.tizen.app-selector-profile_wearable
org.tizen.apptray-widget
org.tizen.bluetooth
org.tizen.bt-syspopup
org.tizen.callmgr-popup
org.tizen.classic-watch
org.tizen.crash-syspopup
org.tizen.dpm-syspopup
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.powerkey-syspopup.wearable
org.tizen.privacy-setting-profile_wearable
org.tizen.screen-reader
org.tizen.stt-engine-default
org.tizen.system-syspopup.wearable
org.tizen.telephony-syspopup
org.tizen.tts-engine-default
org.tizen.w-call-ui
org.tizen.w-clock-viewer
org.tizen.w-contacts
org.tizen.w-gallery
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
wgt-backend
# @ Wearable TPK Applications
org.tizen.alarm
org.tizen.sketch
org.tizen.w-call-setting
org.tizen.w-stopwatch
org.tizen.w-task-mgr
org.tizen.w-timer
org.tizen.windicator
# @ Wearable Bluetooth
bluetooth-agent
bluetooth-agent-profile_wearable
bluetooth-frwk-core
bluetooth-frwk-plugin-headed
bluetooth-frwk-profile_wearable
bluetooth-frwk-service
bluetooth-tools-profile_wearable
bluez
bluez-profile_wearable
obexd
org.tizen.bt-syspopup-profile_wearable
# @ Generic Multimedia
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
capi-media-camera
capi-media-codec
capi-media-metadata-editor
capi-media-player
capi-media-player-display
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-mediademuxer
capi-mediamuxer
dcm-service
freealut
gst-libav
gst-plugins-tizen
gst-plugins-ugly
libbmp
libmm-camcorder
libmm-common
libmm-evas-renderer
libmm-fileinfo
libmm-imgp-gstcs
libmm-player
libmm-radio
libmm-session
libmm-sound
libmm-streamrecorder
libnsbmp
media-thumbnail-server
mediacontroller
mmfw-sysconf-simulator
mmsvc-camera
mmsvc-player
mmsvc-recorder
murphy-glib
mused
openal-soft
opencv
pulseaudio-modules-tizen
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-video-player-plugin
dali-toolkit
dali-toolkit-resources_360x360
# @ Wearable EFL
at-spi2-core
capi-ui-efl-util
default-fonts-fc-sdk
default-fonts-sdk
ecore-buffer
efl-config
efl-misc-profile_wearable
efl-modules-profile_wearable
efl-theme-tizen-wearable
elementary-locale
elementary-tizen
elementary-tools
libatk
libatk-bridge-2_0-0
libatspi0
typelib-1_0-Atspi-2_0
# @ Wearable Enlightenment
e-mod-tizen-devicemgr
e-mod-tizen-eom
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
capi-ui-inputmethod
capi-ui-inputmethod-manager
ise-default
ise-default-profile_wearable
ise-engine-default
isf
isf-config-wearable
libhangul
libscl-ui
org.tizen.inputmethod-setting
smartreply
smartreply-service
# @ Wearable Connectivity Framework
asp-manager
capi-network-asp
capi-network-http
capi-network-nfc
capi-network-smartcard
capi-network-softap
capi-network-wifi-manager
libdns_sd
libnsd-dns-sd
libnsd-ssdp
libtfeature
mdnsresponder
mobileap-agent
mobileap-agent-extension-headed
net-config-plugin-headed
# @ Wearable Connectivity Framework Emulator
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
crosswalk-tizen
libre2
libwebsockets
web-widget-engine
web-widget-js
web-widget-runtime
webapi-plugins
webapi-plugins-profile_wearable
# @ 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
# @ Wearable dotNet Runtime
coreclr
coreclr-extra
corefx-managed
corefx-native
mscorlib
# @ Wearable Adaptation Emulator Circle
audio-hal-emul
boot-animation-extension_emulator
coregl
device-manager-plugin-emul
dlogbackend-logger
emulator-yagl
emuld
gssdp
gst-plugins-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
org.tizen.w-home-extension-circle
sdbd-extension-emulator
sensor-hal-emulator
swap-manager
swap-modules
swap-probe
swap-probe-elf
system-plugin
system-plugin-emulator
tel-plugin-atmodem
tel-plugin-vmodem
vmodemd-emul
webapi-plugins-wearable-extension-emulator
# Others




%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 "############### wearable-base.post ################"

######### multiuser mode: create additional users and fix their homedirs

if ! generic_base_user_exists owner; then
        gum-utils --offline --add-user --username=owner --usertype=admin --usecret=tizen
fi

#for user in owner alice bob carol guest; do
#	if ! generic_base_user_exists $user; then
#		gum-utils --offline --add-user --username="$user" --usertype=normal --usecret=tizen
#	fi
#done


#!/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


#!/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 


%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

%runscript

%end

