summaryrefslogtreecommitdiff
authortille <tille>2002-07-30 14:37:26 (UTC)
committer tille <tille>2002-07-30 14:37:26 (UTC)
commit988409a5a21b3a4238ce41316e48777c885f147a (patch) (unidiff)
tree0c62baa663e715f81e936664e0775dddb96ea519
parent0adb56cb2cd83e9933baa9776c77c4c637f93d04 (diff)
downloadopie-988409a5a21b3a4238ce41316e48777c885f147a.zip
opie-988409a5a21b3a4238ce41316e48777c885f147a.tar.gz
opie-988409a5a21b3a4238ce41316e48777c885f147a.tar.bz2
Added -force-overwrite ipkg option
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/installdialog.cpp17
-rw-r--r--noncore/unsupported/oipkg/installdialog.h1
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp2
3 files changed, 16 insertions, 4 deletions
diff --git a/noncore/unsupported/oipkg/installdialog.cpp b/noncore/unsupported/oipkg/installdialog.cpp
index c676e84..fd93ad3 100644
--- a/noncore/unsupported/oipkg/installdialog.cpp
+++ b/noncore/unsupported/oipkg/installdialog.cpp
@@ -1,108 +1,117 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "installdialog.h" 10#include "installdialog.h"
11 11
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qgroupbox.h> 13#include <qgroupbox.h>
14#include <qheader.h> 14#include <qheader.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qpushbutton.h> 16#include <qpushbutton.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qvariant.h> 18#include <qvariant.h>
19#include <qtooltip.h> 19#include <qtooltip.h>
20#include <qwhatsthis.h> 20#include <qwhatsthis.h>
21 21
22 22
23InstallDialog::InstallDialog( PackageManagerSettings* s, QWidget* parent, const char* name, bool modal, WFlags fl ) 23InstallDialog::InstallDialog( PackageManagerSettings* s, QWidget* parent, const char* name, bool modal, WFlags fl )
24 : QDialog( parent, name, modal, fl ) 24 : QDialog( parent, name, modal, fl )
25{ 25{
26 settings = s; 26 settings = s;
27 if ( !name ) 27 if ( !name )
28 setName( "InstallDialog" ); 28 setName( "InstallDialog" );
29 resize( 223, 269 ); 29 resize( 223, 269 );
30 setCaption( tr( "Install" ) ); 30 setCaption( tr( "Install" ) );
31 InstallDialogLayout = new QGridLayout( this ); 31 InstallDialogLayout = new QGridLayout( this );
32 InstallDialogLayout->setSpacing( 2 ); 32 InstallDialogLayout->setSpacing( 2 );
33 InstallDialogLayout->setMargin( 2 ); 33 InstallDialogLayout->setMargin( 2 );
34 34
35 ListViewPackages = new PackageListView( this,"listViewPackages",settings ); 35 ListViewPackages = new PackageListView( this,"listViewPackages",settings );
36 36
37 InstallDialogLayout->addWidget( ListViewPackages, 0, 0 ); 37 InstallDialogLayout->addWidget( ListViewPackages, 0, 0 );
38 38
39 GroupBoxOptions = new QGroupBox( this, "GroupBoxOptions" ); 39 GroupBoxOptions = new QGroupBox( this, "GroupBoxOptions" );
40 GroupBoxOptions->setTitle( tr( "Ipkg options" ) ); 40 GroupBoxOptions->setTitle( tr( "Ipkg options" ) );
41 GroupBoxOptions->setColumnLayout(0, Qt::Vertical ); 41 GroupBoxOptions->setColumnLayout(0, Qt::Vertical );
42 GroupBoxOptions->layout()->setSpacing( 0 ); 42 GroupBoxOptions->layout()->setSpacing( 0 );
43 GroupBoxOptions->layout()->setMargin( 0 ); 43 GroupBoxOptions->layout()->setMargin( 0 );
44 GroupBoxOptionsLayout = new QGridLayout( GroupBoxOptions->layout() ); 44 GroupBoxOptionsLayout = new QGridLayout( GroupBoxOptions->layout() );
45 GroupBoxOptionsLayout->setAlignment( Qt::AlignTop ); 45 GroupBoxOptionsLayout->setAlignment( Qt::AlignTop );
46 GroupBoxOptionsLayout->setSpacing( 2 ); 46 GroupBoxOptionsLayout->setSpacing( 0 );
47 GroupBoxOptionsLayout->setMargin( 2 ); 47 GroupBoxOptionsLayout->setMargin( 0 );
48 48
49 _force_depends = new QCheckBox( GroupBoxOptions, "_force_depends" ); 49 _force_depends = new QCheckBox( GroupBoxOptions, "_force_depends" );
50 QFont _force_depends_font( _force_depends->font() ); 50 QFont _force_depends_font( _force_depends->font() );
51 _force_depends_font.setPointSize( 8 ); 51 _force_depends_font.setPointSize( 8 );
52 _force_depends->setFont( _force_depends_font ); 52 _force_depends->setFont( _force_depends_font );
53 _force_depends->setText( tr( "-force-depends" ) ); 53 _force_depends->setText( tr( "-force-depends" ) );
54 //_force_depends->setChecked( true ); 54 //_force_depends->setChecked( true );
55 55
56 GroupBoxOptionsLayout->addWidget( _force_depends, 0, 0 ); 56 GroupBoxOptionsLayout->addWidget( _force_depends, 0, 0 );
57 57
58 _force_reinstall = new QCheckBox( GroupBoxOptions, "_force_reinstall" ); 58 _force_reinstall = new QCheckBox( GroupBoxOptions, "_force_reinstall" );
59 QFont _force_reinstall_font( _force_reinstall->font() ); 59 QFont _force_reinstall_font( _force_reinstall->font() );
60 _force_reinstall_font.setPointSize( 8 ); 60 _force_reinstall_font.setPointSize( 8 );
61 _force_reinstall->setFont( _force_reinstall_font ); 61 _force_reinstall->setFont( _force_reinstall_font );
62 _force_reinstall->setText( tr( "-force-reinstall" ) ); 62 _force_reinstall->setText( tr( "-force-reinstall" ) );
63 63
64 GroupBoxOptionsLayout->addWidget( _force_reinstall, 1, 0 ); 64 GroupBoxOptionsLayout->addWidget( _force_reinstall, 1, 0 );
65 65
66 _force_remove = new QCheckBox( GroupBoxOptions, "_force_remove" ); 66 _force_remove = new QCheckBox( GroupBoxOptions, "_force_remove" );
67 QFont _force_remove_font( _force_remove->font() ); 67 QFont _force_remove_font( _force_remove->font() );
68 _force_remove_font.setPointSize( 8 ); 68 _force_remove_font.setPointSize( 8 );
69 _force_remove->setFont( _force_remove_font ); 69 _force_remove->setFont( _force_remove_font );
70 _force_remove->setText( tr( "-force-removal-of-essential-packages" ) ); 70 _force_remove->setText( tr( "-force-removal-of-essential-packages" ) );
71 71
72 GroupBoxOptionsLayout->addWidget( _force_remove, 2, 0 ); 72 GroupBoxOptionsLayout->addWidget( _force_remove, 2, 0 );
73 73
74 _force_overwrite = new QCheckBox( GroupBoxOptions, "_force_overwrite" );
75 QFont _force_overwrite_font( _force_overwrite->font() );
76 _force_overwrite_font.setPointSize( 8 );
77 _force_overwrite->setFont( _force_overwrite_font );
78 _force_overwrite->setText( tr( "-force-overwrite" ) );
79
80 GroupBoxOptionsLayout->addWidget(_force_overwrite, 3, 0 );
81
74 InstallDialogLayout->addWidget( GroupBoxOptions, 1, 0 ); 82 InstallDialogLayout->addWidget( GroupBoxOptions, 1, 0 );
75 toRemoveItem = new QCheckListItem( ListViewPackages, tr("To remove") ); 83 toRemoveItem = new QCheckListItem( ListViewPackages, tr("To remove") );
76 toInstallItem = new QCheckListItem( ListViewPackages, tr("To install") ); 84 toInstallItem = new QCheckListItem( ListViewPackages, tr("To install") );
77 85
78} 86}
79 87
80/* 88/*
81 * Destroys the object and frees any allocated resources 89 * Destroys the object and frees any allocated resources
82 */ 90 */
83InstallDialog::~InstallDialog() 91InstallDialog::~InstallDialog()
84{ 92{
85 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
86} 94}
87 95
88/* 96/*
89 * Main event handler. Reimplemented to handle application 97 * Main event handler. Reimplemented to handle application
90 * font changes 98 * font changes
91 */ 99 */
92bool InstallDialog::event( QEvent* ev ) 100bool InstallDialog::event( QEvent* ev )
93{ 101{
94 bool ret = QDialog::event( ev ); 102 bool ret = QDialog::event( ev );
95 if ( ev->type() == QEvent::ApplicationFontChange ) { 103 if ( ev->type() == QEvent::ApplicationFontChange ) {
96 QFont _force_depends_font( _force_depends->font() ); 104 QFont _force_depends_font( _force_depends->font() );
97 _force_depends_font.setPointSize( 8 ); 105 _force_depends_font.setPointSize( 8 );
98 _force_depends->setFont( _force_depends_font ); 106 _force_depends->setFont( _force_depends_font );
99 QFont _force_reinstall_font( _force_reinstall->font() ); 107 QFont _force_reinstall_font( _force_reinstall->font() );
100 _force_reinstall_font.setPointSize( 8 ); 108 _force_reinstall_font.setPointSize( 8 );
101 _force_reinstall->setFont( _force_reinstall_font ); 109 _force_reinstall->setFont( _force_reinstall_font );
102 QFont _force_remove_font( _force_remove->font() ); 110 QFont _force_remove_font( _force_remove->font() );
111 QFont _force_overwrite_font( _force_overwrite->font() );
103 _force_remove_font.setPointSize( 8 ); 112 _force_remove_font.setPointSize( 8 );
104 _force_remove->setFont( _force_remove_font ); 113 _force_remove->setFont( _force_remove_font );
105 } 114 }
106 return ret; 115 return ret;
107} 116}
108 117
diff --git a/noncore/unsupported/oipkg/installdialog.h b/noncore/unsupported/oipkg/installdialog.h
index 828c8df..d3510ff 100644
--- a/noncore/unsupported/oipkg/installdialog.h
+++ b/noncore/unsupported/oipkg/installdialog.h
@@ -1,50 +1,51 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10 10
11 11
12#ifndef INSTALLDIALOG_H 12#ifndef INSTALLDIALOG_H
13#define INSTALLDIALOG_H 13#define INSTALLDIALOG_H
14 14
15#include "pksettings.h" 15#include "pksettings.h"
16#include "packagelistview.h" 16#include "packagelistview.h"
17#include <qvariant.h> 17#include <qvariant.h>
18#include <qdialog.h> 18#include <qdialog.h>
19class QVBoxLayout; 19class QVBoxLayout;
20class QHBoxLayout; 20class QHBoxLayout;
21class QGridLayout; 21class QGridLayout;
22class QCheckBox; 22class QCheckBox;
23class QGroupBox; 23class QGroupBox;
24class QListView; 24class QListView;
25class QListViewItem; 25class QListViewItem;
26 26
27class InstallDialog : public QDialog 27class InstallDialog : public QDialog
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 30
31public: InstallDialog( PackageManagerSettings* s, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 31public: InstallDialog( PackageManagerSettings* s, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
32 ~InstallDialog(); 32 ~InstallDialog();
33 33
34 PackageListView* ListViewPackages; 34 PackageListView* ListViewPackages;
35 QGroupBox* GroupBoxOptions; 35 QGroupBox* GroupBoxOptions;
36 QCheckBox* _force_depends; 36 QCheckBox* _force_depends;
37 QCheckBox* _force_reinstall; 37 QCheckBox* _force_reinstall;
38 QCheckBox* _force_overwrite;
38 QCheckBox* _force_remove; 39 QCheckBox* _force_remove;
39 QCheckListItem *toRemoveItem; 40 QCheckListItem *toRemoveItem;
40 QCheckListItem *toInstallItem; 41 QCheckListItem *toInstallItem;
41 42
42protected: 43protected:
43 QGridLayout* InstallDialogLayout; 44 QGridLayout* InstallDialogLayout;
44 QGridLayout* GroupBoxOptionsLayout; 45 QGridLayout* GroupBoxOptionsLayout;
45 bool event( QEvent* ); 46 bool event( QEvent* );
46private: 47private:
47 PackageManagerSettings* settings; 48 PackageManagerSettings* settings;
48}; 49};
49 50
50#endif // INSTALLDIALOG_H 51#endif // INSTALLDIALOG_H
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 84de67b..2ed313c 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,442 +1,444 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "pmipkg.h" 10#include "pmipkg.h"
11#include "pksettings.h" 11#include "pksettings.h"
12#include "package.h" 12#include "package.h"
13#include "packagelistitem.h" 13#include "packagelistitem.h"
14 14
15//#include <opie/oprocess.h> 15//#include <opie/oprocess.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/stringutil.h> 18#include <qpe/stringutil.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qdir.h> 20#include <qdir.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qgroupbox.h> 22#include <qgroupbox.h>
23#include <qmultilineedit.h> 23#include <qmultilineedit.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27#include <qtextview.h> 27#include <qtextview.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32 32
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35 35
36#include "mainwindow.h" 36#include "mainwindow.h"
37 37
38 38
39 39
40PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 40PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
41 : QObject ( p ) 41 : QObject ( p )
42{ 42{
43 settings = s; 43 settings = s;
44 runwindow = new RunWindow( p, name, true, f ); 44 runwindow = new RunWindow( p, name, true, f );
45 45
46 Config cfg( "oipkg", Config::User ); 46 Config cfg( "oipkg", Config::User );
47 cfg.setGroup( "ipkg" ); 47 cfg.setGroup( "ipkg" );
48 ipkg_cmd = cfg.readEntry( "cmd", "ipkg" )+" "; 48 ipkg_cmd = cfg.readEntry( "cmd", "ipkg" )+" ";
49} 49}
50 50
51PmIpkg::~PmIpkg() 51PmIpkg::~PmIpkg()
52{ 52{
53} 53}
54 54
55bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 55bool PmIpkg::runIpkg(const QString& args, const QString& dest )
56{ 56{
57 bool ret=false; 57 bool ret=false;
58 QDir::setCurrent("/tmp"); 58 QDir::setCurrent("/tmp");
59 QString cmd = ipkg_cmd; 59 QString cmd = ipkg_cmd;
60 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 60 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
61 if (!args.contains("update")) 61 if (!args.contains("update"))
62 { 62 {
63 if ( dest == "" ) 63 if ( dest == "" )
64 cmd += " -dest "+settings->getDestinationName(); 64 cmd += " -dest "+settings->getDestinationName();
65 else 65 else
66 cmd += " -dest "+ dest; 66 cmd += " -dest "+ dest;
67 67
68 cmd += " -force-defaults "; 68 cmd += " -force-defaults ";
69 69
70 if ( installDialog && installDialog->_force_depends ) 70 if ( installDialog && installDialog->_force_depends )
71 { 71 {
72 if (installDialog->_force_depends->isChecked()) 72 if (installDialog->_force_depends->isChecked())
73 cmd += " -force-depends "; 73 cmd += " -force-depends ";
74 if (installDialog->_force_reinstall->isChecked()) 74 if (installDialog->_force_reinstall->isChecked())
75 cmd += " -force-reinstall "; 75 cmd += " -force-reinstall ";
76 if (installDialog->_force_remove->isChecked()) 76 if (installDialog->_force_remove->isChecked())
77 cmd += " -force-removal-of-essential-packages "; 77 cmd += " -force-removal-of-essential-packages ";
78 if (installDialog->_force_overwrite->isChecked())
79 cmd += " -force-overwrite ";
78 } 80 }
79 } //!args.contains("update") 81 } //!args.contains("update")
80 82
81 out( "Starting to "+ args+"\n"); 83 out( "Starting to "+ args+"\n");
82 qApp->processEvents(); 84 qApp->processEvents();
83 cmd += args; 85 cmd += args;
84 out( "running:\n"+cmd+"\n" ); 86 out( "running:\n"+cmd+"\n" );
85 pvDebug(2,"running:"+cmd); 87 pvDebug(2,"running:"+cmd);
86 qApp->processEvents(); 88 qApp->processEvents();
87 FILE *fp; 89 FILE *fp;
88 char line[130]; 90 char line[130];
89 QString lineStr, lineStrOld; 91 QString lineStr, lineStrOld;
90 sleep(1); 92 sleep(1);
91 cmd +=" 2>&1"; 93 cmd +=" 2>&1";
92 fp = popen( (const char *) cmd, "r"); 94 fp = popen( (const char *) cmd, "r");
93 if ( fp == NULL ) { 95 if ( fp == NULL ) {
94 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 96 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
95 out("\nError while executing "+ cmd+"\n\n"); 97 out("\nError while executing "+ cmd+"\n\n");
96 ret = false; 98 ret = false;
97 } else { 99 } else {
98 while ( fgets( line, sizeof line, fp) != NULL) 100 while ( fgets( line, sizeof line, fp) != NULL)
99 { 101 {
100 lineStr = line; 102 lineStr = line;
101 lineStr=lineStr.left(lineStr.length()-1); 103 lineStr=lineStr.left(lineStr.length()-1);
102 //Configuring opie-oipkg...Done 104 //Configuring opie-oipkg...Done
103 if (lineStr.contains("Done")) ret = true; 105 if (lineStr.contains("Done")) ret = true;
104 if (lineStr!=lineStrOld) 106 if (lineStr!=lineStrOld)
105 out(lineStr); 107 out(lineStr);
106 lineStrOld = lineStr; 108 lineStrOld = lineStr;
107 qApp->processEvents(); 109 qApp->processEvents();
108 } 110 }
109 } 111 }
110 pclose(fp); 112 pclose(fp);
111 pvDebug(2,QString(ret?"success\n":"failure\n")); 113 pvDebug(2,QString(ret?"success\n":"failure\n"));
112 return ret; 114 return ret;
113} 115}
114 116
115void PmIpkg::makeLinks(Package *pack) 117void PmIpkg::makeLinks(Package *pack)
116{ 118{
117 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 119 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
118 QString pn = pack->name(); 120 QString pn = pack->name();
119 linkPackage( pack->packageName(), pack->dest() ); 121 linkPackage( pack->packageName(), pack->dest() );
120} 122}
121 123
122QStringList* PmIpkg::getList( QString packFileName, QString d ) 124QStringList* PmIpkg::getList( QString packFileName, QString d )
123{ 125{
124 QString dest = settings->getDestinationUrlByName( d ); 126 QString dest = settings->getDestinationUrlByName( d );
125 dest = dest==""?d:dest; 127 dest = dest==""?d:dest;
126 // if (dest == "/" ) return 0; 128 // if (dest == "/" ) return 0;
127 { 129 {
128 Config cfg( "oipkg", Config::User ); 130 Config cfg( "oipkg", Config::User );
129 cfg.setGroup( "Common" ); 131 cfg.setGroup( "Common" );
130 QString statusDir = cfg.readEntry( "statusDir", "" ); 132 QString statusDir = cfg.readEntry( "statusDir", "" );
131 } 133 }
132 QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; 134 QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list";
133 QFile f( packFileDir ); 135 QFile f( packFileDir );
134 qDebug("Try to open %s", packFileDir.latin1()); 136 qDebug("Try to open %s", packFileDir.latin1());
135 if ( ! f.open(IO_ReadOnly) ) 137 if ( ! f.open(IO_ReadOnly) )
136 { 138 {
137 out( "Could not open:\n"+packFileDir ); 139 out( "Could not open:\n"+packFileDir );
138 f.close(); 140 f.close();
139 packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; 141 packFileDir = "/"+statusDir+"/info/"+packFileName+".list";
140 f.setName( packFileDir ); 142 f.setName( packFileDir );
141 qDebug("Try to open %s", packFileDir.latin1()); 143 qDebug("Try to open %s", packFileDir.latin1());
142 if ( ! f.open(IO_ReadOnly) ) 144 if ( ! f.open(IO_ReadOnly) )
143 { 145 {
144 qDebug(" Panik! Could not open"+packFileDir); 146 qDebug(" Panik! Could not open"+packFileDir);
145 out( "Could not open:\n"+packFileDir+"\n Panik!" ); 147 out( "Could not open:\n"+packFileDir+"\n Panik!" );
146 return (QStringList*)0; 148 return (QStringList*)0;
147 } 149 }
148 } 150 }
149 QStringList *fileList = new QStringList(); 151 QStringList *fileList = new QStringList();
150 QTextStream t( &f ); 152 QTextStream t( &f );
151 while ( !t.eof() ) 153 while ( !t.eof() )
152 { 154 {
153 *fileList += t.readLine(); 155 *fileList += t.readLine();
154 } 156 }
155 f.close(); 157 f.close();
156 return fileList; 158 return fileList;
157} 159}
158 160
159void PmIpkg::linkPackage( QString packFileName, QString dest ) 161void PmIpkg::linkPackage( QString packFileName, QString dest )
160{ 162{
161 if (dest == "root" || dest == "/" ) return; 163 if (dest == "root" || dest == "/" ) return;
162 QStringList *fileList = getList( packFileName, dest ); 164 QStringList *fileList = getList( packFileName, dest );
163 processFileList( fileList, dest ); 165 processFileList( fileList, dest );
164 delete fileList; 166 delete fileList;
165} 167}
166 168
167void PmIpkg::processFileList( QStringList *fileList, QString d ) 169void PmIpkg::processFileList( QStringList *fileList, QString d )
168{ 170{
169 if (!fileList || fileList->isEmpty()) return; 171 if (!fileList || fileList->isEmpty()) return;
170 for (uint i=0; i < fileList->count(); i++) 172 for (uint i=0; i < fileList->count(); i++)
171 { 173 {
172 QString dest = settings->getDestinationUrlByName( d ); 174 QString dest = settings->getDestinationUrlByName( d );
173 dest = dest==""?d:dest; 175 dest = dest==""?d:dest;
174 processLinkDir( (*fileList)[i], dest ); 176 processLinkDir( (*fileList)[i], dest );
175 } 177 }
176} 178}
177 179
178 180
179void PmIpkg::processLinkDir( QString file, QString dest ) 181void PmIpkg::processLinkDir( QString file, QString dest )
180{ 182{
181 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); 183 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
182 if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); 184 if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
183 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); 185 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
184 if ( dest == "???" || dest == "" ) return; 186 if ( dest == "???" || dest == "" ) return;
185 QString destFile = file; 187 QString destFile = file;
186 file = dest+"/"+file; 188 file = dest+"/"+file;
187 if (file == dest) return; 189 if (file == dest) return;
188// if (linkOpp==createLink) out( "\ncreating links\n" ); 190// if (linkOpp==createLink) out( "\ncreating links\n" );
189 // if (linkOpp==removeLink) out( "\nremoving links\n" ); 191 // if (linkOpp==removeLink) out( "\nremoving links\n" );
190 QFileInfo fileInfo( file ); 192 QFileInfo fileInfo( file );
191 if ( fileInfo.isDir() ) 193 if ( fileInfo.isDir() )
192 { 194 {
193 pvDebug(4, "process dir "+file); 195 pvDebug(4, "process dir "+file);
194 QDir destDir( destFile ); 196 QDir destDir( destFile );
195 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 197 if (linkOpp==createLink) destDir.mkdir( destFile, true );
196 QDir d( file ); 198 QDir d( file );
197// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 199// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
198 const QFileInfoList *list = d.entryInfoList(); 200 const QFileInfoList *list = d.entryInfoList();
199 QFileInfoListIterator it( *list ); 201 QFileInfoListIterator it( *list );
200 QFileInfo *fi; 202 QFileInfo *fi;
201 while ( (fi=it.current()) ) 203 while ( (fi=it.current()) )
202 { 204 {
203 pvDebug(4, "processLinkDir "+fi->absFilePath()); 205 pvDebug(4, "processLinkDir "+fi->absFilePath());
204 processLinkDir( fi->absFilePath(), dest ); 206 processLinkDir( fi->absFilePath(), dest );
205 ++it; 207 ++it;
206 } 208 }
207 } else 209 } else
208 if ( fileInfo.isFile() ) 210 if ( fileInfo.isFile() )
209 { 211 {
210 const char *instFile = strdup( (file).latin1() ); 212 const char *instFile = strdup( (file).latin1() );
211 const char *linkFile = strdup( (destFile).latin1()); 213 const char *linkFile = strdup( (destFile).latin1());
212 if( linkOpp==createLink ) 214 if( linkOpp==createLink )
213 { 215 {
214 pvDebug(4, "linking: "+file+" -> "+destFile ); 216 pvDebug(4, "linking: "+file+" -> "+destFile );
215 symlink( instFile, linkFile ); 217 symlink( instFile, linkFile );
216 } 218 }
217 } else { 219 } else {
218 const char *linkFile = strdup( (destFile).latin1()); 220 const char *linkFile = strdup( (destFile).latin1());
219 if( linkOpp==removeLink ) 221 if( linkOpp==removeLink )
220 { 222 {
221 QFileInfo toRemoveLink( destFile ); 223 QFileInfo toRemoveLink( destFile );
222 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 224 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
223 { 225 {
224 pvDebug(4,"removing "+destFile+" no "+file); 226 pvDebug(4,"removing "+destFile+" no "+file);
225 unlink( linkFile ); 227 unlink( linkFile );
226 } 228 }
227 } 229 }
228 } 230 }
229} 231}
230 232
231void PmIpkg::loadList( PackageList *pl ) 233void PmIpkg::loadList( PackageList *pl )
232 { 234 {
233 for( Package *pack = pl->first();pack ; (pack = pl->next()) ) 235 for( Package *pack = pl->first();pack ; (pack = pl->next()) )
234 { 236 {
235 if ( pack && (pack->name() != "") && pack) 237 if ( pack && (pack->name() != "") && pack)
236 { 238 {
237 if ( pack->toInstall() ) 239 if ( pack->toInstall() )
238 to_install.append( pack ); 240 to_install.append( pack );
239 if ( pack->toRemove() ) 241 if ( pack->toRemove() )
240 to_remove.append( pack ); 242 to_remove.append( pack );
241 } 243 }
242 } 244 }
243} 245}
244 246
245void PmIpkg::commit() 247void PmIpkg::commit()
246 { 248 {
247 int sizecount = 0; 249 int sizecount = 0;
248 installDialog = new InstallDialog(settings,0,0,true); 250 installDialog = new InstallDialog(settings,0,0,true);
249 installDialog->toRemoveItem->setOpen( true ); 251 installDialog->toRemoveItem->setOpen( true );
250 installDialog->toInstallItem->setOpen( true ); 252 installDialog->toInstallItem->setOpen( true );
251 for (uint i=0; i < to_remove.count(); i++) 253 for (uint i=0; i < to_remove.count(); i++)
252 { 254 {
253 sizecount += 1; 255 sizecount += 1;
254 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); 256 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
255 } 257 }
256 for (uint i=0; i < to_install.count(); i++) 258 for (uint i=0; i < to_install.count(); i++)
257 { 259 {
258 sizecount += to_install.at(i)->size().toInt(); 260 sizecount += to_install.at(i)->size().toInt();
259 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); 261 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
260 } 262 }
261 runwindow->progress->setTotalSteps(sizecount); 263 runwindow->progress->setTotalSteps(sizecount);
262 qDebug("Install size %i",sizecount); 264 qDebug("Install size %i",sizecount);
263 installDialog->showMaximized(); 265 installDialog->showMaximized();
264 installDialog->show(); 266 installDialog->show();
265 if ( installDialog->exec() ) 267 if ( installDialog->exec() )
266 { 268 {
267 doIt(); 269 doIt();
268 runwindow->showMaximized(); 270 runwindow->showMaximized();
269 runwindow->show(); 271 runwindow->show();
270 } 272 }
271 installDialog->close(); 273 installDialog->close();
272 delete installDialog; 274 delete installDialog;
273 installDialog = 0; 275 installDialog = 0;
274 out(tr("\nAll done.")); 276 out(tr("\nAll done."));
275} 277}
276 278
277void PmIpkg::doIt() 279void PmIpkg::doIt()
278{ 280{
279 runwindow->progress->setProgress(0); 281 runwindow->progress->setProgress(0);
280 show(); 282 show();
281 remove(); 283 remove();
282 install(); 284 install();
283} 285}
284 286
285 287
286void PmIpkg::remove() 288void PmIpkg::remove()
287{ 289{
288 if ( to_remove.count() == 0 ) return; 290 if ( to_remove.count() == 0 ) return;
289 291
290 out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); 292 out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
291 293
292 QStringList *fileList; 294 QStringList *fileList;
293 for (uint i=0; i < to_remove.count(); i++) 295 for (uint i=0; i < to_remove.count(); i++)
294 { 296 {
295 if ( to_remove.at(i)->link() ) fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); 297 if ( to_remove.at(i)->link() ) fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
296 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) 298 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() ))
297 { 299 {
298 runwindow->progress->setProgress( 1 ); 300 runwindow->progress->setProgress( 1 );
299 linkOpp = removeLink; 301 linkOpp = removeLink;
300 to_remove.at(i)->processed(); 302 to_remove.at(i)->processed();
301 pvDebug(3,"link "+QString::number(i)); 303 pvDebug(3,"link "+QString::number(i));
302 if ( to_remove.at(i)->link() ) 304 if ( to_remove.at(i)->link() )
303 processFileList( fileList, to_remove.at(i)->dest() ); 305 processFileList( fileList, to_remove.at(i)->dest() );
304 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); 306 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count()));
305 //if ( to_remove.at(i) ) to_remove.take( i ); 307 //if ( to_remove.at(i) ) to_remove.take( i );
306 308
307 out("\n"); 309 out("\n");
308 }else{ 310 }else{
309 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); 311 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n");
310 if ( to_remove.at(i)->link() ) 312 if ( to_remove.at(i)->link() )
311 processFileList( fileList, to_remove.at(i)->dest() ); 313 processFileList( fileList, to_remove.at(i)->dest() );
312 } 314 }
313 if ( to_remove.at(i)->link() ) 315 if ( to_remove.at(i)->link() )
314 processFileList( fileList, to_remove.at(i)->dest() ); 316 processFileList( fileList, to_remove.at(i)->dest() );
315 if ( to_remove.at(i)->link() )delete fileList; 317 if ( to_remove.at(i)->link() )delete fileList;
316 } 318 }
317 to_remove.clear(); 319 to_remove.clear();
318 out("\n"); 320 out("\n");
319} 321}
320 322
321 323
322void PmIpkg::install() 324void PmIpkg::install()
323{ 325{
324 if ( to_install.count() == 0 ) return; 326 if ( to_install.count() == 0 ) return;
325 out(tr("Installing")+"\n"+tr("please wait")+"\n"); 327 out(tr("Installing")+"\n"+tr("please wait")+"\n");
326 for (uint i=0; i < to_install.count(); i++) 328 for (uint i=0; i < to_install.count(); i++)
327 { 329 {
328 qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug 330 qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug
329 if (to_install.at(i)->link()) 331 if (to_install.at(i)->link())
330 { 332 {
331 // hack to have package.list 333 // hack to have package.list
332 // in "dest"/usr/lib/ipkg/info/ 334 // in "dest"/usr/lib/ipkg/info/
333 QString rds = settings->getDestinationUrlByName("root"); 335 QString rds = settings->getDestinationUrlByName("root");
334 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); 336 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest());
335 QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; 337 QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list";
336 rds += listFile; 338 rds += listFile;
337 lds += listFile; 339 lds += listFile;
338 const char *rd = rds.latin1(); 340 const char *rd = rds.latin1();
339 const char *ld = lds.latin1(); 341 const char *ld = lds.latin1();
340 pvDebug(4, "linking: "+rds+" -> "+lds ); 342 pvDebug(4, "linking: "+rds+" -> "+lds );
341 symlink( rd, ld ); 343 symlink( rd, ld );
342 } 344 }
343 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) 345 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
344 { 346 {
345 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); 347 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
346 to_install.at(i)->processed(); 348 to_install.at(i)->processed();
347 linkOpp = createLink; 349 linkOpp = createLink;
348 if ( to_install.at(i)->link() ) 350 if ( to_install.at(i)->link() )
349 makeLinks( to_install.at(i) ); 351 makeLinks( to_install.at(i) );
350 // to_install.take( i ); 352 // to_install.take( i );
351 out("\n"); 353 out("\n");
352 }else{ 354 }else{
353 out(tr("Error while installing")+to_install.at(i)->name()+"\n"); 355 out(tr("Error while installing")+to_install.at(i)->name()+"\n");
354 linkOpp = createLink; 356 linkOpp = createLink;
355 if ( to_install.at(i)->link() ) 357 if ( to_install.at(i)->link() )
356 makeLinks( to_install.at(i) ); 358 makeLinks( to_install.at(i) );
357 } 359 }
358 } 360 }
359 out("\n"); 361 out("\n");
360 to_install.clear(); 362 to_install.clear();
361} 363}
362 364
363void PmIpkg::createLinks( const QString &dest ) 365void PmIpkg::createLinks( const QString &dest )
364{ 366{
365 pvDebug(2,"PmIpkg::createLinks "+dest); 367 pvDebug(2,"PmIpkg::createLinks "+dest);
366 linkOpp=createLink; 368 linkOpp=createLink;
367 QString url = settings->getDestinationUrlByName( dest ); 369 QString url = settings->getDestinationUrlByName( dest );
368 url = url==""?dest:url; 370 url = url==""?dest:url;
369 processLinkDir( "/opt", url ); 371 processLinkDir( "/opt", url );
370 processLinkDir( "/usr", url ); 372 processLinkDir( "/usr", url );
371} 373}
372 374
373void PmIpkg::removeLinks( const QString &dest ) 375void PmIpkg::removeLinks( const QString &dest )
374{ 376{
375 pvDebug(2,"PmIpkg::removeLinks "+dest); 377 pvDebug(2,"PmIpkg::removeLinks "+dest);
376 linkOpp=removeLink; 378 linkOpp=removeLink;
377 QString url = settings->getDestinationUrlByName( dest ); 379 QString url = settings->getDestinationUrlByName( dest );
378 url = url==""?dest:url; 380 url = url==""?dest:url;
379 processLinkDir( "/opt", url ); 381 processLinkDir( "/opt", url );
380 processLinkDir( "/usr", url ); 382 processLinkDir( "/usr", url );
381} 383}
382 384
383void PmIpkg::update() 385void PmIpkg::update()
384{ 386{
385 show(); 387 show();
386 runIpkg( "update" ); 388 runIpkg( "update" );
387} 389}
388 390
389void PmIpkg::out( QString o ) 391void PmIpkg::out( QString o )
390{ 392{
391 //runwindow->outPut->append(o); 393 //runwindow->outPut->append(o);
392 runwindow->outPut->setText(runwindow->outPut->text()+o); 394 runwindow->outPut->setText(runwindow->outPut->text()+o);
393 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); 395 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
394} 396}
395 397
396 398
397 399
398 400
399void PmIpkg::show() 401void PmIpkg::show()
400{ 402{
401 if (!runwindow->isVisible()) 403 if (!runwindow->isVisible())
402 { 404 {
403 runwindow->showMaximized(); 405 runwindow->showMaximized();
404 runwindow->show(); 406 runwindow->show();
405 } 407 }
406 runwindow->outPut->setText(""); 408 runwindow->outPut->setText("");
407} 409}
408 410
409void PmIpkg::installFile(const QString &fileName, const QString &dest) 411void PmIpkg::installFile(const QString &fileName, const QString &dest)
410{ 412{
411 413
412 to_install.clear(); 414 to_install.clear();
413 to_remove.clear(); 415 to_remove.clear();
414 pvDebug( 2,"PmIpkg::installFile "+ fileName); 416 pvDebug( 2,"PmIpkg::installFile "+ fileName);
415 Package *p = new Package(fileName,settings); 417 Package *p = new Package(fileName,settings);
416 if ( dest!="") p->setDest( dest ); 418 if ( dest!="") p->setDest( dest );
417 to_install.append( p ); 419 to_install.append( p );
418 commit(); 420 commit();
419 delete p; 421 delete p;
420} 422}
421 423
422void PmIpkg::removeFile(const QString &fileName, const QString &dest) 424void PmIpkg::removeFile(const QString &fileName, const QString &dest)
423{ 425{
424 426
425 to_install.clear(); 427 to_install.clear();
426 to_remove.clear(); 428 to_remove.clear();
427 pvDebug( 2,"PmIpkg::removeFile "+ fileName); 429 pvDebug( 2,"PmIpkg::removeFile "+ fileName);
428 Package *p = new Package(fileName,settings); 430 Package *p = new Package(fileName,settings);
429 if ( dest!="") p->setDest( dest ); 431 if ( dest!="") p->setDest( dest );
430 to_remove.append( p ); 432 to_remove.append( p );
431 commit(); 433 commit();
432 delete p; 434 delete p;
433} 435}
434 436
435 437
436void PmIpkg::clearLists() 438void PmIpkg::clearLists()
437{ 439{
438 to_remove.clear(); 440 to_remove.clear();
439 to_install.clear(); 441 to_install.clear();
440} 442}
441 443
442 444