summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/symlinker/main.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/core/symlinker/main.cpp b/core/symlinker/main.cpp
index 73d5166..6a04980 100644
--- a/core/symlinker/main.cpp
+++ b/core/symlinker/main.cpp
@@ -13,2 +13,3 @@
#include <mntent.h>
+#include <errno.h>
@@ -18,2 +19,3 @@ static void createSymlinks( const QString &location, const QString &package )
{
+
QFile inFile( location + "/usr/lib/ipkg/info/" + package + ".list" );
@@ -24,3 +26,3 @@ static void createSymlinks( const QString &location, const QString &package )
- //qDebug( "createSymlinks %s -> %s", inFile.name().ascii(), outFile.name().ascii() );
+// qDebug( "createSymlinks %s -> %s", inFile.name().ascii(), outFile.name().ascii() );
@@ -35,6 +37,12 @@ static void createSymlinks( const QString &location, const QString &package )
s = in.readLine(); // line of text excluding '\n'
- //qDebug( "Read: %s", s.ascii() );
+// 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());
+// qDebug("do mkdir for %s", s.ascii());
mkdir( s.ascii(), 0777 );
@@ -43,3 +51,3 @@ static void createSymlinks( const QString &location, const QString &package )
} else {
- //qDebug("do symlink for %s", s.ascii());
+// qDebug("do symlink for %s", s.ascii());
QFileInfo ffi( s );
@@ -47,8 +55,18 @@ static void createSymlinks( const QString &location, const QString &package )
if ( !ffi.exists() || ffi.isSymLink() ) {
- symlink( (location+s).ascii(), s.ascii() );
+ 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() );
-// }
+ } else {
+ qDebug( "%s exists already, not symlinked", s.ascii() );
+ }
}
@@ -72,10 +90,11 @@ static void removeSymlinks( const QString &package )
s = in.readLine(); // line of text excluding '\n'
- //qDebug("remove symlink %s", s.ascii());
+// qDebug("remove symlink %s", s.ascii());
QFileInfo ffi( s );
//Confirm that it's still a symlink.
- if ( ffi.isSymLink() )
+ if ( ffi.isSymLink() ){
unlink( s.ascii() );
-// qDebug ( "Removed %s", s.ascii() );
-// else
+// qDebug ( "Removed %s", s.ascii() );}
+// else
// qDebug( "Not removed %s", s.ascii() );
+ }
}
@@ -114,3 +133,3 @@ static void updateSymlinks()
QDir infoDir( info );
- //qDebug( "looking at %s", info.ascii() );
+// qDebug( "looking at %s", info.ascii() );
if ( infoDir.isReadable() ) {
@@ -122,3 +141,3 @@ static void updateSymlinks()
if ( knownPackages.contains( fi->fileName() ) ) {
- //qDebug( "found %s and we've seen it before", fi->fileName().latin1() );
+// qDebug( "found %s and we've seen it before", fi->fileName().latin1() );
knownPackages.remove( fi->fileName() );