Install debian maintainer's toolset:
apt-get install devscripts dh-make
Assume we have a source (upstream) package inside "helloworld" directory. We must follow the naming convention of - for packaged sources, so we rename it properly, say "helloworld-1.9". Then, descend into the source directory.
mv helloworld helloworld-1.9
cd helloworld-1.9
From inside your source "helloworld-1.9" directory, invoke dh-make to create a skeleton "debian" subdirectory. Provide 'createorig' option so that an original upstream tarball is also created (inside the parent directory).
dh-make -e foo@example.com --packagename helloworld --copyright gpl3 --createorig
Build:
debuild -us -uc
This should produce the .deb package for your current architecture (in the parent directory):
helloworld_<version>-<package-version>_<cpu-arch>.deb
In order to create a new package version (the upstream version cannot be changed!), create a new entry inside debian/changelog:
dch -i
In some cases, the upstream source must be updated i.e. when making some debian-specific customizations. So, before rebuilding with debuild, a changeset should be created in order to be automatically applied to the original upstream package.
dpkg-source --commit
Let's assume we have built (or just downloaded) helloworld_1.0-3_amd64.deb. Install through dpkg:
dpkg --install helloworld_1.0-3_amd64.deb
If the command fails, complaining about missing dependencies, install them through apt:
apt-get install -f