<?xml version="1.0" encoding="UTF-8"?>
<libosinfo version="0.0.1">
  <install-script id='http://debian.org/debian/preseed/jeos'>
    <profile>jeos</profile>
    <expected-filename>preseed.cfg</expected-filename>
    <can-pre-install-drivers>true</can-pre-install-drivers>
    <config>
      <param policy="required" name="admin-password"/>
      <param value-map="http://x.org/x11-keyboard" policy="optional" name="l10n-keyboard"/>
      <param policy="optional" name="l10n-timezone"/>
      <param policy="optional" name="l10n-language"/>
      <param policy="optional" name="target-disk"/>
    </config>
    <injection-method>initrd</injection-method>
    
    <needs-internet>true</needs-internet>
    <template>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

        <xsl:output method="text"/>

        <xsl:template name="target-disk">
          <xsl:choose>
            <xsl:when test="config/target-disk != ''">
              <xsl:value-of select="config/target-disk"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>/dev/vda</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>

        <xsl:template name="l10n-language">
          <xsl:choose>
            <xsl:when test="config/l10n-language != '' and config/l10n-language != 'C'">
              <xsl:value-of select="config/l10n-language"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>en_US</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>

        <xsl:template name="l10n-keyboard">
          <xsl:choose>
            <xsl:when test="config/l10n-keyboard != '' and config/l10n-keyboard != 'C'">
              <xsl:value-of select="config/l10n-keyboard"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>us</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>

        <xsl:template match="/command-line">
            <xsl:text> keyboard-configuration/xkb-keymap=</xsl:text>
            <xsl:call-template name="l10n-keyboard"/>
            <xsl:text> debconf/priority=critical</xsl:text>
        </xsl:template>

<xsl:template match="/install-script-config">
d-i debian-installer/locale select <xsl:call-template name="l10n-language"/>
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string <xsl:call-template name="l10n-keyboard"/>

d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string localhost
d-i netcfg/get_domain string localdomain
d-i netcfg/disable_dhcp     boolean false
d-i mirror/http/proxy string
d-i netcfg/wireless_wep string

d-i clock-setup/utc boolean true
d-i time/zone select <xsl:value-of select="config/l10n-timezone"/>

d-i partman-auto/disk string <xsl:call-template name="target-disk"/>
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select home

d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i passwd/root-password password <xsl:value-of select="config/admin-password"/>
d-i passwd/root-password-again password <xsl:value-of select="config/admin-password"/>

tasksel tasksel/first multiselect standard ssh-server

# Workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666974
d-i grub-installer/only_debian boolean false
d-i grub-installer/bootdev string <xsl:call-template name="target-disk"/>

d-i apt-setup/use_mirror boolean true
d-i apt-setup/security_host string
d-i apt-setup/services-select multiselect
d-i apt-setup/volatile_host string
d-i apt-setup/security_host string

d-i finish-install/reboot_in_progress note

### Remove the installation DVD from the apt-get's sources.list
d-i preseed/late_command string in-target sed -i '/cdrom/d' /etc/apt/sources.list

</xsl:template>
      </xsl:stylesheet>
    </template>
  </install-script>
</libosinfo>