Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

files-app does not compile on OSX #30

Open
nbigaouette opened this issue Nov 11, 2015 · 6 comments
Open

files-app does not compile on OSX #30

nbigaouette opened this issue Nov 11, 2015 · 6 comments

Comments

@nbigaouette
Copy link

nbigaouette commented Nov 11, 2015

There seems to be a mount helper included in files-app but this is not supported under OSX.

Trying to compile it I get the following error:

make
[  2%] Built target translations
[  5%] Automatic moc for target folderlistmodel
[  5%] Built target folderlistmodel_automoc
[ 62%] Built target folderlistmodel
[ 65%] Automatic moc for target PlacesModel
[ 65%] Built target PlacesModel_automoc
[ 67%] Building CXX object src/plugin/placesmodel/CMakeFiles/PlacesModel.dir/qmtabparser.cpp.o
files-app.git/src/plugin/placesmodel/qmtabparser.cpp:22:10: fatal error: 'mntent.h'
      file not found
#include <mntent.h>
         ^
1 error generated.
make[2]: *** [src/plugin/placesmodel/CMakeFiles/PlacesModel.dir/qmtabparser.cpp.o] Error 1
make[1]: *** [src/plugin/placesmodel/CMakeFiles/PlacesModel.dir/all] Error 2
make: *** [all] Error 2

I simply deleted everything related to mtab for files-app to compile:

diff --git a/src/plugin/placesmodel/CMakeLists.txt b/src/plugin/placesmodel/CMakeLists.txt
index 5db402e..69240dd 100644
--- a/src/plugin/placesmodel/CMakeLists.txt
+++ b/src/plugin/placesmodel/CMakeLists.txt
@@ -9,8 +9,6 @@ set(placesmodel_SRCS
     placesmodel.h
     placesmodel_plugin.cpp
     placesmodel_plugin.h
-    qmtabparser.h
-    qmtabparser.cpp
 )

 add_library(PlacesModel MODULE
@@ -34,4 +32,3 @@ endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
 # Install plugin file
 install(TARGETS PlacesModel DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
 install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN_DIR})
-
diff --git a/src/plugin/placesmodel/placesmodel.cpp b/src/plugin/placesmodel/placesmodel.cpp
index 0e8aed6..a5ade52 100644
--- a/src/plugin/placesmodel/placesmodel.cpp
+++ b/src/plugin/placesmodel/placesmodel.cpp
@@ -62,7 +62,6 @@ PlacesModel::PlacesModel(QObject *parent) :
     }

     initNewUserMountsWatcher();
