[PC-BSD Commits] r3770 - in pbibuild/pbi-source: PBIsource PBItext
svn at pcbsd.org
svn at pcbsd.org
Mon Apr 6 12:38:52 PDT 2009
Author: kris
Date: 2009-04-06 12:38:51 -0700 (Mon, 06 Apr 2009)
New Revision: 3770
Modified:
pbibuild/pbi-source/PBIsource/pbi.cpp
pbibuild/pbi-source/PBIsource/pbi.h
pbibuild/pbi-source/PBIsource/pbi.ui
pbibuild/pbi-source/PBItext/main.cpp
Log:
Updated the PBI installer. Fixed a few bugs:
* Now our kmenu icon gets created in such a way, that your favorites list doesn't get messed up when you remove / update a PBI to a diff version.
* Setup the PBI installer to check if a previous copy of app is installed, and prompt the user to overwrite it
* Fixed a bug formatting the ProgList data file when you overwrite a app
Modified: pbibuild/pbi-source/PBIsource/pbi.cpp
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.cpp 2009-04-06 14:18:59 UTC (rev 3769)
+++ pbibuild/pbi-source/PBIsource/pbi.cpp 2009-04-06 19:38:51 UTC (rev 3770)
@@ -11,10 +11,10 @@
*****************************************************************************/
/****************************************************************************
* Name: PBI-Wizard
-* Version: 5.1
+* Version: 5.2
* Author: Kris Moore
* License: BSD (See LICENSE file for more detail)
-* Date: 3-06-09
+* Date: 4-06-09
*****************************************************************************/
#include <iostream>
@@ -75,12 +75,15 @@
connect( LicenseCheckBox, SIGNAL( clicked() ), this, SLOT(AgreeButtonSlot() ) );
+ // Check if we have any custom graphics for this PBI
checkCustomGraphics();
+ // Read in this programs configuration data
readSettingsSlot();
+
+ // Slot to check if this Program is already installed
+ QTimer::singleShot( 500, this, SLOT(slotCheckExistingProgram()) );
-
-
// Setup the launch when finished checkbox to be hidden at first
checkLaunch->setHidden(TRUE);
LaunchClose="";
@@ -89,10 +92,48 @@
ChecksumFinished = 1;
ChecksumPassed = 1;
startChecksumTest();
-
+
}
+// Function which checks the ProgList if we already have this app installed
+void PBI::slotCheckExistingProgram(void)
+{
+ QString line;
+ bool foundProgram = false;
+
+ QFile file2( "/Programs/.config/ProgList" );
+ if ( file2.open( IO_ReadOnly ) ) {
+ QTextStream stream2( &file2 );
+ while ( !stream2.atEnd() ) {
+ line = stream2.readLine(); // line of text excluding '\n'
+ // Look for the same entry if it exists in the package config file
+ if ( line.indexOf("ProgName: " + ProgramName) != -1)
+ {
+ foundProgram=true;
+ }
+
+ }
+
+ file2.close();
+ }
+
+ if (foundProgram) {
+ switch( QMessageBox::warning( this, tr("Warning!"), tr("The program") + " (" + ProgramName + ") " + tr("is already installed. Overwrite it?"), tr("OK"), tr("Cancel"), 0, 0, 1 ) )
+ {
+ case 0: // The user clicked the OK button
+ OverWrote = 1;
+ break;
+
+ case 1: // The user clicked the cancel button
+ exit(1);
+ break;
+ }
+
+
+ }
+}
+
void PBI::PageChanged( const QString &PageName )
{
setHelpEnabled(currentPage(), FALSE);
@@ -319,7 +360,9 @@
// Set the menu labels
//ProgramLabel->setText(ProgramName);
WelcomeLabel->setText(tr("Click Next to start the install of ") + " " + ProgramName + tr(".") );
- ProgramLabel->setText("<h1><b>" + ProgramName + " " + ProgramVer + " " + "</b></h1>");
+ QFont font("Sans Serif", 16, QFont::Bold);
+ ProgramLabel->setText( ProgramName + " " + ProgramVer);
+ ProgramLabel->setFont(font);
AuthorLabel->setText(ProgramAuthor);
WebsiteLabel->setText(ProgramWeb);
setCaption("PBI: " + ProgramName + " " + ProgramVer );
@@ -428,22 +471,34 @@
// Look for the same entry if it exists in the package config file
if ( line.indexOf("ProgName: " + ProgramName) != -1)
{
- // Check the version, make sure they are same
line2 = stream2.readLine();
- // If the same version, then gobble up extra lines
- if ( line2.indexOf("ProgVer: " + ProgramVer) != -1)
+ while ( line2.indexOf("ProgName: ") == -1 && ! stream2.atEnd() )
{
- while ( line2.indexOf("ProgName: ") == -1 && ! stream2.atEnd() )
- {
- line2 = stream2.readLine();
- }
+ line2 = stream2.readLine();
+ }
- SavedFile = SavedFile + line2 + "\n";
-
- // If different version, then continue on
- } else {
- SavedFile = SavedFile + line2 + "\n";
- }
+ // Check if this is the last entry in ProgList
+ if ( ! stream2.atEnd() ) {
+ SavedFile = SavedFile + line2 + "\n";
+ } else {
+ QStringList tmpList = SavedFile.split(QRegExp("\n"));
+ // Clean up the end of our list
+ for (int i = tmpList.size() -1 ; i > 0; --i)
+ {
+ if ( tmpList.at(i) == "[ Program Entry ]" || tmpList.at(i).isEmpty())
+ {
+ // Remove the last entry
+ tmpList.removeLast();
+ } else {
+ break;
+ }
+ }
+
+ // Create our new save file
+ SavedFile = tmpList.join("\n");
+ SavedFile = SavedFile + "\n";
+ }
+
// If no entry, save the line
} else {
SavedFile = SavedFile + line + "\n";
@@ -706,7 +761,7 @@
if(LaunchCheckBox->isChecked() && NoMenu[exenum] == "0" )
{
- tmp = "/usr/local/share/applications/kde/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ tmp = "/usr/local/share/applications/kde/PBI-" + ProgramName + "-" + Binary + ".desktop";
QFile file( tmp );
if(!file.open( QIODevice::WriteOnly))
{
@@ -1367,52 +1422,32 @@
void PBI::startInstallSlot()
{
-
-
progressTextDialog->setText("");
-
// Set our new installation path
InstallDirPath = lineInstallLocation->text();
- QDir NewDir;
- NewDir.setPath("/Programs/" + ProgDirName);
- installProgress->setTotalSteps(StepsTarFile);
- installProgress->setProgress(0);
+ QDir NewDir;
+ NewDir.setPath("/Programs/" + ProgDirName);
+ installProgress->setTotalSteps(StepsTarFile);
+ installProgress->setProgress(0);
- if (NewDir.exists() && CLImode == 0)
- {
- 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);
- break;
- }
- } else if (NewDir.exists() && CLImode == 1) {
- OverWrote=1;
+ // Check if we need to remove an old directory
+ if (NewDir.exists())
+ {
if (! ProgDirName.isEmpty() )
{
- runCommand("rm -rf /Programs/" + ProgDirName);
- }
- }
+ system("rm -rf /Programs/" + ProgDirName.toLatin1());
+ }
+ }
- //NewDir.mkpath("/Programs/" + ProgDirName);
- QString RegularPath = "/Programs/" + ProgDirName;
- NewDir.mkpath(InstallDirPath);
- if ( InstallDirPath != RegularPath )
- {
- system("ln -s '" + InstallDirPath + "' " + "/Programs/" + ProgDirName);
- }
+ //NewDir.mkpath("/Programs/" + ProgDirName);
+ NewDir.mkpath(InstallDirPath);
+ system("ln -s '" + InstallDirPath + "' " + "/Programs/" + ProgDirName);
- // If we have update URL, create the file here
- if ( ! ProgUpdateURL.isEmpty() )
+ // If we have update URL, create the file here
+ if ( ! ProgUpdateURL.isEmpty() )
{
// Now save the new config file
QFile file3( "/Programs/" + ProgDirName + "/PBI.UpdateURL.sh" );
@@ -2295,7 +2330,7 @@
stream << "then\n";
stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
stream << "fi\n";
- stream << "rm /usr/local/share/applications/kde/PBI-" + ProgDirName+ "-* >/dev/null 2>/dev/null\n";
+ stream << "rm /usr/local/share/applications/kde/PBI-" + ProgramName+ "-* >/dev/null 2>/dev/null\n";
stream << "rm /usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory >/dev/null 2>/dev/null\n";
stream << "rm /usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu >/dev/null 2>/dev/null\n";
stream << "rm -rf '" + InstallDirPath + "'\n";
Modified: pbibuild/pbi-source/PBIsource/pbi.h
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.h 2009-04-06 14:18:59 UTC (rev 3769)
+++ pbibuild/pbi-source/PBIsource/pbi.h 2009-04-06 19:38:51 UTC (rev 3770)
@@ -66,6 +66,7 @@
void slotChecksumProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
void readFirstRunOutput(int exitCode, QProcess::ExitStatus exitStatus);
void slotCheckLocationProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
+ void slotCheckExistingProgram();
private:
QString ProgramName;
Modified: pbibuild/pbi-source/PBIsource/pbi.ui
===================================================================
--- pbibuild/pbi-source/PBIsource/pbi.ui 2009-04-06 14:18:59 UTC (rev 3769)
+++ pbibuild/pbi-source/PBIsource/pbi.ui 2009-04-06 19:38:51 UTC (rev 3770)
@@ -56,14 +56,6 @@
<bool>false</bool>
</property>
<widget class="QWidget" name="WizardPage" >
- <property name="geometry" >
- <rect>
- <x>6</x>
- <y>36</y>
- <width>503</width>
- <height>321</height>
- </rect>
- </property>
<attribute name="title" >
<string>Welcome Screen</string>
</attribute>
@@ -622,7 +614,7 @@
<property name="sizeHint" stdset="0" >
<size>
<width>21</width>
- <height>31</height>
+ <height>15</height>
</size>
</property>
</spacer>
@@ -953,6 +945,14 @@
</layout>
</widget>
<widget class="QWidget" name="WizardPage" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>100</width>
+ <height>30</height>
+ </rect>
+ </property>
<attribute name="title" >
<string>Install Directory</string>
</attribute>
Modified: pbibuild/pbi-source/PBItext/main.cpp
===================================================================
--- pbibuild/pbi-source/PBItext/main.cpp 2009-04-06 14:18:59 UTC (rev 3769)
+++ pbibuild/pbi-source/PBItext/main.cpp 2009-04-06 19:38:51 UTC (rev 3770)
@@ -13,6 +13,7 @@
void ProgramInit( QString ProgDir );
void readSettingsSlot(void);
+void checkExistingProgram(void);
void StartInstall(void);
QString getLineFromCommandOutput( QString command );
void runCommand( QString Command );
@@ -116,11 +117,35 @@
OverWrote = 0;
readSettingsSlot();
+ checkExistingProgram();
StartInstall();
runKmenuRegen();
cout << "Installation complete!\n";
}
+// Function which checks the ProgList if we already have this app installed
+void checkExistingProgram()
+{
+ QString line;
+
+ QFile file2( "/Programs/.config/ProgList" );
+ if ( file2.open( QIODevice::ReadOnly ) ) {
+ QTextStream stream2( &file2 );
+ while ( !stream2.atEnd() ) {
+ line = stream2.readLine(); // line of text excluding '\n'
+ // Look for the same entry if it exists in the package config file
+ if ( line.indexOf("ProgName: " + ProgramName) != -1)
+ {
+ OverWrote=1;
+ }
+
+ }
+
+ file2.close();
+ }
+
+}
+
void runKmenuRegen()
{
system("echo -e \"Rebuilding Menu Database...\\c\"");
@@ -164,10 +189,10 @@
if (NewDir.exists())
{
- cout << "Warning: Overwrote ";
- cout << ProgDirName.toStdString();
- cout << "\n";
- OverWrote = 1;
+ if (! ProgDirName.isEmpty() )
+ {
+ system("rm -rf /Programs/" + ProgDirName.toLatin1());
+ }
}
NewDir.mkpath("/Programs/" + ProgDirName);
@@ -400,9 +425,7 @@
void CreateConfigSlot(void)
{
-
-
-
+ // Check if we are installing on top of an existing app, and clean the list
if ( OverWrote == 1)
{
@@ -411,29 +434,41 @@
QString line2;
QFile file2( "/Programs/.config/ProgList" );
- if ( file2.open( QIODevice::ReadOnly ) ) {
+ if ( file2.open( QIODevice::ReadOnly ) ) {
QTextStream stream2( &file2 );
while ( !stream2.atEnd() ) {
line = stream2.readLine(); // line of text excluding '\n'
// Look for the same entry if it exists in the package config file
if ( line.indexOf("ProgName: " + ProgramName) != -1)
{
- // Check the version, make sure they are same
line2 = stream2.readLine();
- // If the same version, then gobble up extra lines
- if ( line2.indexOf("ProgVer: " + ProgramVer) != -1)
+ while ( line2.indexOf("ProgName: ") == -1 && ! stream2.atEnd() )
{
- while ( line2.indexOf("ProgName: ") == -1 && ! stream2.atEnd() )
- {
- line2 = stream2.readLine();
- }
+ line2 = stream2.readLine();
+ }
- SavedFile = SavedFile + line2 + "\n";
-
- // If different version, then continue on
- } else {
- SavedFile = SavedFile + line2 + "\n";
- }
+ // Check if this is the last entry in ProgList
+ if ( ! stream2.atEnd() ) {
+ SavedFile = SavedFile + line2 + "\n";
+ } else {
+ QStringList tmpList = SavedFile.split(QRegExp("\n"));
+ // Clean up the end of our list
+ for (int i = tmpList.size() -1 ; i > 0; --i)
+ {
+ if ( tmpList.at(i) == "[ Program Entry ]" || tmpList.at(i).isEmpty())
+ {
+ // Remove the last entry
+ tmpList.removeLast();
+ } else {
+ break;
+ }
+ }
+
+ // Create our new save file
+ SavedFile = tmpList.join("\n");
+ SavedFile = SavedFile + "\n";
+ }
+
// If no entry, save the line
} else {
SavedFile = SavedFile + line + "\n";
@@ -447,7 +482,7 @@
}
// Now save the new config file
QFile file3( "/Programs/.config/ProgList" );
- if ( file3.open( QIODevice::WriteOnly ) ) {
+ if ( file3.open( QIODevice::WriteOnly ) ) {
QTextStream stream3( &file3 );
stream3 << SavedFile;
file3.close();
@@ -457,8 +492,6 @@
}
-
-
int i;
// Adds the program to the Program Manager list
@@ -663,7 +696,7 @@
if( NoMenu[exenum] == "0" )
{
- tmp = "/usr/local/share/applications/kde/PBI-" + ProgDirName + "-" + Binary + ".desktop";
+ tmp = "/usr/local/share/applications/kde/PBI-" + ProgramName + "-" + Binary + ".desktop";
QFile file( tmp );
if(!file.open( QIODevice::WriteOnly))
{
@@ -1226,7 +1259,7 @@
stream << "then\n";
stream << " sh /Programs/" + ProgDirName + "/PBI.RemoveScript2.sh \"${@}\"\n";
stream << "fi\n";
- stream << "rm /usr/local/share/applications/kde/PBI-" + ProgDirName+ "-* >/dev/null 2>/dev/null\n";
+ stream << "rm /usr/local/share/applications/kde/PBI-" + ProgramName+ "-* >/dev/null 2>/dev/null\n";
stream << "rm /usr/local/share/desktop-directories/PBI-" + ProgDirName + ".directory >/dev/null 2>/dev/null\n";
stream << "rm /usr/local/etc/xdg/menus/applications-merged/PBI-" + ProgDirName + ".merge.menu >/dev/null 2>/dev/null\n";
More information about the Commits
mailing list