# -*-mic2-options-*- -A aarch64 -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 America/Los_Angeles
part / --fstype="ext4" --size=3500 --ondisk=mmcblk0 --label rootfs --fsoptions=defaults,noatime
part /opt --fstype="ext4" --size=512 --ondisk=mmcblk0 --label system-data --fsoptions=defaults,noatime
part /opt/usr --fstype="ext4" --size=3500 --ondisk=mmcblk0 --label user --fsoptions=defaults,noatime


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

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


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

%packages

# @ Generic Adaptation
linux-firmware
system-plugin
# @ Common Adaptation
# @ 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
# @ Common Base
argos_watchdog
boost-date-time
boost-program-options
boost-regex
capi-base-utils
cryptsetup
device-mapper
deviced-profile_common
dlogutil
fsck-msdos
newfs-msdos
pass
session-utils
storaged
storaged-module_block
storaged-module_storage
svi-data-profile_common
system-rw-update
system-servant
system-servant-profile_common
tizen-debug
tizen-locale
tizen-release-profile_common
tlm-config-common-singleseat
# @ Generic Console Tools
curl
findutils
grep
gzip
iptables
tar
unzip
xz
zip
# @ Common Console Tools
strace
usbutils
# @ Generic Wayland
xkeyboard-config
# @ Common Wayland
libtdm-client
libwayland-tbm-client
libwayland-tbm-server
xkb-tizen-data
# @ Generic Middleware
amd
app-installers
appcore-agent
buxton2
cairo
calendar-service
capi-maps-service
cert-svc
contacts-service
crash-worker
csr-framework
cynara
data-control
drm-service-core-tizen
eventsystem
key-manager
key-manager-pam-plugin
launchpad
libcontacts-service
libcynara-creds-commons
libcynara-creds-dbus
libcynara-creds-gdbus
libcynara-creds-socket
libkey-manager-client
libkey-manager-common
murphy
nghttp2
org.tizen.tts-engine-default
org.tizen.vc-engine-default
pkgmgr-server
pkgmgr-tool
privilege-checker
privilege-info
pubkey-pinning
resourced
sdbd
security-privilege-manager
sqlite3
stt
toybox
toybox-symlinks-dhcp
toybox-symlinks-dhcpd
tpk-backend
ttrace
vconf-internal-keys
voice-control
voice-control-elm
wgt-backend
xdelta3
# @ Common Middleware
SDL2
amd-mod-watchdog
app-core-ui
app2sd
capi-appfw-alarm
capi-appfw-app-common
capi-appfw-app-control
capi-appfw-event
capi-appfw-job-scheduler
capi-appfw-preference
capi-media-player-display
capi-media-player-utils
capi-system-media-key
capi-system-sensor
esd
fido-asm
fido_bt_roaming_agent
fido_silent
klay
launchpad-loader
libcalendar-service
libspeex
message-port
rpc-port
sensord-profile_common
tef-libteec
vconf-internal-keys-config-profile_common
webapi-plugins-teec
# @ Generic Applications
ca-certificates
# @ Common Applications
boot-animation
data-provider-master
org.tizen.menu-screen
org.tizen.screen-reader
org.tizen.setting-profile_common
org.tizen.telephony-syspopup
org.tizen.worldclock-efl
starter
starter-profile_common
# @ Generic Bluetooth
bluetooth-frwk-core
bluetooth-frwk-service
bluetooth-share
bluez
obexd
# @ 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
# @ Generic Desktop Applications
emotion
# @ Common Desktop Applications
elementary-tools
# @ Generic Crosswalk
crosswalk-tizen
# @ Common Crosswalk
wgt-backend
# @ Common EFL
default-fonts-fc-sdk
default-fonts-sdk
ecore-buffer
efl-config
efl-misc-profile_common
efl-modules-profile_common
efl-theme-tizen-common
elementary-locale
elementary-tizen
# @ Common Enlightenment
e-mod-tizen-devicemgr
e-mod-tizen-eom
e-mod-tizen-keyrouter
e-mod-tizen-processmgr
e-mod-tizen-wl-textinput
e-mod-tizen-wm-policy
e-tizen-data-profile_common
# @ Common Web Framework
libwebsockets
webapi-plugins-profile_common
# @ Common Input Framework
anthy
capi-ui-inputmethod
download-fonts-service
ise-default
ise-default-profile_common
ise-engine-anthy
ise-engine-default
ise-engine-hangul
ise-engine-sunpinyin
ise-engine-tables
isf
isf-config-common
libhangul
libscl-common
libscl-core-profile_common
libscl-ui
org.tizen.inputmethod-setting
org.tizen.inputmethod-setting-profile_common
org.tizen.stt-engine-default
tts-engine-rsc
tzsh
vc-webview
vc-webview-js
# @ Common Telephony
call-manager
capi-telephony
libcall-manager
libtcore
libtfeature
tel-plugin-manager
tel-plugin-syspopup
# @ Common Dali
dali-adaptor
dali-adaptor-cxx03
dali-adaptor-profile_common
dali-adaptor-profile_common-cxx03
dali-csharp-binder
dali-cxx03
dali-extension
dali-extension-key-extension
dali-extension-video-player-plugin
dali-toolkit-cxx03
dali-toolkit-resources_720x1280
# @ Common Bluetooth
bluetooth-frwk-plugin-headed
bluetooth-frwk-profile_common
bluetooth-tools-profile_common
bluez-profile_common
org.tizen.bt-syspopup-profile_common
# @ Common Connectivity Framework
bind
capi-network-stc
capi-network-wifi-manager
capi-network-zigbee
gssdp
libnsd-dns-sd
libnsd-ssdp
mdnsresponder
stc-manager
tayga
wifi-direct-manager
wifi-direct-manager-profile_common
wifi-direct-plugin-wpasupplicant
zigbee-lib
zigbee-manager
# @ Common Security
askuser-notification
askuser-notification-client
auth-fw
capi-privacy-privilege-manager
csr-framework
device-policy-manager
dpm-application
dpm-bluetooth
dpm-browser
dpm-media
dpm-security
dpm-storage
dpm-usb
dpm-wifi
krate
libaskuser-notification-common
libauth-fw-client
libauth-fw-client-admin
libcsr-framework-client
libcynara-creds-self
libcynara-monitor
libdpm
libkrate
libnss-security-manager
libode
nether
ode
ode-dummy-ksp
org.tizen.dpm-syspopup
org.tizen.ode
org.tizen.secure-erase
security-license-manager
security-manager
yaca
# @ Common Adaptation Aarch64
bluetooth-tools-no-firmware
boot-animation-sound-file-profile_common
coregl
gst-omx
libtbm-dumb
libtdm-drm
model-config-generic
# Others



