How to cross-build a Debian package

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












5















I want to build an armhf package on an amd64 machine. My armhf machine is a lot slower than my amd64 one.










share|improve this question






















  • For kernel package specifically: askubuntu.com/questions/802701/kernel-build-cross-compile

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 8 '18 at 21:24
















5















I want to build an armhf package on an amd64 machine. My armhf machine is a lot slower than my amd64 one.










share|improve this question






















  • For kernel package specifically: askubuntu.com/questions/802701/kernel-build-cross-compile

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 8 '18 at 21:24














5












5








5


5






I want to build an armhf package on an amd64 machine. My armhf machine is a lot slower than my amd64 one.










share|improve this question














I want to build an armhf package on an amd64 machine. My armhf machine is a lot slower than my amd64 one.







debian cross-compilation deb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 10 '14 at 10:17









TshepangTshepang

25.8k71185263




25.8k71185263












  • For kernel package specifically: askubuntu.com/questions/802701/kernel-build-cross-compile

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 8 '18 at 21:24


















  • For kernel package specifically: askubuntu.com/questions/802701/kernel-build-cross-compile

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 8 '18 at 21:24

















For kernel package specifically: askubuntu.com/questions/802701/kernel-build-cross-compile

– Ciro Santilli 新疆改造中心 六四事件 法轮功
Oct 8 '18 at 21:24






For kernel package specifically: askubuntu.com/questions/802701/kernel-build-cross-compile

– Ciro Santilli 新疆改造中心 六四事件 法轮功
Oct 8 '18 at 21:24











3 Answers
3






active

oldest

votes


















4














We first have to set up the multi-arch environment (more info):



sudo dpkg --add-architecture armhf
sudo apt update


Download the source package (using less as an example):



apt-get source less


Navigate to the directory and, finally, build the package:



cd less-458
dpkg-buildpackage -us -uc -b --host-arch armhf


The special flag in the command above is --host-arch.
The other flags mean:



  • We are not signing a source package

  • We are not signing the .changes file

  • We are doing a binary-only build

Those 3 are only relevant to those building public repositories, like Debian Developers/Maintainers.






share|improve this answer

























  • Tested on a Debian 8 amd64 system

    – Tshepang
    May 18 '15 at 20:14











  • coreutils also builds

    – Tshepang
    May 18 '15 at 21:23






  • 2





    You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

    – Stephen Kitt
    May 18 '15 at 21:25











  • But it's so complex to set up. Maybe I'll try at some point.

    – Tshepang
    May 20 '15 at 9:18






  • 1





    Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

    – vinc17
    May 15 '18 at 11:59


















2














If you care more about convenience than speed, you can use the following method, which uses qemu to emulate an ARM system.



Install package that got the tool we need, pbuilder-dist:



sudo apt install ubuntu-dev-tools


The following command creates a chroot to build on, and creates a tarball
of it (in this case a Debian 8 system for armhf architecture):



pbuilder-dist jessie armhf create


Get sources of some package:



apt-get source bb


Build the package:



pbuilder-dist jessie armhf bb_1.3rc1-8.3.dsc


This took about 370 seconds on my machine, and about 250 seconds on the ARM system I was building on.






