summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/symlinker/main.cpp31
1 files changed, 25 insertions, 6 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
@@ -11,11 +11,13 @@
#include <sys/vfs.h>
#include <mntent.h>
+#include <errno.h>
static const char *listDir = "/usr/lib/ipkg/externinfo/";
static void createSymlinks( const QString &location, const QString &package )
{
+
QFile inFile( location + "/usr/lib/ipkg/info/" + package + ".list" );
mkdir( "/usr/lib/ipkg", 0777 );
mkdir( listDir, 0777 );
@@ -34,6 +36,12 @@ static void createSymlinks( const QString &location, const QString &package )
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());
@@ -45,12 +53,22 @@ static void createSymlinks( const QString &location, const QString &package )
QFileInfo ffi( s );
//Don't try to symlink if a regular file exists already
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() );
+ }
}
}
inFile.close();
@@ -73,12 +91,13 @@ static void removeSymlinks( const QString &package )
//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() );
+// qDebug ( "Removed %s", s.ascii() );}
// else
// qDebug( "Not removed %s", s.ascii() );
}
+ }
inFile.close();
inFile.remove();
}