Permalink
Browse files

Merge branch 'master' of github.com:pcbsd/pcbsd

  • Loading branch information...
2 parents c69425e + 5a1d1a0 commit dca28eb07dd8199638c3a433e2794adc23978d92 @beanpole135 beanpole135 committed Oct 18, 2013
View
14 src-qt4/pc-firstbootgui/backend.cpp
@@ -96,6 +96,20 @@ QStringList Backend::timezones()
return _zones;
}
+QString Backend::guessTimezone()
+{
+ QString code;
+
+ Process p(QStringList() << "detect-country");
+
+ if (p.waitForFinished()) {
+ code = p.readLine().simplified();
+ }
+ code = code.section(" ", 1, 1);
+ qDebug() << "Found timezone:" << code;
+ return code;
+}
+
QStringList Backend::languages()
{
QStringList _languages;
View
5 src-qt4/pc-firstbootgui/backend.h
@@ -10,8 +10,8 @@
#include <QByteArray>
#include <QWidget>
-#define PCSYSINSTALL QString("/usr/sbin/pc-sysinstall")
-#define PCSYSINSTALLDIR QString("/usr/share/pc-sysinstall")
+#define PCSYSINSTALL QString("/usr/local/sbin/pc-sysinstall")
+#define PCSYSINSTALLDIR QString("/usr/local/share/pc-sysinstall")
#define PCSYSINSTALLCFG QString("/tmp/sys-install.cfg")
#define TMPLANGFILE QString("/tmp/.SysInstallLang")
@@ -50,6 +50,7 @@ class Backend {
static QStringList bootableMedia();
static QStringList networkDevices();
static QStringList timezones();
+ static QString guessTimezone();
static void changeKbMap(QString model, QString layout, QString variant);
static QList<QStringList> hardDrives();
static QList<QStringList> availComponents();
View
15 src-qt4/pc-firstbootgui/firstboot.cpp
@@ -48,11 +48,18 @@ Installer::Installer(QWidget *parent) : QMainWindow(parent)
// Load the timezones
comboBoxTimezone->clear();
+ QString curZone = Scripts::Backend::guessTimezone();
comboBoxTimezone->addItems(Scripts::Backend::timezones());
- // Set America/New_York to default
- int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
- if (index != -1)
- comboBoxTimezone->setCurrentIndex(index);
+ if ( ! curZone.isEmpty() ) {
+ int index = comboBoxTimezone->findText(curZone, Qt::MatchStartsWith);
+ if (index != -1)
+ comboBoxTimezone->setCurrentIndex(index);
+ } else {
+ // Set America/New_York to default
+ int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
+ if (index != -1)
+ comboBoxTimezone->setCurrentIndex(index);
+ }
// Load the hostname
lineHostname->setText(pcbsd::Utils::getConfFileValue("/etc/rc.conf", "hostname=", 1));
View
15 src-qt4/pc-installgui/backend.cpp
@@ -234,6 +234,21 @@ int Backend::systemMemory()
return -1;
}
+QString Backend::detectCountryCode()
+{
+ QString code;
+
+ Process p(QStringList() << "detect-country");
+
+ if (p.waitForFinished()) {
+ code = p.readLine().simplified();
+ }
+ code = code.section(" ", 0, 0);
+ qDebug() << "Found Country Code:" << code;
+ return code;
+}
+
+
QStringList Backend::networkDevices()
{
QStringList nics;
View
1 src-qt4/pc-installgui/backend.h
@@ -56,6 +56,7 @@ class Backend {
static QStringList bootableMedia();
static QStringList networkDevices();
static QStringList timezones();
+ static QString detectCountryCode();
static void changeKbMap(QString model, QString layout, QString variant);
static QList<QStringList> hardDrives();
static QList<QStringList> availComponents();
View
38 src-qt4/pc-installgui/installer.cpp
@@ -100,14 +100,30 @@ void Installer::slotPushKeyLayout()
void Installer::initInstall()
{
// load languages
+ QString langCode;
+ bool foundLang = false;
comboLanguage->clear();
languages = Scripts::Backend::languages();
+ QString curLang = Scripts::Backend::detectCountryCode();
for (int i=0; i < languages.count(); ++i) {
QString languageStr = languages.at(i);
QString language = languageStr.split("-").at(0);
comboLanguage->addItem(language.trimmed());
+
+ // Grab the language code
+ langCode = languageStr;
+ langCode.truncate(langCode.lastIndexOf(")"));
+ langCode.remove(0, langCode.lastIndexOf("(") + 1);
+ if ( curLang == langCode ) {
+ comboLanguage->setCurrentIndex(i);
+ foundLang = true;
+ }
}
connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage()));
+ // If we found a language from geo-loication, change UI now
+ if ( foundLang )
+ slotChangeLanguage();
+
// Load any package scheme data
listDeskPkgs = Scripts::Backend::getPackageData(availDesktopPackageData, QString());
@@ -775,20 +791,16 @@ void Installer::slotChangeLanguage()
QCoreApplication::installTranslator(translator);
this->retranslateUi(this);
}
-}
-
-void Installer::changeLang(QString code)
-{
- // Change the language in the combobox with the current running one
- comboLanguage->disconnect();
- for (int i=0; i < languages.count(); ++i) {
- if ( languages.at(i).indexOf("(" + code + ")" ) != -1 ) {
- comboLanguage->setCurrentIndex(i);
- }
- }
-
- connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage()));
+ // Change the default keyboard layout
+ if ( langCode == "en" ) {
+ Scripts::Backend::changeKbMap("pc104", "us", "");
+ } else {
+ // TODO - At some point, add additional tests here and set more specific layouts
+ // based upon the language selected
+ Scripts::Backend::changeKbMap("pc105", langCode, "" );
+ }
+
}
QStringList Installer::getGlobalCfgSettings()
View
1 src-qt4/pc-installgui/installer.h
@@ -34,7 +34,6 @@ class Installer : public QMainWindow, private Ui::Installer
public:
Installer(QWidget *parent = 0);
~Installer();
- void changeLang(QString code);
void initInstall();
private slots:
View
27 src-qt4/pc-installgui/wizardDisk.cpp
@@ -152,6 +152,11 @@ int wizardDisk::nextId() const
}
break;
case Page_BasicDisk:
+ if (checkSSD->isChecked())
+ pushSwapSize->setVisible(false);
+ else
+ pushSwapSize->setVisible(true);
+
if (radioBasic->isChecked())
return Page_Confirmation;
if (comboPartition->currentIndex() != 0 ) {
@@ -413,15 +418,21 @@ void wizardDisk::generateDiskLayout()
{
fsType= "ZFS";
+ QString rootOpts="";
+ if ( checkSSD->isChecked() )
+ rootOpts="(atime=off)";
+
// This lets the user do nifty stuff like a mirror/raid post-install with a single zpool command
- fileSystem << targetDisk << targetSlice << "/,/tmp(compress=lz4),/usr(canmount=off),/usr/home,/usr/jails,/usr/obj(compress=lz4),/usr/pbi,/usr/ports(compress=lz4),/usr/ports/distfiles(compress=lz4),/usr/src(compress=lz4),/var(canmount=off),/var/audit(compress=lz4),/var/log(compress=lz4),/var/tmp(compress=lz4)" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
+ fileSystem << targetDisk << targetSlice << "/" + rootOpts + ",/tmp(compress=lz4),/usr(canmount=off),/usr/home,/usr/jails,/usr/obj(compress=lz4),/usr/pbi,/usr/ports(compress=lz4),/usr/ports/distfiles(compress=lz4),/usr/src(compress=lz4),/var(canmount=off),/var/audit(compress=lz4),/var/log(compress=lz4),/var/tmp(compress=lz4)" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
sysFinalDiskLayout << fileSystem;
fileSystem.clear();
- // Now add swap space
- fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
- sysFinalDiskLayout << fileSystem;
- fileSystem.clear();
+ // Now add swap space if NOT on a SSD
+ if ( ! checkSSD->isChecked() ) {
+ fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
+ sysFinalDiskLayout << fileSystem;
+ fileSystem.clear();
+ }
//qDebug() << "Auto-Gen FS:" << fileSystem;
}
@@ -899,8 +910,10 @@ void wizardDisk::generateCustomDiskLayout()
sysFinalDiskLayout << fileSystem;
fileSystem.clear();
- fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
- sysFinalDiskLayout << fileSystem;
+ if ( ! checkSSD->isChecked() ) {
+ fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
+ sysFinalDiskLayout << fileSystem;
+ }
qDebug() <<"AutoLayout:" << sysFinalDiskLayout;
}
View
253 src-qt4/pc-installgui/wizardDisk.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>641</width>
- <height>386</height>
+ <height>407</height>
</rect>
</property>
<property name="windowTitle">
@@ -190,88 +190,78 @@
</widget>
<widget class="QWizardPage" name="Page_BasicDisk">
<layout class="QGridLayout" name="gridLayout_11">
- <item row="3" column="1">
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QComboBox" name="comboDisk">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="label_5">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Selected Disk</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QComboBox" name="comboPartition">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_6">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Selected Partition</string>
- </property>
- </widget>
- </item>
- </layout>
+ <item row="9" column="1">
+ <widget class="QGroupBox" name="groupZFSPool">
+ <property name="font">
+ <font>
+ <weight>50</weight>
+ <bold>false</bold>
+ </font>
+ </property>
+ <property name="title">
+ <string>ZFS pool name</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QLineEdit" name="lineZpoolName">
+ <property name="inputMask">
+ <string/>
+ </property>
+ <property name="maxLength">
+ <number>32767</number>
+ </property>
+ <property name="placeholderText">
+ <string notr="true">tank</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
- <item row="10" column="1">
- <spacer name="verticalSpacer_6">
+ <item row="2" column="1">
+ <spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
<property name="sizeHint" stdset="0">
<size>
<width>387</width>
- <height>43</height>
+ <height>18</height>
</size>
</property>
</spacer>
</item>
- <item row="6" column="1">
- <widget class="QCheckBox" name="checkForce4K">
- <property name="text">
- <string>Force ZFS 4K block size</string>
+ <item row="1" column="2" rowspan="11">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_4">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>17</width>
+ <height>256</height>
+ </size>
</property>
+ </spacer>
+ </item>
+ <item row="7" column="1">
+ <widget class="QCheckBox" name="checkGRUB">
<property name="text">
- <string>Please select the disk or partition you wish to install onto. Please note that you must select either an entire disk or a primary partition that is at least 20GB for a server install or 50GB for a desktop install. </string>
+ <string>Install GRUB (Required for Boot-Environment support)</string>
</property>
- <property name="wordWrap">
+ <property name="checked">
<bool>true</bool>
</property>
</widget>
@@ -305,7 +295,7 @@
</property>
</spacer>
</item>
- <item row="0" column="0" rowspan="11">
+ <item row="0" column="0" rowspan="12">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_3">
@@ -357,79 +347,96 @@
</property>
</widget>
</item>
- <item row="8" column="1">
- <widget class="QGroupBox" name="groupZFSPool">
- <property name="font">
- <font>
- <weight>50</weight>
- <bold>false</bold>
- </font>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="title">
- <string>ZFS pool name</string>
+ <property name="text">
+ <string>Please select the disk or partition you wish to install onto. Please note that you must select either an entire disk or a primary partition that is at least 20GB for a server install or 50GB for a desktop install. </string>
</property>
- <property name="checkable">
+ <property name="wordWrap">
<bool>true</bool>
</property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QLineEdit" name="lineZpoolName">
- <property name="inputMask">
- <string/>
- </property>
- <property name="maxLength">
- <number>32767</number>
- </property>
- <property name="placeholderText">
- <string notr="true">tank</string>
- </property>
- </widget>
- </item>
- </layout>
</widget>
</item>
- <item row="2" column="1">
- <spacer name="verticalSpacer_4">
+ <item row="11" column="1">
+ <spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
<property name="sizeHint" stdset="0">
<size>
<width>387</width>
- <height>18</height>
+ <height>43</height>
</size>
</property>
</spacer>
</item>
- <item row="1" column="2" rowspan="10">
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>17</width>
- <height>256</height>
- </size>
+ <item row="6" column="1">
+ <widget class="QCheckBox" name="checkForce4K">
+ <property name="text">
+ <string>Force ZFS 4K block size</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="7" column="1">
- <widget class="QCheckBox" name="checkGRUB">
+ <item row="3" column="1">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QComboBox" name="comboDisk">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Selected Disk</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="comboPartition">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Selected Partition</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="8" column="1">
+ <widget class="QCheckBox" name="checkSSD">
<property name="text">
- <string>Install GRUB (Required for Boot-Environment support)</string>
- </property>
- <property name="checked">
- <bool>true</bool>
+ <string>Installing to SSD (Disables SWAP / atime)</string>
</property>
</widget>
</item>
View
38 src-sh/pc-sysinstall/backend-query/detect-country.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (c) 2013 iXsystems, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+# We use geo-location to detect the country of this machine, and can set the default language this way
+fetch -o "/tmp/.dR.$$" "http://web.pcbsd.org/getlocale.php" >/dev/null 2>/dev/null
+COUNTRY="`grep CountryCode: /tmp/.dR.$$ | awk '{print $2}' | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
+TZ="`grep TimeZone: /tmp/.dR.$$ | awk '{print $2}'`"
+rm /tmp/.dR.$$
+if [ -z "$COUNTRY" ] ; then
+ echo "UNKNOWN"
+ exit 1
+fi
+
+echo "$COUNTRY $TZ"
+exit 0
View
3 src-sh/pc-sysinstall/doc/help-index
@@ -20,6 +20,9 @@ System Query Commands
disk-info <disk>
Returns information about the disks size, cyls, heads, and sectors
+
+ detect-country
+ Returns the country-code based upon IP address of the system, or UNKNOWN
detect-laptop
Tests to see if this system is a laptop or desktop
View
5 src-sh/pc-sysinstall/pc-sysinstall
@@ -7,6 +7,7 @@
# to retrive information about the system
#####################################################################
# Copyright 2010 iXsystems
+# Copyright 2013 iXsystems
# All rights reserved
#
# Redistribution and use in source and binary forms, with or without
@@ -136,6 +137,10 @@ case $1 in
detect-laptop) ${QUERYDIR}/detect-laptop.sh
;;
+ # Get geo-location data for this system
+ detect-country) ${QUERYDIR}/detect-country.sh
+ ;;
+
# The user is wanting to see what nics are available on the system
detect-nics) ${QUERYDIR}/detect-nics.sh
;;
View
1 src-sh/port-files/pkg-plist
@@ -84,6 +84,7 @@ share/pc-sysinstall/backend-query/xkeyboard-variants.sh
share/pc-sysinstall/backend-query/setup-ssh-keys.sh
share/pc-sysinstall/backend-query/xkeyboard-layouts.sh
share/pc-sysinstall/backend-query/enable-net.sh
+share/pc-sysinstall/backend-query/detect-country.sh
share/pc-sysinstall/backend-query/detect-laptop.sh
share/pc-sysinstall/backend-query/list-packages.sh
share/pc-sysinstall/backend-query/disk-info.sh

0 comments on commit dca28eb

Please sign in to comment.