share|improve this answer






























    1














    In Debian 9, with pbuilder:



    pbuilder build --host-arch armhf foo.dsc


    or sbuild:



    sbuild --host=armhf foo.dsc


    No, you don't need to set up an extra chroot. The regular chroots for native building will work.



    (sbuild has supported --host for a long time, using various approaches over time; pbuilder added --host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)






    share|improve this answer




















    • 1





      Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

      – Stephen Kitt
      Jan 7 at 8:32










    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f172500%2fhow-to-cross-build-a-debian-package%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    We first have to set up the multi-arch environment (more info):



    sudo dpkg --add-architecture armhf
    sudo apt update


    Download the source package (using less as an example):



    apt-get source less


    Navigate to the directory and, finally, build the package:



    cd less-458
    dpkg-buildpackage -us -uc -b --host-arch armhf


    The special flag in the command above is --host-arch.
    The other flags mean:



    • We are not signing a source package

    • We are not signing the .changes file

    • We are doing a binary-only build

    Those 3 are only relevant to those building public repositories, like Debian Developers/Maintainers.






    share|improve this answer

























    • Tested on a Debian 8 amd64 system

      – Tshepang
      May 18 '15 at 20:14











    • coreutils also builds

      – Tshepang
      May 18 '15 at 21:23






    • 2





      You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

      – Stephen Kitt
      May 18 '15 at 21:25











    • But it's so complex to set up. Maybe I'll try at some point.

      – Tshepang
      May 20 '15 at 9:18






    • 1





      Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

      – vinc17
      May 15 '18 at 11:59















    4














    We first have to set up the multi-arch environment (more info):



    sudo dpkg --add-architecture armhf
    sudo apt update


    Download the source package (using less as an example):



    apt-get source less


    Navigate to the directory and, finally, build the package:



    cd less-458
    dpkg-buildpackage -us -uc -b --host-arch armhf


    The special flag in the command above is --host-arch.
    The other flags mean:



    • We are not signing a source package

    • We are not signing the .changes file

    • We are doing a binary-only build

    Those 3 are only relevant to those building public repositories, like Debian Developers/Maintainers.






    share|improve this answer

























    • Tested on a Debian 8 amd64 system

      – Tshepang
      May 18 '15 at 20:14











    • coreutils also builds

      – Tshepang
      May 18 '15 at 21:23






    • 2





      You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

      – Stephen Kitt
      May 18 '15 at 21:25











    • But it's so complex to set up. Maybe I'll try at some point.

      – Tshepang
      May 20 '15 at 9:18






    • 1





      Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

      – vinc17
      May 15 '18 at 11:59













    4












    4








    4







    We first have to set up the multi-arch environment (more info):



    sudo dpkg --add-architecture armhf
    sudo apt update


    Download the source package (using less as an example):



    apt-get source less


    Navigate to the directory and, finally, build the package:



    cd less-458
    dpkg-buildpackage -us -uc -b --host-arch armhf


    The special flag in the command above is --host-arch.
    The other flags mean:



    • We are not signing a source package

    • We are not signing the .changes file

    • We are doing a binary-only build

    Those 3 are only relevant to those building public repositories, like Debian Developers/Maintainers.






    share|improve this answer















    We first have to set up the multi-arch environment (more info):



    sudo dpkg --add-architecture armhf
    sudo apt update


    Download the source package (using less as an example):



    apt-get source less


    Navigate to the directory and, finally, build the package:



    cd less-458
    dpkg-buildpackage -us -uc -b --host-arch armhf


    The special flag in the command above is --host-arch.
    The other flags mean:



    • We are not signing a source package

    • We are not signing the .changes file

    • We are doing a binary-only build

    Those 3 are only relevant to those building public repositories, like Debian Developers/Maintainers.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 18 '15 at 23:14

























    answered May 18 '15 at 20:13









    TshepangTshepang

    25.8k71185263




    25.8k71185263












    • Tested on a Debian 8 amd64 system

      – Tshepang
      May 18 '15 at 20:14











    • coreutils also builds

      – Tshepang
      May 18 '15 at 21:23






    • 2





      You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

      – Stephen Kitt
      May 18 '15 at 21:25











    • But it's so complex to set up. Maybe I'll try at some point.

      – Tshepang
      May 20 '15 at 9:18






    • 1





      Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

      – vinc17
      May 15 '18 at 11:59

















    • Tested on a Debian 8 amd64 system

      – Tshepang
      May 18 '15 at 20:14











    • coreutils also builds

      – Tshepang
      May 18 '15 at 21:23






    • 2





      You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

      – Stephen Kitt
      May 18 '15 at 21:25











    • But it's so complex to set up. Maybe I'll try at some point.

      – Tshepang
      May 20 '15 at 9:18






    • 1





      Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

      – vinc17
      May 15 '18 at 11:59
















    Tested on a Debian 8 amd64 system

    – Tshepang
    May 18 '15 at 20:14





    Tested on a Debian 8 amd64 system

    – Tshepang
    May 18 '15 at 20:14













    coreutils also builds

    – Tshepang
    May 18 '15 at 21:23





    coreutils also builds

    – Tshepang
    May 18 '15 at 21:23




    2




    2





    You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

    – Stephen Kitt
    May 18 '15 at 21:25





    You might want to take a look at sbuild, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system...

    – Stephen Kitt
    May 18 '15 at 21:25













    But it's so complex to set up. Maybe I'll try at some point.

    – Tshepang
    May 20 '15 at 9:18





    But it's so complex to set up. Maybe I'll try at some point.

    – Tshepang
    May 20 '15 at 9:18




    1




    1





    Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

    – vinc17
    May 15 '18 at 11:59





    Note that debuild can be used instead of dpkg-buildpackage in order to have a sanitized environment for the build. But in this case, one must use -a<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.

    – vinc17
    May 15 '18 at 11:59













    2














    If you care more about convenience than speed, you can use the following method, which uses qemu to emulate an ARM system.



    Install package that got the tool we need, pbuilder-dist:



    sudo apt install ubuntu-dev-tools


    The following command creates a chroot to build on, and creates a tarball
    of it (in this case a Debian 8 system for armhf architecture):



    pbuilder-dist jessie armhf create


    Get sources of some package:



    apt-get source bb


    Build the package:



    pbuilder-dist jessie armhf bb_1.3rc1-8.3.dsc


    This took about 370 seconds on my machine, and about 250 seconds on the ARM system I was building on.






    share|improve this answer



























      2














      If you care more about convenience than speed, you can use the following method, which uses qemu to emulate an ARM system.



      Install package that got the tool we need, pbuilder-dist:



      sudo apt install ubuntu-dev-tools


      The following command creates a chroot to build on, and creates a tarball
      of it (in this case a Debian 8 system for armhf architecture):



      pbuilder-dist jessie armhf create


      Get sources of some package:



      apt-get source bb


      Build the package:



      pbuilder-dist jessie armhf bb_1.3rc1-8.3.dsc


      This took about 370 seconds on my machine, and about 250 seconds on the ARM system I was building on.






      share|improve this answer

























        2












        2








        2







        If you care more about convenience than speed, you can use the following method, which uses qemu to emulate an ARM system.



        Install package that got the tool we need, pbuilder-dist:



        sudo apt install ubuntu-dev-tools


        The following command creates a chroot to build on, and creates a tarball
        of it (in this case a Debian 8 system for armhf architecture):



        pbuilder-dist jessie armhf create


        Get sources of some package:



        apt-get source bb


        Build the package:



        pbuilder-dist jessie armhf bb_1.3rc1-8.3.dsc


        This took about 370 seconds on my machine, and about 250 seconds on the ARM system I was building on.






        share|improve this answer













        If you care more about convenience than speed, you can use the following method, which uses qemu to emulate an ARM system.



        Install package that got the tool we need, pbuilder-dist:



        sudo apt install ubuntu-dev-tools


        The following command creates a chroot to build on, and creates a tarball
        of it (in this case a Debian 8 system for armhf architecture):



        pbuilder-dist jessie armhf create


        Get sources of some package:



        apt-get source bb


        Build the package:



        pbuilder-dist jessie armhf bb_1.3rc1-8.3.dsc


        This took about 370 seconds on my machine, and about 250 seconds on the ARM system I was building on.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 19 '15 at 19:18









        TshepangTshepang

        25.8k71185263




        25.8k71185263





















            1














            In Debian 9, with pbuilder:



            pbuilder build --host-arch armhf foo.dsc


            or sbuild:



            sbuild --host=armhf foo.dsc


            No, you don't need to set up an extra chroot. The regular chroots for native building will work.



            (sbuild has supported --host for a long time, using various approaches over time; pbuilder added --host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)






            share|improve this answer




















            • 1





              Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

              – Stephen Kitt
              Jan 7 at 8:32















            1














            In Debian 9, with pbuilder:



            pbuilder build --host-arch armhf foo.dsc


            or sbuild:



            sbuild --host=armhf foo.dsc


            No, you don't need to set up an extra chroot. The regular chroots for native building will work.



            (sbuild has supported --host for a long time, using various approaches over time; pbuilder added --host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)






            share|improve this answer




















            • 1





              Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

              – Stephen Kitt
              Jan 7 at 8:32













            1












            1








            1







            In Debian 9, with pbuilder:



            pbuilder build --host-arch armhf foo.dsc


            or sbuild:



            sbuild --host=armhf foo.dsc


            No, you don't need to set up an extra chroot. The regular chroots for native building will work.



            (sbuild has supported --host for a long time, using various approaches over time; pbuilder added --host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)






            share|improve this answer















            In Debian 9, with pbuilder:



            pbuilder build --host-arch armhf foo.dsc


            or sbuild:



            sbuild --host=armhf foo.dsc


            No, you don't need to set up an extra chroot. The regular chroots for native building will work.



            (sbuild has supported --host for a long time, using various approaches over time; pbuilder added --host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 7 at 8:36









            Stephen Kitt

            168k24378455




            168k24378455










            answered Jan 6 at 13:30









            Helmut GrohneHelmut Grohne

            1112




            1112







            • 1





              Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

              – Stephen Kitt
              Jan 7 at 8:32












            • 1





              Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

              – Stephen Kitt
              Jan 7 at 8:32







            1




            1





            Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

            – Stephen Kitt
            Jan 7 at 8:32





            Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available.

            – Stephen Kitt
            Jan 7 at 8:32

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f172500%2fhow-to-cross-build-a-debian-package%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?