summaryrefslogtreecommitdiff
path: root/core/symlinker
authorar <ar>2004-05-02 17:31:50 (UTC)
committer ar <ar>2004-05-02 17:31:50 (UTC)
commita210b9a597ba0c929d95c38ffbaf972916c7b8a7 (patch) (side-by-side diff)
treece121d5017eb054222c86e0afb6057a28ea7bf8a /core/symlinker
parent18759e9156c96795831120408a9da0d3b4ec71a4 (diff)
downloadopie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.zip
opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.gz
opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.bz2
- convert qDebug to odebug
Diffstat (limited to 'core/symlinker') (more/less context) (ignore whitespace changes)
-rw-r--r--core/symlinker/main.cpp220
-rw-r--r--core/symlinker/symlinker.pro18
2 files changed, 122 insertions, 116 deletions
diff --git a/core/symlinker/main.cpp b/core/symlinker/main.cpp
index 6a04980..96e7f3c 100644
--- a/core/symlinker/main.cpp
+++ b/core/symlinker/main.cpp
@@ -1,3 +1,8 @@
+
+/* OPIE */
+#include <opie2/odebug.h>
+
+/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qfileinfo.h>
@@ -5,8 +10,9 @@
#include <qtextstream.h>
#include <qstringlist.h>
+/* STD */
#include <stdlib.h>
-#include <unistd.h> //symlink()
+#include <unistd.h> //symlink()
#include <sys/stat.h> // mkdir()
#include <sys/vfs.h>
@@ -24,55 +30,55 @@ static void createSymlinks( const QString &location, const QString &package )
QFile outFile( listDir + package + ".list");
-// qDebug( "createSymlinks %s -> %s", inFile.name().ascii(), outFile.name().ascii() );
-
-
-
- if ( inFile.open(IO_ReadOnly) && outFile.open(IO_WriteOnly)) {
- QTextStream in(&inFile);
- QTextStream out(&outFile);
-
- QString s;
- while ( !in.eof() ) { // until end of file...
- s = in.readLine(); // line of text excluding '\n'
-// qDebug( "Read: %s", s.ascii() );
- if (s.find(location,0,true) >= 0){
-// qDebug( "Found!" );
- s = s.replace(location,"");
- }
-// qDebug( "Read after: %s", s.ascii() );
-
- // for s, do link/mkdir.
- if ( s.right(1) == "/" ) {
-// qDebug("do mkdir for %s", s.ascii());
- mkdir( s.ascii(), 0777 );
- //possible optimization: symlink directories
- //that don't exist already. -- Risky.
- } else {
-// qDebug("do symlink for %s", s.ascii());
- QFileInfo ffi( s );
- //Don't try to symlink if a regular file exists already
- if ( !ffi.exists() || ffi.isSymLink() ) {
- if (symlink( (location+s).ascii(), s.ascii() ) != 0){
- if (errno == ENOENT){
-// perror("Symlink Failed! ");
- QString e=s.ascii();
- e = e.replace(ffi.fileName(),"");
-// qDebug("DirName : %s",e.ascii() );
- system ( QString("mkdir -p ")+e.ascii() );
- if (symlink( (location+s).ascii(), s.ascii() ) != 0)
- qDebug ("Big problem creating symlink and directory");
- }
- }
-// qDebug ( "Created %s" ,s.ascii() );
- out << s << "\n";
- } else {
- qDebug( "%s exists already, not symlinked", s.ascii() );
- }
- }
- }
- inFile.close();
- outFile.close();
+// odebug << "createSymlinks " << inFile.name().ascii() << " -> " << outFile.name().ascii() << "" << oendl;
+
+
+
+ if ( inFile.open(IO_ReadOnly) && outFile.open(IO_WriteOnly)) {
+ QTextStream in(&inFile);
+ QTextStream out(&outFile);
+
+ QString s;
+ while ( !in.eof() ) { // until end of file...
+ s = in.readLine(); // line of text excluding '\n'
+// odebug << "Read: " << s.ascii() << "" << oendl;
+ if (s.find(location,0,true) >= 0){
+// odebug << "Found!" << oendl;
+ s = s.replace(location,"");
+ }
+// odebug << "Read after: " << s.ascii() << "" << oendl;
+
+ // for s, do link/mkdir.
+ if ( s.right(1) == "/" ) {
+// odebug << "do mkdir for " << s.ascii() << "" << oendl;
+ mkdir( s.ascii(), 0777 );
+ //possible optimization: symlink directories
+ //that don't exist already. -- Risky.
+ } else {
+// odebug << "do symlink for " << s.ascii() << "" << oendl;
+ QFileInfo ffi( s );
+ //Don't try to symlink if a regular file exists already
+ if ( !ffi.exists() || ffi.isSymLink() ) {
+ if (symlink( (location+s).ascii(), s.ascii() ) != 0){
+ if (errno == ENOENT){
+// perror("Symlink Failed! ");
+ QString e=s.ascii();
+ e = e.replace(ffi.fileName(),"");
+// odebug << "DirName : " << e.ascii() << "" << oendl;
+ system ( QString("mkdir -p ")+e.ascii() );
+ if (symlink( (location+s).ascii(), s.ascii() ) != 0)
+ odebug << "Big problem creating symlink and directory" << oendl;
+ }
+ }
+// qDebug ( "Created %s" ,s.ascii() );
+ out << s << "\n";
+ } else {
+ odebug << "" << s.ascii() << " exists already, not symlinked" << oendl;
+ }
+ }
+ }
+ inFile.close();
+ outFile.close();
}
}
@@ -82,24 +88,24 @@ static void removeSymlinks( const QString &package )
{
QFile inFile( listDir + package + ".list" );
- if ( inFile.open(IO_ReadOnly) ) {
- QTextStream in(&inFile);
-
- QString s;
- while ( !in.eof() ) { // until end of file...
- s = in.readLine(); // line of text excluding '\n'
-// qDebug("remove symlink %s", s.ascii());
- QFileInfo ffi( s );
- //Confirm that it's still a symlink.
- if ( ffi.isSymLink() ){
- unlink( s.ascii() );
-// qDebug ( "Removed %s", s.ascii() );}
-// else
-// qDebug( "Not removed %s", s.ascii() );
- }
- }
- inFile.close();
- inFile.remove();
+ if ( inFile.open(IO_ReadOnly) ) {
+ QTextStream in(&inFile);
+
+ QString s;
+ while ( !in.eof() ) { // until end of file...
+ s = in.readLine(); // line of text excluding '\n'
+// odebug << "remove symlink " << s.ascii() << "" << oendl;
+ QFileInfo ffi( s );
+ //Confirm that it's still a symlink.
+ if ( ffi.isSymLink() ){
+ unlink( s.ascii() );
+// qDebug ( "Removed %s", s.ascii() );}
+// else
+// odebug << "Not removed " << s.ascii() << "" << oendl;
+ }
+ }
+ inFile.close();
+ inFile.remove();
}
}
@@ -109,7 +115,7 @@ static void removeSymlinks( const QString &package )
Slightly hacky: we can't use StorageInfo, since we don't have a
QApplication. We look for filesystems that have the directory
/usr/lib/ipkg/info, and assume that they are removable media
- with packages installed. This is safe even if eg. /usr is on a
+ with packages installed. This is safe even if eg. /usr is on a
separate filesystem, since then we would be testing for
/usr/usr/lib/ipkg/info, which should not exist. (And if it
does they deserve to have it treated as removable.)
@@ -119,44 +125,44 @@ static void updateSymlinks()
{
QDir lists( listDir );
QStringList knownPackages = lists.entryList( "*.list" ); // No tr
-
+
struct mntent *me;
FILE *mntfp = setmntent( "/etc/mtab", "r" );
if ( mntfp ) {
- while ( (me = getmntent( mntfp )) != 0 ) {
- QString root = me->mnt_dir;
- if ( root == "/" )
- continue;
-
- QString info = root + "/usr/lib/ipkg/info";
- QDir infoDir( info );
-// qDebug( "looking at %s", info.ascii() );
- if ( infoDir.isReadable() ) {
- const QFileInfoList *packages = infoDir.entryInfoList( "*.list" ); // No tr
- QFileInfoListIterator it( *packages );
- QFileInfo *fi;
- while (( fi = *it )) {
- ++it;
- if ( knownPackages.contains( fi->fileName() ) ) {
-// qDebug( "found %s and we've seen it before", fi->fileName().latin1() );
- knownPackages.remove( fi->fileName() );
- } else {
- //it's a new one
- createSymlinks( root, fi->baseName() );
- }
-
- }
-
- }
- }
- endmntent( mntfp );
+ while ( (me = getmntent( mntfp )) != 0 ) {
+ QString root = me->mnt_dir;
+ if ( root == "/" )
+ continue;
+
+ QString info = root + "/usr/lib/ipkg/info";
+ QDir infoDir( info );
+// odebug << "looking at " << info.ascii() << "" << oendl;
+ if ( infoDir.isReadable() ) {
+ const QFileInfoList *packages = infoDir.entryInfoList( "*.list" ); // No tr
+ QFileInfoListIterator it( *packages );
+ QFileInfo *fi;
+ while (( fi = *it )) {
+ ++it;
+ if ( knownPackages.contains( fi->fileName() ) ) {
+// odebug << "found " << fi->fileName() << " and we've seen it before" << oendl;
+ knownPackages.remove( fi->fileName() );
+ } else {
+ //it's a new one
+ createSymlinks( root, fi->baseName() );
+ }
+
+ }
+
+ }
+ }
+ endmntent( mntfp );
}
-
- for ( QStringList::Iterator it = knownPackages.begin();
- it != knownPackages.end(); ++it ) {
- // strip ".info" off the end.
- removeSymlinks( (*it).left((*it).length()-5) );
+
+ for ( QStringList::Iterator it = knownPackages.begin();
+ it != knownPackages.end(); ++it ) {
+ // strip ".info" off the end.
+ removeSymlinks( (*it).left((*it).length()-5) );
}
}
@@ -167,13 +173,13 @@ int main( int argc, char *argv[] )
QApplication a( argc, argv, QApplication::Tty );
QString command = argc > 1 ? argv[1] : "update"; // No tr
-
+
if ( command == "update" ) // No tr
- updateSymlinks();
+ updateSymlinks();
else if ( command == "create" && argc > 3 ) // No tr
- createSymlinks( argv[2], argv[3] );
+ createSymlinks( argv[2], argv[3] );
else if ( command == "remove" && argc > 2 ) // No tr
- removeSymlinks( argv[2] );
+ removeSymlinks( argv[2] );
else
- qWarning( "Argument error" );
+ owarn << "Argument error" << oendl;
}
diff --git a/core/symlinker/symlinker.pro b/core/symlinker/symlinker.pro
index f850d46..50ad785 100644
--- a/core/symlinker/symlinker.pro
+++ b/core/symlinker/symlinker.pro
@@ -1,15 +1,15 @@
-TEMPLATE = app
-CONFIG += qt warn_on
-DESTDIR = $(OPIEDIR)/bin
+TEMPLATE = app
+CONFIG += qt warn_on
+DESTDIR = $(OPIEDIR)/bin
-HEADERS =
-SOURCES = main.cpp
-INTERFACES =
+HEADERS =
+SOURCES = main.cpp
+INTERFACES =
-TARGET = opie-update-symlinks
-INCLUDEPATH += $(OPIEDIR)/include
+TARGET = opie-update-symlinks
+INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include .
-LIBS += -lqpe
+LIBS += -lqpe -lopiecore2
include ( $(OPIEDIR)/include.pro )