Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

NOTE: this is mostly obsolete, as the new build process uses docker and inside of it the conan package management system to install the required mingw libs.
See GitHub builder-docker repository for more information.

NOTE: DRAFT / WORK-IN-PROGRESS / INCOMPLETE

...

  • Much of my learnings stemmed from the following pages:

  • Install the debian package building scripts with:

    • sudo apt install devscripts

  • Install mingw compilers with:

    • sudo apt install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 gcc-mingw-w64 g++-mingw-w64

  • cd ~

  • mkdir debs

  • cd debsI’ll

  • now retrieve Ubuntu’s libusb and I think one fruitful path I took was to make use of an existing *-mingw-w64 source package file, study how it was structured, then slowly tweak/modify it to transform it into a package for another program.

  • E.g., I think I did this when I used ubuntu’s libz-mingw-w64 package and tweaked it into libpng-mingw-w64 and libusb-mingw-w64 packages.

  • I’ll now retrieve Ubuntu focal’s libz-mingw-w64 .dsc (source package) file with:

    • Run software-properties-gtk

    • Under the Ubuntu software tab, check (x) Source code

    • Click ‘OK’ button

    • Back in a console, then type:

      Code Block
      cd ~/debs
      mkdir libz
      cd libz
    • Then grab the libz source package with:
      apt source libusblibz-1.0mingw-0w64

      This will retrieve the following:

      • libusb-1.0libz-mingw-w64-1.02.2311+dfsg/… (lots of files in here)libusb-1.0_1.0.23

      • libz-mingw-w64_1.2.11+dfsg-2.debian.tar.xz

      • libz-mingw-w64_1.2.11+dfsg-2.dsc

      • libz-mingw-w64_1.2.11+dfsg.orig.tar.bz2libusb-1.0xz

  • Make a copy of the libz folder as libusb:

    Code Block
    cd ..
    cp -r libz libusb
    cd libusb

Step 1: Rename the upstream tarball

  • I’ll grab the desired version of libusb from their site:
    wget https://github.com/libusb/libusb/archive/refs/tags/v1.0.24.tar.gz

  • Rename the source tar file to debian standards:
    mv v1.0.24.tar.gz libusb-mingw-w64_1.0

    .23-2build1.debian

    .24.orig.tar.gz

  • Delete the libz source tar:
    rm libz-mingw-w64_1.2.11+dfsg.orig.tar.xz

Step 2: Unpack the upstream tarball

  • Extract it with:
    tar xvf libusb-mingw-w64_1.0

    _

    .24.orig.tar.gz

  • Rename extracted folder name to match “<source-package-name>-<upstream-version-number>”:
    mv libusb-1.0.

    23-2build1.dsc

    24 libusb-mingw-w64-1.0.24

Step 3: Add the Debian packaging files

  • cd libusb-mingw-w64-1.0.24

  • Copy the debian/rules file from libz into libusb:

    Code Block
    languagem
    mkdir debian
    cp ../libz-mingw-w64-1
    .0.23
    .2.11+dfsg/debian/rules debian/

    file and add the following stuff in green:
    CFLAGS="$(CFLAGS) -Os" CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ dh_auto_configure --builddirectory build-udeb -- --libdir=\$${prefix}/lib/
    Run debuild -us -uc and make note of any errors spotted there. E.g. for me:
    dpkg-checkbuilddeps: error: Unmet build dependencies: debhelper (>= 12.4) libudev-dev doxygen
    In this case, I just needed to install a few dependencies:
    sudo apt install debhelper libudev-dev doxygen
    If you get an error like this:
    /usr/bin/x86_64-w64-mingw32-ld: unrecognized option '-z'
    • Edit the following files and remove and reference to -Wl,-z,relro

      • build-deb/Makefile

      • build-deb/tests/Makefile

      • build-deb/libusb/Makefile

      • build-deb/examples/Makefile

      • build-deb/doc/Makefile file and remove any mention of --disable-static in it.

      • Search for any references to ‘libpng’ within the file and aim to replace them with ‘libusb’

        • Some of these tweaks might relate to the upstream tar file, so assess if the filename matches what you have. If not, tweak the reference in this file to make it match what you have.

  • Create an initial changelog file with:
    dch --create -v1.0.24-1 --package libusb-mingw-w64

    • You’ll need to pick you’re favourite editor from a list and then edit the default contents.

    • Be sure to replace the default email address with your own valid one (otherwise there will be build errors later)

    • Save the file and exit your editor

  • Copy across the debian/compat file:
    cp ../libz-mingw-w64-1.2.11+dfsg/debian/compat debian/

  • Copy across the debian/copyright file:
    cp ../libz-mingw-w64-1.2.11+dfsg/debian/copyright debian/

  • Copy across the debian/control file:
    cp ../libz-mingw-w64-1.2.11+dfsg/debian/control debian/

    • It contains descriptions for one source and two packages.

    • Try update these details to suit ‘libusb’, put your own name as maintainer.

    • You can remove those Vcs-Browser/Vcs-Git/Homepage lines if you can’t be bothered chasing up those details.

    • Search for the term ‘libz’ and sure any past references to it are now saying ‘libusb’

  • Copy across the debian/source/format file:

    Code Block
    languagem
    mkdir debian/source
    cp ../libz-mingw-w64-1.2.11+dfsg/debian/source/format debian/source/

Step 4: Build the package

  • Let's try building with:

    debuild -us -uc

  • Google around for any issues that arise on each build attempt…

  • Try open the generated .deb file in an archive browser to assess whether the built binaries are in the desired locations

  • Try install the package and build a mega65-tools mingw target, and see if you get any errors:

    Code Block
    sudo dpkg -i libusb-mingw-w64_1.0.24-1_amd64.deb
    make bin/mega65_ftp.exe

  • If you get errors, uninstall the .deb, tweak your debian/* files some more, google some more, try call debuild -us -uc again, try un-install your old .deb and install your new one, then run the make .exe again. Rinse and repeat…

    Code Block
    # <tweak stuff in debian/*>
    debuild -us -uc
    # <assess warnings/errors in .deb build output>
    sudo dkpg -r libusb-mingw-w64
    sudo dpkg -i libusb-mingw-w64_1.0.24-1_amd64.deb
    make bin/mega65_ftp.exe
    # <assess warnings/errors in .exe build output>
    # go back to step 1

Some tweaks I recall making

  • I had to add a debian/source/include-binaries file consisting of:

    Code Block
    debian/libusb-mingw-w64/usr/x86_64-w64-mingw32/bin/libusb-1.0.dll
    debian/libusb-mingw-w64/usr/i686-w64-mingw32/bin/libusb-1.0.dll

    (this was to assure those files were included inside the .deb package, as they’re not in the typical lib/ location)

  • From inside debian/control, I removed the Package: libusb-mingw-w64 section, as when I inspected its contents, it had nothing significant in it.

Sharing these .deb files via a package repository

I had a prior attempt at this at the following location:

It was working fine for a while, but after a year passed, the certificate expired and I had no memory of the password I set or how to update the certificate.

So for now, I’ll just manually share the newly-generated .deb file here:
- http://gurce.net/ubuntu/libusb-mingw-w64_1.0.24-1_amd64.deb

Later on, I’ll try remake the .deb package repository, and get better acquainted with these certificate shenanigans…