system-plugin-init_wrapper

%end



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

# fix TIVI-2291
sed -ri "s/(^blacklist i8042.*$)/#fix from base-general.post \1/" /etc/modprobe.d/blacklist.conf


#!/bin/sh
echo "############### common-adaptation.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 "############### common-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 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

######### add 'guest' user that runs bt-service daemon to vconf_bt group
function mygetid() { sed '/^'"$1"':/!d;s/^\([^:]*:\)\{2\}\([^:]*\):.*$/\2/' "$2"; }
function mygetuid() { mygetid "$1" /etc/passwd; }
function mygetgid() { mygetid "$1" /etc/group; }

gum-utils --offline --add-member --gid=$(mygetgid vconf_bt) --mem_uid=$(mygetuid guest)


#!/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 "#################### generic-wayland.post ####################"


#!/bin/sh
echo "#################### common-wayland.post ##################"

# add users to display group
for user in alice bob carol guest developer owner; do
	if generic_base_user_exists $user; then
		/usr/sbin/usermod -G display $user
	fi
done

#{ Add installed apps for tizen to launcher if not present
dst="/usr/share/applications/tizen/launcher.conf"

if [ -w "$dst" ] ; then
   ls /usr/share/applications/tizen/*.desktop \
   | while read src; do
        grep "$src" "$dst" \
            || { [ ! -r "$src" ] || echo "$src" >> "$dst" ; }

    done
fi

#}

# tag the background image with the current snapshot id
/usr/bin/mark_image.py /opt/share/settings/Wallpapers/home_001.png "Tizen Common: @BUILD_ID@" ffff70 10 60 95 70


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


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


#!/bin/sh
echo "#################### generic-applications.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 "############### common-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 "############### common-crosswalk.post ################"

# start wrt widgets preinstall
rpm -qa | grep wrt-widget
if [ $? = 0 ]
then
prepare_widgets.sh
fi


#!/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
	echo "$IMG_NAME @BUILD_ID@" >>$INSTALL_ROOT/etc/tizen-snapshot
fi


%end

%runscript

%end