-    rescanMtab();
 }

 PlacesModel::~PlacesModel() {
@@ -73,77 +72,7 @@ void
 PlacesModel::initNewUserMountsWatcher() {
     m_newUserMountsWatcher = new QFileSystemWatcher(this);

-    qDebug() << Q_FUNC_INFO << "Start watching mtab file for new mounts" << m_mtabParser.path();
-
-    m_newUserMountsWatcher->addPath(m_mtabParser.path());
-
-    connect(m_newUserMountsWatcher, &QFileSystemWatcher::fileChanged, this, &PlacesModel::mtabChanged);
-}
-
-void
-PlacesModel::mtabChanged(const QString &path) {
-    qDebug() << Q_FUNC_INFO << "file changed in " << path;
-    rescanMtab();
-    // Since old mtab file is replaced with new contents, must readd filesystem watcher
-    m_newUserMountsWatcher->removePath(path);
-    m_newUserMountsWatcher->addPath(path);
-}
-
-void
-PlacesModel::rescanMtab() {
-    const QString& path = m_mtabParser.path();
-    qDebug() << Q_FUNC_INFO << "rescanning mtab" << path;
-
-    QList<QMtabEntry> entries = m_mtabParser.parseEntries();
-
-    QSet<QString> userMounts;
-
-    foreach (QMtabEntry e, entries) {
-        qDebug() << Q_FUNC_INFO << "Considering" << "fsName:" <<  e.fsName << "dir:" << e.dir << "type:" << e.type;
-        if (isMtabEntryUserMount(e)) {
-            qDebug() << Q_FUNC_INFO << "Adding as userMount directory dir" << e.dir;
-            userMounts << e.dir;
-        }
-    }
-
-    QSet<QString> addedMounts = QSet<QString>(userMounts).subtract(m_userMounts);
-    QSet<QString> removedMounts = QSet<QString>(m_userMounts).subtract(userMounts);
-
-    m_userMounts = userMounts;
-
-    foreach (QString addedMount, addedMounts) {
-        qDebug() << Q_FUNC_INFO << "user mount added: " << addedMount;
-        addLocationWithoutStoring(addedMount);
-        emit userMountAdded(addedMount);
-    }
-
-    foreach (QString removedMount, removedMounts) {
-        qDebug() << Q_FUNC_INFO << "user mount removed: " << removedMount;
-        int index = m_locations.indexOf(removedMount);
-        if (index > -1) {
-            removeItemWithoutStoring(index);
-        }
-        emit userMountRemoved(removedMount);
-    }
-}
-
-bool PlacesModel::isMtabEntryUserMount(const QMtabEntry &e) const {
-    if (e.fsName == "none") {
-        qDebug() << Q_FUNC_INFO << "Ignoring mounts with filesystem name 'none'";
-        return false;
-    }
-    if (isSubDirectory(m_userMountLocation, e.dir)) {
-        qDebug() << Q_FUNC_INFO << "Is user mount location";
-        return true;
-    }
-    foreach (const QString &runtimeLocation, m_runtimeLocations) {
-        if (isSubDirectory(runtimeLocation, e.dir)) {
-            qDebug() << Q_FUNC_INFO << "Is user mount location";
-            return true;
-        }
-    }
-
-    return false;
+    qDebug() << Q_FUNC_INFO << "mtab disabled on OSX";
 }

 bool PlacesModel::isSubDirectory(const QString &dir, const QString &path) const {
diff --git a/src/plugin/placesmodel/placesmodel.h b/src/plugin/placesmodel/placesmodel.h
index 56156eb..3c1560f 100644
--- a/src/plugin/placesmodel/placesmodel.h
+++ b/src/plugin/placesmodel/placesmodel.h
@@ -28,8 +28,6 @@
 #include <QTimer>
 #include <QSet>

-#include "qmtabparser.h"
-
 class PlacesModel : public QAbstractListModel
 {
     Q_OBJECT
@@ -65,10 +63,6 @@ public slots:
         return m_userMounts.contains(location);
     }

-private slots:
-    void mtabChanged(const QString &path);
-    void rescanMtab();
-
 private:
     void initNewUserMountsWatcher();
     // Returns true if location was not known before, and false if it was known
@@ -76,10 +70,8 @@ private:
     // Returns true if location was not known before, and false if it was known
     void removeItemWithoutStoring(int itemToRemove);

-    QMtabParser m_mtabParser;
     QStringList m_runtimeLocations;
     QString m_userMountLocation;
-    bool isMtabEntryUserMount(const QMtabEntry &entry) const;
     bool isSubDirectory(const QString &dir, const QString &path) const;
     QString standardLocation(QStandardPaths::StandardLocation location) const;
     QStringList m_locations;
@@ -89,6 +81,3 @@ private:
 };

 #endif // PLACESMODEL_H
-
-
-
diff --git a/src/plugin/placesmodel/qmtabparser.cpp b/src/plugin/placesmodel/qmtabparser.cpp
deleted file mode 100644
index 99fe6c0..0000000
--- a/src/plugin/placesmodel/qmtabparser.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Author : Arto Jalkanen <[email protected]>
- *          Carlos J Mazieri <[email protected]>
- */
-
-#include <qmtabparser.h>
-
-#include <mntent.h>
-
-#include <QFileInfo>
-#include <QStringList>
-
-class MtabFileGuard {
-    FILE *mtabFile;
-
-public:
-    MtabFileGuard(FILE *f) {
-        mtabFile = f;
-    }
-    ~MtabFileGuard() {
-        endmntent(mtabFile);
-    }
-};
-
-QMtabParser::QMtabParser(const QString& path, QObject *parent)
-    : QObject(parent) {
-    m_path = path.isEmpty() ? _PATH_MOUNTED : path;
-}
-
-QMtabParser::~QMtabParser() {}
-
-QList<QMtabEntry>
-QMtabParser::parseEntries() {
-    QList<QMtabEntry> entries;
-
-    FILE *f = setmntent(m_path.toLocal8Bit().data(), "r");
-    if (f == 0) {
-        return entries;
-    }
-
-    MtabFileGuard guard(f);
-
-    struct mntent entStorage;
-    char buffer[1024];
-    while (mntent *ent = getmntent_r(f, &entStorage, buffer, 1024)) {
-        QMtabEntry entry;
-        entry.fsName = ent->mnt_fsname;
-        entry.dir = ent->mnt_dir;
-        entry.type = ent->mnt_type;
-        entry.opts = ent->mnt_opts;
-        entry.freq = ent->mnt_freq;
-        entry.passno = ent->mnt_passno;
-        entries << entry;
-    }
-
-    return entries;
-}
diff --git a/src/plugin/placesmodel/qmtabparser.h b/src/plugin/placesmodel/qmtabparser.h
deleted file mode 100644
index 82aa1c4..0000000
--- a/src/plugin/placesmodel/qmtabparser.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2015 Canonical Ltd
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Author : Arto Jalkanen <[email protected]>
- *          Carlos J Mazieri <[email protected]>
- */
-
-#ifndef QMTABPARSER_H
-#define QMTABPARSER_H
-
-#include <QObject>
-
-struct QMtabEntry {
-    QString fsName;
-    QString dir;
-    QString type;
-    QString opts;
-    int freq;
-    int passno;
-};
-
-class QMtabParser : public QObject
-{
-    Q_OBJECT
-    QString m_path;
-
-public:
-    explicit QMtabParser(const QString& path = QString(), QObject *parent = 0);
-    ~QMtabParser();
-
-    QList<QMtabEntry> parseEntries();
-
-    inline const QString& path() { return m_path; }
-};
-
-#endif // QMTABPARSER_H
-
-
-

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28146361-files-app-does-not-compile-on-osx?utm_campaign=plugin&utm_content=tracker%2F12543815&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12543815&utm_medium=issues&utm_source=github).
@dcfranca
Copy link

