{"id":295,"date":"2025-06-25T17:53:34","date_gmt":"2025-06-25T09:53:34","guid":{"rendered":"https:\/\/qkd.koudaipc.com\/?p=295"},"modified":"2026-01-27T09:47:05","modified_gmt":"2026-01-27T01:47:05","slug":"%e6%90%ad%e5%bb%ba%e7%ba%af%e5%87%80-debian-%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/ns1.koudaipc.com\/en\/2025\/06\/25\/%e6%90%ad%e5%bb%ba%e7%ba%af%e5%87%80-debian-%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83%e6%8c%87%e5%8d%97\/","title":{"rendered":"\u642d\u5efa\u7eaf\u51c0 Debian \u7f16\u8bd1\u73af\u5883\u6307\u5357"},"content":{"rendered":"<p>\u8981\u642d\u5efa\u4e00\u4e2a\u7eaf\u51c0\u7684\u7f16\u8bd1 Debian \u8f6f\u4ef6\u5305\u7684\u73af\u5883\uff0c\u63a8\u8350\u4f7f\u7528\u5b98\u65b9\u5de5\u5177 <strong>&lt;code&gt;pbuilder&lt;\/code&gt;<\/strong> \u6216 <strong>&lt;code&gt;cowbuilder&lt;\/code&gt;<\/strong>\uff08\u57fa\u4e8e OverlayFS \u7684\u9ad8\u6548\u7248\u672c\uff09\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<hr \/>\n<h3><strong>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528 &lt;code&gt;pbuilder&lt;\/code&gt;<\/strong><\/h3>\n<h4>1. \u5b89\u88c5\u5fc5\u8981\u5de5\u5177<\/h4>\n<pre><code class=\"language-bash\">sudo apt update\nsudo apt install pbuilder debootstrap devscripts<\/code><\/pre>\n<h4>2. \u521b\u5efa\u57fa\u7840\u73af\u5883<\/h4>\n<pre><code class=\"language-bash\"># \u521b\u5efa\u9ed8\u8ba4\u7684\u6784\u5efa\u73af\u5883\uff08\u57fa\u4e8e\u5f53\u524d\u7cfb\u7edf\u7684 Debian \u7248\u672c\uff09\nsudo pbuilder create\n\n# \u6307\u5b9a\u7279\u5b9a\u53d1\u884c\u7248\uff08\u5982 bookworm\uff09\nsudo pbuilder create --distribution bookworm --mirror &amp;quot;http:\/\/deb.debian.org\/debian&amp;quot;<\/code><\/pre>\n<h4>3. \u66f4\u65b0\u73af\u5883\uff08\u53ef\u9009\uff09<\/h4>\n<pre><code class=\"language-bash\">sudo pbuilder update<\/code><\/pre>\n<h4>4. \u7f16\u8bd1\u8f6f\u4ef6\u5305<\/h4>\n<pre><code class=\"language-bash\"># \u8fdb\u5165\u6e90\u7801\u76ee\u5f55\uff08\u5305\u542b .dsc \u6587\u4ef6\uff09\ncd \/path\/to\/package-source\n\n# \u751f\u6210\u6e90\u7801\u5305\ndpkg-source -b .\n\n# \u4f7f\u7528 pbuilder \u7f16\u8bd1\nsudo pbuilder build *.dsc<\/code><\/pre>\n<h4>5. \u83b7\u53d6\u7f16\u8bd1\u7ed3\u679c<\/h4>\n<p>\u7f16\u8bd1\u540e\u7684 &lt;code&gt;.deb&lt;\/code&gt; \u6587\u4ef6\u4f4d\u4e8e\uff1a<br \/>\n&lt;code&gt;\/var\/cache\/pbuilder\/result\/&lt;\/code&gt;<\/p>\n<hr \/>\n<h3><strong>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528 &lt;code&gt;cowbuilder&lt;\/code&gt;\uff08\u66f4\u9ad8\u6548\uff09<\/strong><\/h3>\n<h4>1. \u5b89\u88c5\u5de5\u5177<\/h4>\n<pre><code class=\"language-bash\">sudo apt install cowbuilder<\/code><\/pre>\n<h4>2. \u521b\u5efa\u57fa\u7840\u73af\u5883<\/h4>\n<pre><code class=\"language-bash\">sudo cowbuilder --create --distribution bookworm --basepath \/var\/cache\/pbuilder\/base-bookworm.cow<\/code><\/pre>\n<h4>3. \u66f4\u65b0\u73af\u5883<\/h4>\n<pre><code class=\"language-bash\">sudo cowbuilder --update --basepath \/var\/cache\/pbuilder\/base-bookworm.cow<\/code><\/pre>\n<h4>4. \u7f16\u8bd1\u8f6f\u4ef6\u5305<\/h4>\n<pre><code class=\"language-bash\">sudo cowbuilder --build --basepath \/var\/cache\/pbuilder\/base-bookworm.cow package-name_version.dsc<\/code><\/pre>\n<hr \/>\n<h3><strong>\u65b9\u6cd5\u4e09\uff1a\u624b\u52a8\u521b\u5efa\u7eaf\u51c0 chroot \u73af\u5883<\/strong><\/h3>\n<h4>1. \u5b89\u88c5\u4f9d\u8d56<\/h4>\n<pre><code class=\"language-bash\">sudo apt install debootstrap schroot<\/code><\/pre>\n<h4>2. \u914d\u7f6e schroot<\/h4>\n<p>\u521b\u5efa\u914d\u7f6e\u6587\u4ef6 &lt;code&gt;\/etc\/schroot\/chroot.d\/bookworm.conf&lt;\/code&gt;\uff1a<\/p>\n<pre><code class=\"language-ini\">[bookworm]\ndescription=Debian Bookworm\ndirectory=\/srv\/chroot\/bookworm\ntype=directory\npersonality=linux\nprofile=default<\/code><\/pre>\n<h4>3. \u521d\u59cb\u5316 chroot<\/h4>\n<pre><code class=\"language-bash\">sudo mkdir -p \/srv\/chroot\/bookworm\nsudo debootstrap bookworm \/srv\/chroot\/bookworm http:\/\/deb.debian.org\/debian<\/code><\/pre>\n<h4>4. \u8fdb\u5165 chroot \u5b89\u88c5\u7f16\u8bd1\u5de5\u5177<\/h4>\n<pre><code class=\"language-bash\">sudo schroot -c bookworm\napt update\napt install build-essential devscripts fakeroot\nexit<\/code><\/pre>\n<h4>5. \u7f16\u8bd1\u8f6f\u4ef6\u5305<\/h4>\n<pre><code class=\"language-bash\"># \u590d\u5236\u6e90\u7801\u5230 chroot\nsudo cp -r \/path\/to\/source \/srv\/chroot\/bookworm\/home\/\n\n# \u8fdb\u5165 chroot \u7f16\u8bd1\nsudo schroot -c bookworm\ncd \/home\/source\ndpkg-buildpackage -us -uc  # \u4e0d\u7b7e\u540d<\/code><\/pre>\n<hr \/>\n<h3><strong>\u5173\u952e\u4f18\u52bf<\/strong><\/h3>\n<ul>\n<li><strong>\u7eaf\u51c0\u6027<\/strong>\uff1a\u6240\u6709\u7f16\u8bd1\u5728\u72ec\u7acb\u73af\u5883\u4e2d\u8fdb\u884c\uff0c\u4e0d\u4f9d\u8d56\u5bbf\u4e3b\u7cfb\u7edf\u3002<\/li>\n<li><strong>\u53ef\u91cd\u590d\u6027<\/strong>\uff1a\u786e\u4fdd\u7f16\u8bd1\u7ed3\u679c\u4e00\u81f4\u3002<\/li>\n<li><strong>\u591a\u7248\u672c\u652f\u6301<\/strong>\uff1a\u53ef\u4e3a\u4e0d\u540c Debian \u53d1\u884c\u7248\uff08\u5982 &lt;code&gt;bullseye&lt;\/code&gt;\u3001&lt;code&gt;bookworm&lt;\/code&gt;\uff09\u521b\u5efa\u72ec\u7acb\u73af\u5883\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>\u6e05\u7406\u73af\u5883<\/strong><\/h3>\n<pre><code class=\"language-bash\"># \u5220\u9664 pbuilder \u73af\u5883\nsudo rm -rf \/var\/cache\/pbuilder\/base.tgz\n\n# \u5220\u9664 schroot \u73af\u5883\nsudo rm -rf \/srv\/chroot\/bookworm<\/code><\/pre>\n<h3><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/h3>\n<ol>\n<li>\u9996\u6b21\u6784\u5efa\u9700\u4e0b\u8f7d\u57fa\u7840\u7cfb\u7edf\uff0c\u8017\u65f6\u8f83\u957f\uff08\u7ea6 5-10 \u5206\u949f\uff09\u3002<\/li>\n<li>\u7f16\u8bd1\u524d\u786e\u4fdd\u5b89\u88c5\u6240\u6709\u4f9d\u8d56\uff1a\n<pre><code class=\"language-bash\">sudo pbuilder --login  # \u8fdb\u5165\u73af\u5883\u624b\u52a8\u5b89\u88c5\u4f9d\u8d56\napt install -y &lt;missing-dependencies&gt;<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u83b7\u5f97\u4e00\u4e2a\u53ef\u91cd\u590d\u3001\u9694\u79bb\u7684 Debian \u8f6f\u4ef6\u5305\u7f16\u8bd1\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u642d\u5efa\u4e00\u4e2a\u7eaf\u51c0\u7684\u7f16\u8bd1 Debian \u8f6f\u4ef6\u5305\u7684\u73af\u5883\uff0c\u63a8\u8350\u4f7f\u7528\u5b98\u65b9\u5de5\u5177 &lt;code&gt;pbuilder&#038; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pmpro_default_level":"","footnotes":""},"categories":[26],"tags":[],"class_list":["post-295","post","type-post","status-publish","format-standard","hentry","category-foss","pmpro-has-access"],"_links":{"self":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/comments?post=295"}],"version-history":[{"count":2,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/295\/revisions"}],"predecessor-version":[{"id":414,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/295\/revisions\/414"}],"wp:attachment":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/media?parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/categories?post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/tags?post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}