Skip to content

Commit 2f05e36

Browse files
committed
fix: generate ld cache before builder run
Signed-off-by: reddevillg <reddevillg@gmail.com>
1 parent fb30135 commit 2f05e36

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

libs/linglong/src/linglong/builder/linglong_builder.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,11 +1854,12 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
18541854
.type = "bind",
18551855
});
18561856

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

@@ -1874,13 +1875,25 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
18741875
return LINGLONG_ERR(res);
18751876
}
18761877
cfgBuilder.setAppId(curRef->id.toStdString())
1877-
.setAppCache(appCache.absolutePath().toStdString(), false)
1878+
.setAppCache(appCache, false)
18781879
.addUIdMapping(uid, uid, 1)
18791880
.addGIdMapping(gid, gid, 1)
18801881
.bindDefault()
18811882
.addExtraMounts(applicationMounts)
18821883
.enableSelfAdjustingMount();
18831884

1885+
// write ld.so.conf
1886+
std::string triplet = curRef->arch.getTriplet().toStdString();
1887+
std::string ldRawConf = cfgBuilder.ldConf(triplet);
1888+
1889+
QFile ldsoconf{ ldConfPath.c_str() };
1890+
if (!ldsoconf.open(QIODevice::WriteOnly)) {
1891+
return LINGLONG_ERR(ldsoconf);
1892+
}
1893+
ldsoconf.write(ldRawConf.c_str());
1894+
// must be closed here, this conf will be used later.
1895+
ldsoconf.close();
1896+
18841897
if (!cfgBuilder.build()) {
18851898
auto err = cfgBuilder.getError();
18861899
return LINGLONG_ERR("build cfg error: " + QString::fromStdString(err.reason));
@@ -1911,7 +1924,7 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
19111924
return LINGLONG_ERR(res);
19121925
}
19131926
cfgBuilder.setAppId(curRef->id.toStdString())
1914-
.setAppCache(appCache.absolutePath().toStdString())
1927+
.setAppCache(appCache)
19151928
.enableLDCache()
19161929
.addUIdMapping(uid, uid, 1)
19171930
.addGIdMapping(gid, gid, 1)

0 commit comments

Comments
 (0)