Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions libs/linglong/src/linglong/builder/linglong_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,11 +1854,12 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
.type = "bind",
});

QDir appCache = this->workingDir.absoluteFilePath("linglong/cache");
auto appCache = std::filesystem::path{ workingDir.absolutePath().toStdString() } / "linglong" / "cache";
std::string ldConfPath = appCache / "ld.so.conf";
applicationMounts.push_back(ocppi::runtime::config::types::Mount{
.destination = "/etc/ld.so.conf.d/zz_deepin-linglong-app.conf",
.options = { { "rbind", "ro" } },
.source = appCache.absoluteFilePath("ld.so.conf").toStdString(),
.source = ldConfPath,
.type = "bind",
});

Expand All @@ -1874,13 +1875,25 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
return LINGLONG_ERR(res);
}
cfgBuilder.setAppId(curRef->id.toStdString())
.setAppCache(appCache.absolutePath().toStdString(), false)
.setAppCache(appCache, false)
.addUIdMapping(uid, uid, 1)
.addGIdMapping(gid, gid, 1)
.bindDefault()
.addExtraMounts(applicationMounts)
.enableSelfAdjustingMount();

// write ld.so.conf
std::string triplet = curRef->arch.getTriplet().toStdString();
std::string ldRawConf = cfgBuilder.ldConf(triplet);

QFile ldsoconf{ ldConfPath.c_str() };
if (!ldsoconf.open(QIODevice::WriteOnly)) {
return LINGLONG_ERR(ldsoconf);
}
ldsoconf.write(ldRawConf.c_str());
// must be closed here, this conf will be used later.
ldsoconf.close();

if (!cfgBuilder.build()) {
auto err = cfgBuilder.getError();
return LINGLONG_ERR("build cfg error: " + QString::fromStdString(err.reason));
Expand Down Expand Up @@ -1911,7 +1924,7 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
return LINGLONG_ERR(res);
}
cfgBuilder.setAppId(curRef->id.toStdString())
.setAppCache(appCache.absolutePath().toStdString())
.setAppCache(appCache)
.enableLDCache()
.addUIdMapping(uid, uid, 1)
.addGIdMapping(gid, gid, 1)
Expand Down