我的理解是,如果RUN命令“string”本身没有改变(即要安装的包列表没有改变),docker引擎将使用缓存中的图像进行相同的操作。这也是我的经历:
...\nStep 2/6 : RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl git-all locales locales-all python3 python3-pip python3-venv libusb-1.0-0 gosu && rm -rf /var/lib/apt/lists/*\n ---> Using cache\n ---> 518e8ff74d4c\n...\nRun Code Online (Sandbox Code Playgroud)\n然而,官方Dockerfile 最佳实践文档对 apt-get 是这样说的:
\n\n\n使用
\nRUN apt-get update && apt-get install -y可确保您的 Dockerfile 安装最新的软件包版本,无需进一步编码或手动干预。这种技术被称为\xe2\x80\x9ccachebusting\xe2\x80\x9d。
如果我向列表中添加新包,则情况如此,但如果我不修改列表,则情况并非如此。
\n我的理解正确吗,还是我在这里遗漏了一些东西?
\napt-get install如果是,我是否可以假设只有 Ubuntu 基础映像也已更新(这会使整个缓存失效)时我才会获得更新的软件包?
在写这个问题的时候,Ubuntu 22.04 已经快出来了。我很好奇开发人员从旧版本(可能从 18.04 LTS)迁移到新 LTS 的速度有多快。这对于我决定我的应用程序应针对哪个 Ubuntu 版本非常重要。
最好是有关不同 Linux 发行版和版本的使用情况的一些统计数据,可能带有时间尺度。有一些图表和列表(例如,https://distrowatch.com/dwres.php?resource =trending),但我找不到任何深入到发行版版本级别的统计信息。
获取此信息的最佳或“官方”来源是什么?
build( https://github.com/pypa/build ) 是一个创建轮子的好工具。但是,我找不到一种方法来创建可以使用python setup.py --plat-name=linux_x86_64.
我尝试过这些方法:
setup.cfg内容[bdist_wheel] \ plat-name=linux_x86_64。它运行良好,但我想使其动态化(在 Windows 上,我想使用win_amd64)。python -m build -w -n "--config-setting=--plat-name(=linux_x86_64)",没有成功。重命名创建的.whl文件感觉是一个很棘手的解决方案。
解决这个问题的最先进的方法是什么?
如果我有一个包含公共头文件的库,这些文件被另一个库的公共头文件使用,我如何将前一个库的公共头文件公开给第三个应用程序,该应用程序仅依赖于后一个库,而不显式添加前一个库的头文件的路径到应用程序的 target_include_directories 部分?
我知道这有点令人困惑,这是一个简单的例子:
我在同一个 cmake 项目中有两个共享库和一个应用程序:
library_foo 有一个包含其公共头文件的目录library_bar还有一个包含公共头文件的目录。其中一个公共头文件 ( lib_bar/bar.h) 包含一个#include <lib_foo/foo.h>条目,即公共头文件具有对 中定义的公共头文件的引用library_foo。library_bar实现取决于library_foo.app仅直接取决于library_bar.app'smain.cpp包含一个#include <lib_bar/bar.h>.所以,app 也间接依赖于library_foo它的头文件。
我想为我的应用程序的这三个部分编写三个 CMakeLists.txt 文件。在app我的 CMakeLists.txt 中,我只想指定依赖于library_bar,即libarary_foo在library_barCMakeLists.txt中指定的库和头文件依赖必须转移到app. 我怎样才能做到这一点?我想使用target_*解决方案。
假设存在Bar使用Foo对象的对象。所有权是独占的,因此Bar得到Foo一个std::unique_ptr在其构造。我想Bar使用Google Test框架进行测试,因此我编写了以下代码:
using namespace testing;
class Foo
{
public:
virtual int F() = 0;
};
class Bar
{
public:
Bar(std::unique_ptr<Foo>&& foo) : m_foo(std::move(foo))
{
}
int B()
{
return m_foo->F();
}
private:
std::unique_ptr<Foo> m_foo;
};
class MockFoo : public Foo
{
public:
MOCK_METHOD0(F, int());
};
class BarTest : public Test
{
};
TEST_F(BarTest, Test1)
{
auto mock_foo = std::make_unique<MockFoo>();
ON_CALL(*mock_foo, F()).WillByDefault(Return(1));
Bar bar(std::move(mock_foo));
auto val = bar.B();
EXPECT_THAT(val, …Run Code Online (Sandbox Code Playgroud) 我想实现这个目标:
Foo<int, 5, double, 7> foo_1;
Foo<char, 7> foo_2;
foo_1.Foo<int>::value[4] = 1;
foo_2.Foo<char>::value[1] = 'x';
Run Code Online (Sandbox Code Playgroud)
(这是一个过于简单的例子,它的Foo作用远不止于此。)
我该如何使用可变参数模板来做到这一点?
太长了;
我知道如果使用专用类型或非类型,则可以以这种方式使用可变参数模板:
template <typename ...T>
struct Foo;
template<typename T, typename ...Args>
struct Foo<T, Args...> : Foo<T>, Foo<Args...> {
Foo(T t, Args... args) : Foo<T>(t), Foo<Args...>(args...) { }
};
template<typename T>
struct Foo<T> {
T value;
Foo<T>(T v) : value(v) {}
};
Foo<int, double, char> f(7, 88.1, 'x');
f.Foo<double>::value = 5;
Run Code Online (Sandbox Code Playgroud)
但我不知道是否可以使用可变参数模板来配对和混合类型和非类型模板参数。
我想在其他匹配器中使用一些现有的匹配器。我知道 MatcherInterface 解决方案,但我想知道我可以使用由MATCHER_P. 如果找到此解决方案:
struct Foo
{
double x;
double y;
};
struct Bar
{
Foo foo;
int i;
};
MATCHER_P(EqFoo, foo, "")
{
::testing::Matcher<double> x_matcher = ::testing::DoubleNear(foo.x, 0.0001);
if (!x_matcher.MatchAndExplain(arg.x, result_listener))
{
return false;
}
::testing::Matcher<double> y_matcher = ::testing::DoubleNear(foo.y, 0.0001);
if (!y_matcher.MatchAndExplain(arg.y, result_listener))
{
return false;
}
return true;
}
MATCHER_P(EqBar, bar, "")
{
::testing::Matcher<Foo> foo_matcher = EqFooMatcherP<Foo>(bar.foo);
if (!foo_matcher.MatchAndExplain(arg.foo, result_listener))
{
return false;
}
if (bar.i != arg.i)
{
return false;
}
return true;
}
TEST_F(TestClass, …Run Code Online (Sandbox Code Playgroud) 我有两个脚本:
install.sh
#!/usr/bin/env bash
./internal_install.sh
Run Code Online (Sandbox Code Playgroud)
internal_install.sh
#!/usr/bin/env bash
set -x
while true; do
read -p "Hello, what's your name? " name
echo $name
done
Run Code Online (Sandbox Code Playgroud)
当我运行时./install.sh,一切都按预期进行:
> ./install.sh
+ true
+ read -p 'Hello, what'\''s your name? ' name
Hello, what's your name? Martin
+ echo Martin
Martin
...
Run Code Online (Sandbox Code Playgroud)
但是,当我运行时cat ./install.sh | bash,该read函数不会阻塞:
cat ./install.sh | bash
+ true
+ read -p 'Hello, what'\''s your name? ' name
+ echo
+ true
+ read -p …Run Code Online (Sandbox Code Playgroud) c++ ×4
googlemock ×2
googletest ×2
apt-get ×1
bash ×1
c++11 ×1
cmake ×1
docker ×1
gcc ×1
gmock ×1
pipe ×1
python ×1
python-wheel ×1
qmake ×1
setuptools ×1
stdin ×1
templates ×1
ubuntu ×1
ubuntu-18.04 ×1
ubuntu-20.04 ×1