[PC-BSD Commits] r1117 - pcbsd/trunk/PBIsource
svn at pcbsd.org
svn at pcbsd.org
Wed Jan 9 08:06:57 PST 2008
Author: kris
Date: 2008-01-09 08:06:56 -0800 (Wed, 09 Jan 2008)
New Revision: 1117
Added:
pcbsd/trunk/PBIsource/fileopen.png
Modified:
pcbsd/trunk/PBIsource/pbi.ui
pcbsd/trunk/PBIsource/pbi.ui.h
Log:
Update to version 4.0 of the PBI installer, adds these features:
* Ability for user to choose where they wish to install an application
* Internal checksum / data integrity check is run during install now
* Displays available disk space and doesn't let the user try installing
to a partition without enough room.
Added: pcbsd/trunk/PBIsource/fileopen.png
Property changes on: pcbsd/trunk/PBIsource/fileopen.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Modified: pcbsd/trunk/PBIsource/pbi.ui
===================================================================
--- pcbsd/trunk/PBIsource/pbi.ui 2008-01-09 00:50:24 UTC (rev 1116)
+++ pcbsd/trunk/PBIsource/pbi.ui 2008-01-09 16:06:56 UTC (rev 1117)
@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>499</width>
- <height>419</height>
+ <height>397</height>
</rect>
</property>
<property name="sizePolicy">
@@ -797,6 +797,386 @@
<cstring>WizardPage</cstring>
</property>
<attribute name="title">
+ <string>Install Directory</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Please select where you wish this application to be installed. The suggested directory below is often the best location.</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer33</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer35</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer33_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textDesktopLinks_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="backgroundOrigin">
+ <enum>ParentOrigin</enum>
+ </property>
+ <property name="text">
+ <string><b>Installation Directory</b></string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop|AlignHCenter</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>lineInstallLocation</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="3">
+ <property name="name">
+ <cstring>pushChangeLocation</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>34</width>
+ <height>34</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ </widget>
+ <spacer row="0" column="3" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>spacer37</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>71</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="0" column="2" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer39</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>3</width>
+ <height>60</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="0" column="0" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer36</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>61</width>
+ <height>50</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>spacer38</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>30</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer45</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer44</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="4" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textDirectoryMessage</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="0">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>textRemainSpace</cstring>
+ </property>
+ <property name="text">
+ <string>XXMB</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Available Space</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textReqSpace</cstring>
+ </property>
+ <property name="text">
+ <string>XXMB</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Required Space</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textAvailSpace</cstring>
+ </property>
+ <property name="text">
+ <string>XXMB</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>textLabel2_2_4</cstring>
+ </property>
+ <property name="text">
+ <string>Remaining Space</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="6" column="0">
+ <property name="name">
+ <cstring>spacer46</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>15</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>WizardPage</cstring>
+ </property>
+ <attribute name="title">
<string>Desktop Links</string>
</attribute>
<grid>
@@ -1359,6 +1739,19 @@
</grid>
</widget>
</widget>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1823">89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af4000006e6494441545885c5976d8c554719c77f73cedd7bb9bb7b1758d882588adb360a0245880a0d1a2a9a02bad826a6690a26523fd6f8c9a089a9315bad44c0da0f2635d1840f4afd544d8b69458aa1bc296c5b0a8205ca2eecb29765f7eedef79773cebcf961ce2ebbc2a295264c3299c9997be7f93fcfffff3c3323acb5dccde6dd55eb40024008f1916cf6ecf3fb3a7d9af634a2f0d8ceeec77e024480b9dd7f3eb20874ff7c7f774b734b5fd7571f5ad7dadaf2c3cddff8fe7a200ddcd6bbc41d1bdef9979520f6742e9abbe2eb1b97934a2648257d72a3c51781f5b828c86937f87f45b8e39707673dff8b03ddbb7f75c8f65e2e5829ad1d1b0bedc848dd5a6bed4b7b4ed8a79e7e7117d0ce6d222dacb5b43c79e490d5dab3c60aac75a0ec0d70d6584c38fa33fde6968380dcf1c25f1fb1787b167f72fea2cd1b9712850629355a5bb4d6789e2035a389e776eeaf1efedbcb5d278eeeed011ac04dde2600d62d6b5ff7da8f96520494864043a8208ae7fb4f94d9fddbf75e4f6cfa7df7f7d6cfe9983d3bf3cc86f54bb8efde990481c198a9fb2a6568f63cbef2c8e2d6dce8a6174e1cdddb85a3e1262a128e062803837550c675a!
9dc186958f9501bdbb77452bfa47fbc76ed27f8c2ea4eac05a5a6a7a850a8f1e897eee7e4bb57572debfaf5aeb3177a77f3c1aeb3809e1c0927c2dbe8c048b8f6f6fbccaf96e9dab69a791dcd580be6b6c9e5dae868c0379f58c585cbf9ad17864d49c2b3400598809e003016f42d3094872a0c9c3cc3c3ab16f1d9954bfebbc5ff6851a458303fc3631b3e45a938d2b9af87d9382d4c05608d9d024045d07bf42c6913b1edc9d5645a3f5cb69eebaff2e79e513016e10b92099f01397f53d39adf3c274dfa1a24a4f35a9e761188799f405e5344a512dbbeb5f6437b7db6bfc6e33f3dcd6716cfe5c18fcf743a092d2bd62ce38165e1566d295a6bedc1bf0f646ad7877e9700d0766a049a672748b6b7d3736a90cfadbcf77f365eaa49befbd279beb86a01cf3cb5940bc34ec400c926181e89182ed4c34625b85eabf72ea77afefcb41ad87f25c5ced7fa58b4b088b560b5ab0fd69898328b3576e2bb319681e13a2b1677f09dad4b79e514e46b6e6f00cf83849fe4f8c96bf306df3a6368911ebdbb8ec5141894be617c68145e3d9c65eff615b436593299144a83c2220d286d510aa4b668035283529674aa89597366f0ea69a804378c0be12270f11ffd0c1d3f6f48985944a3c781684203932370ecd408cb3b33747d7e267d57cacc6a6fa2a52d4105284ba8d4a1dc70bd5!
6874a034a122a05a8649d71193ba40349315be0dcd18be447ca0daad130b3d!
4c7a85e3
e06346200ce93f18afdca8101bab7dc4f00a43bdae8ebcff1e0a73b082d44120209c53264739642c5707528a45836942a9a4a5511d4236410a22a35f2d93cf9421ddd90250299c3b7093c9ba274a207a8c722041547e08301c550ae4ed79a7642032609b4cde45c5f85f679192e65e1eab0a158d614cb9a524553ac684a2545beaca95543542342d5ea8c0e8da195417b334046ae02a66841d52f913f343001c0c475c007de3892a56b7507cd4928680801d99ce4e260885fb0482508a525924e0b525ba48448b9b9b5502e3728e7ab78c93422251c57e3cdd769a2b1c3b8ad036f3c0bc6ebc0e17786d9bcfa1e42a012c1401eb24530c90cc3b91a91740695864881944e8cca08ea0d4d365ba61a5a12ad1944e216052c615a291e7b1da84f12a1451918e857d46b115f7b780e835518ac422d72878ef540099f7c29407849226551caba0cd03094ab319c0b11e9667ca3b14170f31993b22d685925f7c7f781da04001dd7813fbc7185c7d7dc432e846a0869e152c8f3c0f7c1b6a5c80e564837fb24512485266925b57c85b40ff3e7cec08621360cb0a681b121d658ea6949206d536054723cfd706782761188f3f950cf102f6f5fc1920c90b9015c6b9052a394462d6942cad0cd9542298394c978ae1c3d2a8152cd28958abfa5512a937962473fc140f63d208841d8894af8!
e6c9323e968dabda6ea2cd4540608cc0f3049ee7e1791621dc38754de0797ebc6e27e6bd4311c19884d13f1d89f9978c67beb196236f0ff1ed476f5df71d0de3867d7cdf19f27d0f21261bf5f07d6f1210811002df171c3957035deb23e8cddf0cc0c0a933d7797ac3c25b027020c484e11bddc3f33c84f06eb136fe7b0f217cdefa67151a7d0762ee03e2f74202e052df180fdc9761f182a66901785e5cb28d248c228220240c0382202408221a4140108684414410048432c22883368672dd307a3584fab977816acc3f130010824259f2e51fbc03d6a5a5bb1d03d662e293cf188d5106a535461b8cd6a878bc9a0ba9e4a4139431eed617efe3ee70e108857dffc2a5dfc4e554586b1142b4010b8199d386e0ce9bc1dd7db3f168270368c23da3a6e7e0ce9bc5793ee54e28eef6f3fcdfbb4c411b01b1318e0000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>pushChangeLocation</sender>
+ <signal>clicked()</signal>
+ <receiver>PBI</receiver>
+ <slot>slotChangeInstallLocation()</slot>
+ </connection>
+</connections>
<includes>
<include location="local" impldecl="in declaration">qprocess.h</include>
<include location="local" impldecl="in implementation">qprocess.h</include>
@@ -1367,6 +1760,7 @@
<include location="local" impldecl="in implementation">qdir.h</include>
<include location="local" impldecl="in implementation">qobjectlist.h</include>
<include location="local" impldecl="in implementation">qtimer.h</include>
+ <include location="local" impldecl="in implementation">qfiledialog.h</include>
<include location="local" impldecl="in implementation">pbi.ui.h</include>
</includes>
<variables>
@@ -1414,6 +1808,14 @@
<variable access="private">int ExtractStarted;</variable>
<variable access="private">QString ExeTaskbar[100];</variable>
<variable access="private">QString LaunchClose;</variable>
+ <variable access="private">int ProgSize;</variable>
+ <variable access="private">QString ProgMD5;</variable>
+ <variable access="private">QProcess *StartDF;</variable>
+ <variable access="private">QString CheckDFParts[100];</variable>
+ <variable access="private">QString InstallDirPath;</variable>
+ <variable access="private">QProcess *ChecksumProc;</variable>
+ <variable access="private">int ChecksumFinished;</variable>
+ <variable access="private">int ChecksumPassed;</variable>
</variables>
<slots>
<slot>ProgramInit( QString ProgDir )</slot>
@@ -1438,13 +1840,22 @@
<slot>reject()</slot>
<slot>extractOnlyFinished()</slot>
<slot>accept()</slot>
+ <slot access="private">slotCheckInstallLocation()</slot>
+ <slot access="private">slotChangeInstallLocation()</slot>
+ <slot access="private">slotSetupCustomRemoveScript()</slot>
+ <slot access="private">slotReadChecksumProc()</slot>
+ <slot access="private">slotChecksumFinished()</slot>
+ <slot access="private">slotRecheckChecksumFinished()</slot>
</slots>
<functions>
<function>layOutButtonRow( QHBoxLayout * layout )</function>
<function>checkCustomGraphics()</function>
<function>uninstall()</function>
<function>extractOnly()</function>
+ <function access="private" returnType="bool">checkSpaceRequirements()</function>
+ <function access="private" returnType="QString">getLineFromCommandOutput( QString command )</function>
+ <function access="private">startChecksumTest()</function>
+ <function access="private">startInstallFirstRunCheck()</function>
</functions>
-<pixmapinproject/>
<layoutdefaults spacing="6" margin="11"/>
</UI>
Modified: pcbsd/trunk/PBIsource/pbi.ui.h
===================================================================
--- pcbsd/trunk/PBIsource/pbi.ui.h 2008-01-09 00:50:24 UTC (rev 1116)
+++ pcbsd/trunk/PBIsource/pbi.ui.h 2008-01-09 16:06:56 UTC (rev 1117)
@@ -84,6 +84,12 @@
// Setup the launch when finished checkbox to be hidden at first
checkLaunch->setHidden(TRUE);
LaunchClose="";
+
+ // Start our internal md5 checksum of the tar data
+ ChecksumFinished = 1;
+ ChecksumPassed = 1;
+ startChecksumTest();
+
}
@@ -103,7 +109,31 @@
AgreeButtonSlot();
}
+ if ( PageName == tr("Install Directory") )
+ {
+ setBackEnabled(currentPage(), TRUE);
+ setNextEnabled(currentPage(), FALSE);
+
+ // Check the lineInstallLocation and populate it if empty
+ if ( lineInstallLocation->text().isEmpty() )
+ {
+ QDir DefaultDir;
+ DefaultDir.setPath("/Programs/" + ProgDirName);
+
+ lineInstallLocation->setText(DefaultDir.canonicalPath());
+ }
+
+ // Check if this directory is valid and has enough space
+ StartDF = new QProcess( this );
+ StartDF->addArgument( "sh" );
+ StartDF->addArgument( "checkdf.sh" );
+ connect( StartDF, SIGNAL(processExited()), this, SLOT( slotCheckInstallLocation() ) );
+ if ( !StartDF->start() ) {
+ QMessageBox::information( this, tr("Error!"), tr("Error running startdf.sh Script! ") );
+ }
+
+ }
if ( PageName == tr("Install Software") )
{
@@ -111,46 +141,13 @@
setFinishEnabled(currentPage(),FALSE);
setNextEnabled(currentPage(), FALSE);
- QDir NewDir;
- NewDir.setPath("/Programs/" + ProgDirName);
-
- // If we have a PBI.FirstRun.sh file, execute it here first
- QFile FirstRun( "PBI.FirstRun.sh" );
- if ( FirstRun.exists() ) {
- StatusLabel->setText(tr("Running pre-install script..."));
- progressTextDialog->setText("");
-
- // Write out the wrapper script
- QFile file( ".PBIwrapper.sh" );
- if ( file.open( IO_WriteOnly ) ) {
- QTextStream stream( &file );
- stream << "#!/bin/sh\n";
- stream << "PROGDIR=\"" + ProgDirName + "\"; export PROGDIR\n";
- stream << "USERNAME=\"" + RealUserName + "\"; export USERNAME\n";
- stream << "INSTALLMODE=\"GUI\"; export INSTALLMODE\n";
- stream << "sh ./PBI.FirstRun.sh\nexit ${?}";
-
- file.close();
- }
-
- FirstRunScript = new QProcess( this );
- FirstRunScript->addArgument( "sh" );
- FirstRunScript->addArgument( "./.PBIwrapper.sh" );
- //FirstRunScript->addArgument( "./PBI.FirstRun.sh" );
- //FirstRunScript->addArgument( ProgDirName );
- //FirstRunScript->addArgument( RealUserName );
- connect( FirstRunScript, SIGNAL(processExited()), this, SLOT(readFirstRunOutput() ) );
- connect( FirstRunScript, SIGNAL(readyReadStdout()), this, SLOT(readyReadScriptOutput() ) );
-
- if ( !FirstRunScript->start() ) {
- QMessageBox::information( this, tr("Error!"), tr("Error running FirstRun.sh Script! ") );
- startInstallSlot();
- }
-
- } else {
- startInstallSlot();
- }
-
+ if ( ChecksumFinished == 0 )
+ {
+ startInstallFirstRunCheck();
+ } else {
+ progressTextDialog->setText(tr("Finishing data integrity check... Your install will begin momentarily..."));
+ QTimer::singleShot( 1000, this, SLOT(slotRecheckChecksumFinished()) );
+ }
}
@@ -298,6 +295,19 @@
TotalLinesTar = 0;
}
+ if (line.find("ProgSize:") == 0)
+ {
+ line = line.replace("ProgSize: ", "");
+ ProgSize = line.toInt();
+ textReqSpace->setText(line + "MB");
+ }
+
+ if (line.find("ProgCheck:") == 0)
+ {
+ line = line.replace("ProgCheck: ", "");
+ ProgMD5 = line;
+ }
+
}
file.close();
@@ -1006,7 +1016,8 @@
void PBI::FinishedInstallSlot()
-{
+{
+
if ( CLImode == 0)
{
installProgress->setProgress(installProgress->totalSteps());
@@ -1067,18 +1078,18 @@
//SetupScript->addArgument( "/Programs/" + ProgDirName + "/PBI.SetupScript.sh");
//SetupScript->addArgument( ProgDirName );
//SetupScript->addArgument( RealUserName );
- connect( SetupScript, SIGNAL(processExited()), this, SLOT(FinishedInstallSlot() ) );
+ connect( SetupScript, SIGNAL(processExited()), this, SLOT(slotSetupCustomRemoveScript() ) );
connect( SetupScript, SIGNAL(readyReadStdout()), this, SLOT(readyReadScriptOutput2() ) );
if ( !SetupScript->start() ) {
QMessageBox::information( this, tr("Error!"), tr("Error running custom setup script! ") );
- FinishedInstallSlot();
+ slotSetupCustomRemoveScript();
}
} else {
// No script, finish the install
- FinishedInstallSlot();
+ slotSetupCustomRemoveScript();
}
@@ -1204,6 +1215,10 @@
progressTextDialog->setText("");
+
+ // Set our new installation path
+ InstallDirPath = lineInstallLocation->text();
+
QDir NewDir;
NewDir.setPath("/Programs/" + ProgDirName);
installProgress->setTotalSteps(StepsTarFile);
@@ -1211,9 +1226,13 @@
if (NewDir.exists() && CLImode == 0)
{
- switch( QMessageBox::warning( this, tr("Warning!"), tr("The program (") + ProgDirName + tr(") exists. Overwrite it?"), tr("OK"), tr("Cancel"), 0, 0, 1 ) ) {
+ switch( QMessageBox::warning( this, tr("Warning!"), tr("The program (") + ProgDirName + tr(") exists. Replace it?"), tr("OK"), tr("Cancel"), 0, 0, 1 ) ) {
case 0: // The user clicked the OK again button or pressed Enter
OverWrote = 1;
+ if (! ProgDirName.isEmpty() )
+ {
+ runCommand("rm -rf /Programs/" + ProgDirName);
+ }
break;
case 1: // The user clicked the Cancel
exit(1);
@@ -1221,9 +1240,16 @@
}
} else if (NewDir.exists() && CLImode == 1) {
OverWrote=1;
+ if (! ProgDirName.isEmpty() )
+ {
+ runCommand("rm -rf /Programs/" + ProgDirName);
+ }
}
- NewDir.mkdir("/Programs/" + ProgDirName, TRUE);
+
+ //NewDir.mkdir("/Programs/" + ProgDirName, TRUE);
+ NewDir.mkdir(InstallDirPath, TRUE);
+ system("ln -s '" + InstallDirPath + "' " + "/Programs/" + ProgDirName);
// If we have update URL, create the file here
if ( ! ProgUpdateURL.isEmpty() )
@@ -1952,3 +1978,309 @@
exit(0);
}
+
+// Check if the location we are installing to is valid, and enable / disable the Next button accordingly
+void PBI::slotCheckInstallLocation()
+{
+
+ // Check if we have enough free disk space in this partition
+ if ( checkSpaceRequirements())
+ {
+ setNextEnabled(currentPage(), TRUE);
+ } else {
+ setNextEnabled(currentPage(), FALSE);
+ }
+}
+
+
+
+// Check how much space we need on the selected directory / partition
+bool PBI::checkSpaceRequirements()
+{
+ QString line, tmp, installLoc;
+ int i = 0, matchLength = 0, selectedPart = 0, z = 0;
+ bool ok;
+
+ // Open our df file, and read it line-by-line
+ QFile file( ".dfoutput" );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+ while ( !stream.atEnd() ) {
+ tmp = stream.readLine(); // line of text excluding '\n'
+ CheckDFParts[i] = tmp.simplifyWhiteSpace();
+
+ // QMessageBox::critical( this, tr("DF"), "Read Line:" + CheckDFParts[i]);
+ i++;
+ }
+ // Make sure the last in our array is empty
+ CheckDFParts[i]="";
+ }
+
+
+ // Get our install location
+ installLoc = lineInstallLocation->text();
+
+ // Now determine which partition we have selected
+ i = 0;
+ while (! CheckDFParts[i].isEmpty() )
+ {
+ tmp = CheckDFParts[i];
+ tmp = tmp.section( ' ', 5, 5);
+ //QMessageBox::critical( this, tr("DF"), "Read Line:" + tmp);
+
+ // check if we have a potential match for the selected directory
+ if ( installLoc.find(tmp) == 0)
+ {
+ if ( matchLength <= tmp.length() )
+ {
+ // We have a new better match, save it
+ selectedPart = i;
+
+ // Save our new matchLength
+ matchLength = tmp.length();
+ }
+ }
+
+ i++;
+ }
+
+
+ // Now that we have our selected partition, populate the UI with the details of available space
+
+ textAvailSpace->setText(CheckDFParts[selectedPart].section( ' ', 3,3) + "MB");
+
+ // Now check if we have enough space here to install our application
+ z = CheckDFParts[selectedPart].section(' ', 3, 3).toInt(&ok);
+ if ( ok)
+ {
+ if ( (z - ProgSize) <= 1 )
+ {
+
+ textDirectoryMessage->setText(tr("Error: Not enough disk space on selected partition!"));
+ textRemainSpace->setText(tmp.setNum(z - ProgSize) + "MB" );
+ return false;
+ } else {
+ textRemainSpace->setText(tmp.setNum(z - ProgSize) + "MB" );
+ return true;
+ }
+
+ } else {
+ QMessageBox::critical( this, tr("ERROR:"), tr("Error determining remaining disk space!"));
+ }
+
+
+
+
+ return true;
+}
+
+// Change the location the user wants to install to
+void PBI::slotChangeInstallLocation()
+{
+
+
+ // Ask the user where they want to install
+ QString newDir = QFileDialog::getExistingDirectory(
+ "/home",
+ this,
+ tr("Select install directory"),
+ tr("Select install directory"),
+ TRUE );
+
+ // Check if the user just hit cancel
+ if ( newDir.isEmpty() )
+ {
+ return;
+ }
+
+ // Confirm we aren't using a potentiall bad directory to install to
+ if ( newDir.find("/dev") == 0 || newDir.find("/tmp") == 0 || newDir.find("/etc") == 0 || newDir.find("/tmp") == 0 || newDir.find("/boot") == 0 || newDir.find("/bin") == 0 || newDir.find("/sbin") == 0 || newDir.find("/lib") == 0 || newDir.find("/libexec") == 0 || newDir.find("/proc") == 0 || newDir.find("/tmp") == 0 || newDir.find("/rescue") == 0 || newDir.find("/tmp") == 0 || newDir.find("/swap") == 0 || newDir.find("/var") == 0)
+ {
+ QMessageBox::critical( this, tr("Directory Error"),
+ tr("Error: This directory cannot be used for program installation. Please select another directory.") );
+ return;
+ }
+
+ // Check if the selected directory is even writable
+ QFile file( newDir + "/.writecheck" );
+ if ( file.open( IO_WriteOnly ) ) {
+ file.close();
+ file.remove();
+ } else {
+ QMessageBox::critical( this, tr("Directory Error"),
+ tr("Error: The selected directory is not writable. Please select another directory.") );
+ return;
+ }
+
+
+ newDir = newDir + ProgDirName;
+ lineInstallLocation->setText(newDir);
+
+ // Run the checks to ensure we have enough room on this partition
+ slotCheckInstallLocation();
+
+}
+
+
+QString PBI::getLineFromCommandOutput( QString command )
+{
+
+ FILE *file = popen(command,"r");
+
+ char buffer[100];
+
+ QString line = "";
+ char firstChar;
+
+ if ((firstChar = fgetc(file)) != -1){
+ line += firstChar;
+ line += fgets(buffer,100,file);
+ }
+
+
+ pclose(file);
+
+
+ return line;
+
+}
+
+
+void PBI::slotSetupCustomRemoveScript()
+{
+ // Setup our custom removal script
+ if ( QFile::exists( "/Programs/" + ProgDirName + "/PBI.RemoveScript.sh" ) )
+ {
+ system("mv /Programs/" + ProgDirName + "/PBI.RemoveScript.sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh");
+ }
+
+ QFile file( "/Programs/" + ProgDirName + "/PBI.RemoveScript.sh" );
+ if ( file.open( IO_WriteOnly ) ) {
+ QTextStream stream( &file );
+ stream << "#!/bin/sh\n";
+ stream << "if [ -e '/Programs/" + ProgDirName + "/PBI.RemoveScript2.sh' ]\n";
+ stream << "then\n";
+ stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
+ stream << "fi\n";
+ stream << "rm -rf '" + InstallDirPath + "'";
+ file.close();
+ }
+ system("chmod 755 /Programs/" + ProgDirName + "/PBI.RemoveScript.sh" );
+
+ FinishedInstallSlot();
+}
+
+
+void PBI::startChecksumTest()
+{
+ // This function starts the internal checksum to ensure the PBI is intact
+
+ // Make the checksum.sh script now
+ QFile file4( "checksum.sh" );
+ if ( file4.open( IO_WriteOnly ) ) {
+ QTextStream stream4( &file4 );
+ stream4 << "#!/bin/sh\nSKIP=`cat pbiskip`\ntail +${SKIP} pbilink | md5 >&1";
+ file4.close();
+ }
+
+ ChecksumProc = new QProcess( this );
+ ChecksumProc->addArgument( "sh" );
+ ChecksumProc->addArgument( "checksum.sh" );
+ connect( ChecksumProc, SIGNAL(processExited()), this, SLOT( slotChecksumFinished() ) );
+ connect( ChecksumProc, SIGNAL(readyReadStdout()), this, SLOT(slotReadChecksumProc() ) );
+ if ( !ChecksumProc->start() ) {
+ QMessageBox::information( this, tr("Error!"), tr("Error running internal checksum Script! ") );
+ }
+}
+
+
+void PBI::slotReadChecksumProc()
+{
+ QString tmp;
+
+ // Make sure we only run once
+ if ( ChecksumFinished == 1)
+ {
+
+ while (ChecksumProc->canReadLineStdout() )
+ {
+ // Read the line, then check if it is a match
+ tmp = ChecksumProc->readLineStdout();
+
+ if ( tmp != ProgMD5 )
+ {
+ ChecksumFinished = 0;
+ QMessageBox::critical( this, tr("Data integrity check failed!"), tr("ERROR: The internal data integrity check failed! The file is corrupt! "));
+ close();
+ } else {
+
+ //QMessageBox::critical( this, "Data Integrity check Passed!", "YAY " + tmp + " = " + ProgMD5);
+ ChecksumFinished = 0;
+ ChecksumPassed = 0;
+ }
+ }
+
+ }
+}
+
+
+void PBI::slotChecksumFinished()
+{
+ ChecksumFinished = 0;
+}
+
+
+void PBI::startInstallFirstRunCheck()
+{
+
+ QDir NewDir;
+ NewDir.setPath("/Programs/" + ProgDirName);
+
+ // If we have a PBI.FirstRun.sh file, execute it here first
+ QFile FirstRun( "PBI.FirstRun.sh" );
+ if ( FirstRun.exists() ) {
+ StatusLabel->setText(tr("Running pre-install script..."));
+ progressTextDialog->setText("");
+
+ // Write out the wrapper script
+ QFile file( ".PBIwrapper.sh" );
+ if ( file.open( IO_WriteOnly ) ) {
+ QTextStream stream( &file );
+ stream << "#!/bin/sh\n";
+ stream << "PROGDIR=\"" + ProgDirName + "\"; export PROGDIR\n";
+ stream << "USERNAME=\"" + RealUserName + "\"; export USERNAME\n";
+ stream << "INSTALLMODE=\"GUI\"; export INSTALLMODE\n";
+ stream << "sh ./PBI.FirstRun.sh\nexit ${?}";
+
+ file.close();
+ }
+
+ FirstRunScript = new QProcess( this );
+ FirstRunScript->addArgument( "sh" );
+ FirstRunScript->addArgument( "./.PBIwrapper.sh" );
+ //FirstRunScript->addArgument( "./PBI.FirstRun.sh" );
+ //FirstRunScript->addArgument( ProgDirName );
+ //FirstRunScript->addArgument( RealUserName );
+ connect( FirstRunScript, SIGNAL(processExited()), this, SLOT(readFirstRunOutput() ) );
+ connect( FirstRunScript, SIGNAL(readyReadStdout()), this, SLOT(readyReadScriptOutput() ) );
+
+ if ( !FirstRunScript->start() ) {
+ QMessageBox::information( this, tr("Error!"), tr("Error running FirstRun.sh Script! ") );
+ startInstallSlot();
+ }
+
+ } else {
+ startInstallSlot();
+ }
+}
+
+
+void PBI::slotRecheckChecksumFinished()
+{
+ if ( ChecksumFinished == 0 )
+ {
+ startInstallFirstRunCheck();
+ } else {
+ QTimer::singleShot( 1000, this, SLOT(slotRecheckChecksumFinished()) );
+ }
+}
More information about the Commits
mailing list