Maybe it can be added a wrapper with ifdef to use getmntinfo[1] instead on OS X?
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/getmntinfo.3.html

@nbigaouette
Copy link
Author

Sure, the linux only feature should be at least isolated using #ifdefs if the app is meant to be portable to other platforms.

@dcfranca
Copy link

I'm trying to wrap the mount helper to work both on Linux and OSX, the app is compiling, but when I try to run it I receive the following error: main.qml:23 module "org.nemomobile.folderlistmodel" is not installed

Any idea how can I solve it? I already tried to add the folderlistmodel path to the QML2_IMPORT_PATH env var, but it didn't help.

@nbigaouette
Copy link
Author

I have the same problem. Actually I've never been able to run files-app, neither on linux nor osx.

On OSX, I get the following:

./src/app/papyros-files
Trying to load QML from: "/Users/path/to/files-app.git/build/src/app/qml/main.qml"
QQmlApplicationEngine failed to load component
file:///Users/path/to/files-app.git/build/src/app/qml/main.qml:23 module "io.papyros.folderlistmodel" is not installed

Might be the same error on linux (can't remember, can check tomorrow).

I think I've seen another bug report about the folderlist module missing.

Also, note that in the error above I have run papyros-files from the build dir. When installing with make install I have rpath problems:

$ /usr/local/bin/papyros-files
dyld: Library not loaded: @rpath/QtQuick.framework/Versions/5/QtQuick
  Referenced from: /usr/local/bin/papyros-files
  Reason: image not found
Trace/BPT trap: 5

from which I tried to fix using:

$ ldd /usr/local/bin/papyros-files
/usr/local/bin/papyros-files:
    @rpath/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
$ install_name_tool -change @rpath/QtQuick.framework/Versions/5/QtQuick /Users/me/Qt/5.5/clang_64/lib/QtQuick.framework/Versions/5/QtQuick /usr/local/bin/papyros-files
$ install_name_tool -change @rpath/QtGui.framework/Versions/5/QtGui /Users/me/Qt/5.5/clang_64/lib/QtGui.framework/Versions/5/QtGui /usr/local/bin/papyros-files
$ install_name_tool -change @rpath/QtQml.framework/Versions/5/QtQml /Users/me/Qt/5.5/clang_64/lib/QtQml.framework/Versions/5/QtQml /usr/local/bin/papyros-files
$ install_name_tool -change @rpath/QtNetwork.framework/Versions/5/QtNetwork /Users/me/Qt/5.5/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork /usr/local/bin/papyros-files
$ install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore /Users/me/Qt/5.5/clang_64/lib/QtCore.framework/Versions/5/QtCore /usr/local/bin/papyros-files

but then I get:

$ /usr/local/bin/papyros-files
This application failed to start because it could not find or load the Qt platform plugin "cocoa".

Available platform plugins are: cocoa, minimal, offscreen.

Reinstalling the application may fix this problem.
Abort trap: 6

@ricardomv
Copy link
Member

@nbigaouette I can't help you much because i never worked with OS X but on linux i would delete everything installed in /usr/local listed in install_manifest.txt. clean the build directory and install with the following commands.

cmake -DCMAKE_INSTALL_PREFIX=/usr ..

@DanielFranca i think the same would work for you. Specially because in current master org.nemomobile.folderlistmodel is called io.papyros.folderlistmodel

@ricardomv ricardomv reopened this Nov 16, 2015
@dcfranca
Copy link

After update my master with the current master, I could figure out how to solve this specific problem.
I'd to include the libtag again, and then fix manually the files:
folderlistmodel.dir/link.txt and CMakeFiles/folderlistmodel.dir/flags.make

Because the path for taglib includes/libs was wrong/missing in those files, so the folderlistmodel was not being compiled.

After that it was compiled, but then I got some errors trying to run files-app, errors saying that it was not finding the QtQuick libraries to load: dyld: Library not loaded: @rpath/QtQuick.framework/Versions/5/QtQuick

To fix that I copied the libraries to the executable path, following the dir structure, like:
./QtQuick.framework/Versions/5/QtQuick

But now I receive the error: This application failed to start because it could not find or load the Qt platform plugin "cocoa".

Tried to copy the cocoa lib to the structure: ./plugins/platforms/libqcocoa.dylib

No success, for now I'm done, if anyone has any other idea to make it work let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants