Showing posts with label Debian package. Show all posts
Showing posts with label Debian package. Show all posts

Wednesday, 8 June 2016

How to generate GPG Key?

Prerequisites

packages to be installed

  1. rngd
  2. gpgv OR gpgv2
Step1: Create a Temporary Folder and CD to it
Step2: Generate GPG Key
  1. eval `gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info`
  2. export GPG_TTY=`tty`
  3. export GPG_AGENT_INFO
  4. gpg --gen-key
    1. Enter passphrase: ******
  5. Run in a Different terminal rngd -f -r /dev/urandom
Step3: read the key' s.

 gpg -k

Sample Output:

GPG Key o/p:
.......+++++
+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.+++++
.................+++++
gpg: key 50F6E79D marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/50F6E79D 2015-08-14
Key fingerprint = 3C2C 81AA 5B9E 6772 1AEA  9AF3 78B2 D37D 50F6 E79D
uid ZeroOnePrograms  <developer@zerooneprograms.com>
sub   2048R/EA01868C 2015-08-14

How to create debian package without tarball file?


Prerequisites

  1. Installed packages 
    1. build-essential
    2. fakeroot
    3. devscripts
    4. gnupg-agent
    5. debhelper
    6. dh_make
Notes:

  1. This tutorial is useful to develop a quick Debian package example.
  2. This tutorial doesn't have any explanation' s for 
    1. Debian rules.
    2. Various Debian build stage' s.
    3. license creation and attaching to Debian package.
    4. Debian man pages creation& integrating to the Debian package.
    5. Debian package creation from existing tarball.
    6. how to write debian package build changes.
    7. gpg key for Debian Package

Step1: add Debian Package default Name, Email-Id to global environment variables /etc/environment.

DEBEMAIL="developer@zerooneprograms.com"
DEBFULLNAME="zerooneprograms"
EMAIL="support@zerooneprograms.com"

Step2: add Debian Package Name, installation script file name, HOME Folder Path for Script& Package Version.

SOURCEBINPATH=$(pwd)
SOURCEBIN=zerooneprograms
DEBFOLDER=zerooneprograms
DEBVERSION=1.0

Step3: Create Folder Debian Package with below  naming Conventions

DEBFOLDERNAME=$DEBFOLDER-$DEBVERSION
# Create your scripts source dir
mkdir $DEBFOLDERNAME

Step4: Copy the installation script file to the Debian Package HOME Folder.

# Copy your script to the source dir
cp $SOURCEBINPATH/$SOURCEBIN $DEBFOLDERNAME
cd $DEBFOLDERNAME

Step5: Create Sample Files& Folder/ Skeleton from Standard Debian Package Format.

# Create the packaging skeleton (debian/*)
dh_make  -s --indep --createorig

|-- debian
|   |-- rules
|   |-- copoyright
|   |-- control
|   |-- changelog
|   |-- patches
|   |-- source
|   `-- upstream
|-- doc
|   |-- man
|   |   `-- fr
|   |-- syntax
|   `-- texinfo
|-- m4
|-- po
`-- src

Step6: Change the script files for below, based on package requirements

  1. add zerooneprograms script file to root folder 
  2. preinstallation scripts
  3. post installation scripts
  4. pre remove scripts
  5. post remove scripts
  6. control file
  7. rules

echo "\nchange control file, preins, postins,prerm and postrm and hit the <Enter> with any key"
read temp

Step7: Create custom Linux terminal commands,  debian/install has instructions to create File& Folder' s while installing the package. Below line will add the file zerooneprograms script in /usr/bin, which creates a terminal command.
echo $SOURCEBIN usr/bin > debian/install

add the instructions to create Folder' s and to copy the files& Folder to the Specific path.

Step8: Remove the all unnecessary files 
# Remove the example files
rm debian/*.ex

Step9: Remove the all unnecessary files 
dpkg-buildpackage -uc -us   #without key


Example Script for creating the debian package  create.sh 

#!/bin/bash
# Configure your paths and filenames
SOURCEBINPATH=$(pwd)
SOURCEBIN=zerooneprograms
DEBFOLDER=zerooneprograms
DEBVERSION=1.0


DEBFOLDERNAME=$DEBFOLDER-$DEBVERSION

# Create your scripts source dir
mkdir $DEBFOLDERNAME

# Copy your script to the source dir
cp $SOURCEBINPATH/$SOURCEBIN $DEBFOLDERNAME
cd $DEBFOLDERNAME

# Create the packaging skeleton (debian/*)
dh_make  -s --indep --createorig

echo "\nchange control file, preins, postins,prerm and postrm and hit the <Enter> with any key"
read temp

# Remove make calls
#grep -v makefile debian/rules > debian/rules.new
#mv debian/rules.new debian/rules

#mkdir -p debian/tmp

#cp $SOURCEBINPATH/$SOURCEBIN  debian/tmp/
# debian/install must contain the list of scripts to install
# as well as the target directory
echo $SOURCEBIN usr/bin > debian/install
#echo test opt >> debian/install

# Remove the example files
rm debian/*.ex

# Build the package.
# You  will get a lot of warnings and ../somescripts_0.1-1_i386.deb
#debuild -S -rfakeroot -k<gpg_key_id>

#debuild -S -rfakeroot -k50F6E79D
#(or)
dpkg-buildpackage -uc -us   #without key


Example rules for Debian Package Creation

#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

#%:
# dh $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp

install: build
dh_testdir
dh_testroot
dh_clean -k 
dh_installdirs

# Add here commands to install the package into debian/flare.

install -d debian/opt/ZeroOnePrograms
cp -r $(CURDIR)/../ZeroOnePrograms    $(CURDIR)/debian/zerooneprograms/opt


# Sample RULE's

# install -m 755 $(DISTSDIR)/*              $(CURDIR)/debian/tmp/opt/
# bunzip2                          $(CURDIR)/debian/tmp/usr/share/doc/debian-book/*pdf*.bz2
# install -m 644 $(DISTSDIR)/*latex*.bz2    $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# cp -r          $(SRCDIR)/htmlsplit        $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# install -m 644 $(CURDIR)/debian/copyright $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# install -m 644 $(SRCDIR)/*.html           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# install -m 644 $(SRCDIR)/*.css            $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# cp -r          $(SRCDIR)/images           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# cp             $(CURDIR)/LICENSE          $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# cp             $(CURDIR)/AUTHORS          $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# gzip           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/AUTHORS
# cp             $(CURDIR)/README           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# gzip           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/README
# cp             $(CURDIR)/TODO             $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# gzip           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/TODO
# cp             $(CURDIR)/README.Debian    $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# gzip           $(CURDIR)/debian/tmp/usr/share/doc/debian-book/README.Debian
# cp             $(CURDIR)/ChangeLog        $(CURDIR)/changelog
# mv             $(CURDIR)/changelog        $(CURDIR)/debian/tmp/usr/share/doc/debian-book/
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs 
# dh_installdocs --exclude=CVS
# dh_installexamples
dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
# dh_installman
dh_link
# dh_strip
dh_compress --exclude=.pdf --exclude=LICENSE
dh_fixperms
# dh_perl
# dh_python
# dh_makeshlibs
dh_installdeb
# dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configu 


Reference