Purpose of this documentation
Is to help systems administrators support and maintain the script for installing the OHIE stack: "How to install DATIM4U OHIE Stack"
General References
Comprehensive Steps:
http://packaging.ubuntu.com/html/packaging-new-software.html
...
Optimized setup: - use this after performing a complete example somewhere else
Basic system update and upgrade:
Code Block | ||
---|---|---|
| ||
ubuntu:~#sudo apt-get update
ubuntu:~#sudo apt-get upgrade |
For having pbuilder that creates a clean simple ubuntu environment for builds:
Code Block | ||
---|---|---|
| ||
ubuntu:~#sudo apt-get install gnupg pbuilder ubuntu-dev-tools bzr-builddeb apt-file |
This does the packaging but is not used regularly
Code Block | ||
---|---|---|
| ||
ubuntu:~#sudo apt-get install packaging-dev |
Generate the gpg key:
Code Block | ||
---|---|---|
| ||
gpg --gen-key |
Send the keys to launchpad:
Code Block | ||
---|---|---|
| ||
gpg --send-keys --keyserver keyserver.ubuntu.com keythatgotgenerated |
Copy paste the secure email from launchpad to read its content:
Code Block | ||
---|---|---|
| ||
vim mail.gpg |
Extract the message for the launchpad stuff:
Code Block | ||
---|---|---|
| ||
gpg -d mail.gpg |
Creating the clean pbuilder environment:
Code Block | ||
---|---|---|
| ||
pbuilder-dist trusty create |
Should match with the gpg key:
Code Block | ||
---|---|---|
| ||
bzr whoami "YourName <youremailid>" |
Launchpad key:
Code Block | ||
---|---|---|
| ||
bzr launchpad-login yourlaunchpadid |
These commands should be included in the bashrc file:
Code Block | ||
---|---|---|
| ||
vim ~/.bashrc |
and add:
Code Block | ||
---|---|---|
| ||
export DEBFULLNAME="YourFullName"
export DEBEMAIL="youremailid" |
Source the script:
Code Block | ||
---|---|---|
| ||
source ~/.bashrc |
basic git config necessary:
Code Block | ||
---|---|---|
| ||
git config --global user.email "youremailid"
git config --global user.name "youreusername"
git config --global core.editor "vim"
git config --global push.default simple
git --version |
This allows us to access the actual file system - vagrant is useful this way that by placing //files/folders in this folder will allow them to be accessible to vagrant shell:
Code Block | ||
---|---|---|
| ||
cd /vagrant
mkdir code
cd packages/
mkdir -p adxadapter2
cd adxadapter2/
sudo apt-get install openjdk-7-jdk --no-install-recommends |
This will create the .ssh folder in the exact location:
Code Block | ||
---|---|---|
| ||
ssh-keygen |
Copy your private rsa key so that you can directly access github:
Code Block | ||
---|---|---|
| ||
cp id_rsa ~/.ssh/
cd .ssh
cd .. |
Remove the created public file that is not required created by ssh-keygen file:
Code Block | ||
---|---|---|
| ||
rm id_rsa.pub |
Doing the Packaging
Navigate to the packaging folders
Code Block | ||
---|---|---|
| ||
cd code/packages/ |
This will get all the folders from the pepfar files
Code Block | ||
---|---|---|
| ||
git clone git@github.com:pepfar-datim/OHIE.git |
Navigate to the packaging folder:
Code Block | ||
---|---|---|
| ||
cd adxAdapter/ |
This is not yet executable and the following will make it executable to make it run:
Code Block | ||
---|---|---|
| ||
chmod +x gradlew
./gradlew war
cd build
cd libs
cp adxAdapter.war /vagrant/code/packages/adxadapter2/
cd ..
cp adxAdapter.properties.sample /vagrant/code/packages/adxadapter2/
cd /vagrant/code/packages/adxadapter2/
tar czf adxadapter-1.0.0.tar.gz adxAdapter.*
rm adxAdapter.*
dh_make -p adxadapter_1.0.0 -f adxadapter-1.0.0.tar.gz |
This needs to be in double folder names down because the build file/folder generated is kept //one level up and it was a mistake to not do it this way earlier:
Code Block | ||
---|---|---|
| ||
mkdir adxadapter2
cp -r debian adxadapter2/ |
This will extract the data from a tar.gz file
Code Block | ||
---|---|---|
| ||
tar zxf adxadapter-1.0.0.tar.gz -C adxadapter2/
cd adxadapter2/ |
-p allows to create all the folders that are not yet created in the below levels:
Code Block | ||
---|---|---|
| ||
mkdir -p var/lib/tomcat7/webapps/
cp adxAdapter.war var/lib/tomcat7/webapps/
rm *.war |
Rename the file:
Code Block | ||
---|---|---|
| ||
mv adxAdapter.properties.sample adxAdapter.properties |
Entering the packaging folders:
Code Block | ||
---|---|---|
| ||
mkdir -p etc/adxadapter/
mv adxAdapter.properties etc/adxadapter/
cd debian/
rm *.ex
rm *.EX
vim control |
Keep section as misc and homepage should be if the have any page, depends needs to be include any packages needed, architecture is changed to amd64
Source: adxadapter
Section: misc
Priority: optional
Maintainer: yourname <youremailid>
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.4
Homepage:
Package: adxadapter
Architecture: amd64
Depends: npm, nodejs
Description: ADX adapter sample package
Clear out the Copyright or include one as per your needs:
Code Block | ||
---|---|---|
| ||
vim copyright |
Include only if required for a sample one - clear this out
Code Block | ||
---|---|---|
| ||
rm README.Debian
vim README.source |
adxadapter for Debian
---------------------
use gradlew without parameters script to set up gradle (only needed the first time)
projects users 1.7 java compliance, so at least 1.7 should be present
use gradlew eclipse to set up eclipse project. it also downloads dependencies on the first run.
if adding new dependencies, update gradle.build and rerun gradlew eclipse to update eclipse classpath.
Alternatively, gradlew eclipseClasspath can be used to only update eclipse classpath, and not
affect other project files.
to generate war file, use gradlew war command. it places war file in build/libs directory.
-- yourname <youremailid> Fri, 15 Apr 2016 15:33:01 +0000
Preliminary Requirements
- Add your `id_rsa.pub` ssh key to launchpad
- Navigate to https://launchpad.net/people/+me/+editsshkeys
- copy and paste your public key into the prompt
to output your public key into the terminal run the following command:
Code Block cat ~/.ssh/id_rsa.pub
Setup Vagrant
- References
Install packages
Code Block sudo apt-get -y install virtualbox vagrant virtualbox-dkms
Install a Vagrant Box
- Use hashicorp to find a suitable box to install, like ubuntu/trusty64 at https://atlas.hashicorp.com/ubuntu/boxes/trusty64
- note, rest of development we will assume that we are using the ubuntu/trusty64 box from hashicorp
- navigate to a directory where you wish to store your vagrant configurations for this setup
e.g.,
Code Block mkdir /var/www/vagrant/ && cd /var/www/vagrant/
download and setup vagrant box:
Code Block vagrant init ubuntu/trusty64; vagrant up --provider virtualbox
- Use hashicorp to find a suitable box to install, like ubuntu/trusty64 at https://atlas.hashicorp.com/ubuntu/boxes/trusty64
- Create relevant provisions and vagrant settings
Open the Vagrantfile for your vagrant
Code Block nano /var/www/vagrant/Vagrantfile
Insert the following code into the Vagrant file, at the end - but before the `end` command
- Don't forget to replace the values for `your_launchpad_name`, `your_launchpad_email`, etc...
If the formatting on the code block below breaks, visit https://gist.github.com/uladkasach/81cfe5d3b879882152178f0b5c8a6ec0
Code Block config.ssh.forward_agent = true; config.vm.provision "shell" do |s| your_launchpad_name = "Launchpad Name"; your_launchpad_email = "launchpademail@provider.com"; your_launchpad_username = "launchpadusername"; your_gpg_password = "a_gpg_password"; your_git_email = "yourgitemail@provider.com"; your_git_username = "gitusername"; s.inline = <<-SHELL echo "##########################"; echo Beginning provisioning of packaging environment setup.; echo "##########################"; echo For launchpad: echo Using #{your_launchpad_name} as your name, echo Using #{your_launchpad_email} as your email, echo Using #{your_launchpad_username} as your username... echo For git: echo Using #{your_launchpad_email} as your email, echo Using #{your_launchpad_username} as your username... echo "##########################"; echo Updating and Upgrading echo "##########################"; sudo apt-get update && sudo apt-get -y upgrade; echo "##########################"; echo Installing package building packages...; echo "##########################"; sudo apt-get -y install gnupg pbuilder ubuntu-dev-tools bzr-builddeb apt-file; sudo apt-get -y install packaging-dev; # Install packaging package echo This next part may take a little while...; pbuilder-dist trusty create; echo "##########################"; echo Configuring Bazaar...; echo "##########################"; bzr whoami "#{your_launchpad_name} <#{your_launchpad_email}>"; bzr launchpad-login #{your_launchpad_username}; echo "##########################"; echo Configuring Git...; echo "##########################"; git config --global user.email "#{your_git_email}" git config --global user.name "#{your_git_username}" git config --global push.default simple echo "##########################"; echo Assigning your DEBFULLNAME and DEBEMAIL; echo "##########################"; echo $'export DEBFULLNAME="#{your_launchpad_name}"\nexport DEBEMAIL="#{your_launchpad_email}"' >> ~/.bashrc; source ~/.bashrc; echo "##########################"; echo Creating your vagrants GPG key; echo "##########################"; sudo apt-get install rng-tools; cat > .temp_settings_file <<-SETTINGS %echo Generating a basic OpenPGP key... Key-Type: RSA Key-Length: 2048 Subkey-Type: RSA Subkey-Length: 2048 Name-Real: #{your_launchpad_name} Name-Email: #{your_launchpad_email} Expire-Date: 0 Passphrase: #{your_gpg_password} %commit %echo OpenPGP key created successfully. SETTINGS gpg --batch --gen-key .temp_settings_file; rm .temp_settings_file; echo "##########################"; echo Packaging environment successfuly provisioned [Success]. SHELL end
- Note: if you had run
vagrant up
before setting these provisions you will need to runvagrant reload --provision
to see these changes affect your vagrant.
Add a your vagrant's GPG key to Ubuntu and Launchpad
- References
- Enter your vagrant box
Note, this can take a while if this is the first time this vagrant is run or if your triggering its provisioning manually.
Code Block vagrant up; vagrant ssh;
Send the vagrant's gpg key to Ubuntu registry
Find all your vagrant's keys with
Code Block gpg --list- keys
Find the pub id
if you see an entry that looks like `pub 2048R/523053B5 2017-06-01`, `523053B5` is the pub id
Send the keys
run the following command, replacing the `<pub_key_id>` with the actual value
Code Block gpg --send-keys --keyserver keyserver.ubuntu.com <pub_key_id>
For example
Code Block gpg --send-keys --keyserver keyserver.ubuntu.com 523053B5
Verify successful transmission
The response key sending input should look like the following
Code Block gpg: sending key <pub_key_id> to hkp server keyserver.ubuntu.com
You can double check that the transaction went through successfuly with the following command
Code Block gpg --keyserver hkp://keyserver.ubuntu.com --search-key 'your@email.com'
Import key into launchpad
navigate to your OpenPGP keys page
get fingerprint of your key
gpg
Code Block gpg --fingerprint
- copy paste the key into the launchpad input box, press import key
- open email that launchpad sent you
decrypt the email
copy and paste the contents into a new file
Code Block nano email.gpg
decrypt the file with your key
Code Block gpg -d email.gpg
open the link contained in the decrypted email and confirm your key by pressing
continue
Congratulations
The last line is important for this as that matches with the GPG key in launchpad
Code Block | ||
---|---|---|
| ||
vim source/format |
3.0 (native) |
...
Code Block | ||
---|---|---|
| ||
vim rules |
You're all done. You've successfully set up your packaging environment.