All posts by alter

Ubuntu: add sign of packages in own repository

This article is extension of http://ag-up.com/ubuntu-create-own-repository/

1. Generate own key
gpg --gen-key
Choose generate sign-only key
enter your Name and Email

2. gpg --armor --export foo@bar.com --output > /opt/repository/ubuntu/public.key where foo@bar.com is Email which you use for generating the key.
3. apt-get install dpkg-sig
dpkg-sig --sign builder /tmp/nginx-ng_1.8.x-1_amd64.deb — sign deb package, use password which you input in the 1st step

4. In the previous article we used command reprepro -C main includedeb precise /tmp/nginx-ng_1.8.x-1_amd64.deb for adding new package in repository,
we have to modify that command to reprepro --ask-passphrase -V -C main includedeb precise /tmp/nginx-at_1.8.x-1_amd64.deb — it'll ask you for key password

5. add to /opt/repository/ubuntu/conf/distributions new option SignWith: yes

On the client side import public key which we exported in step 2:
curl http://packages.localdomain/public.key | apt-key add —
apt-get update

Ubuntu: Create own repository

mkdir -p /opt/repository/ubuntu/
mkdir -p /opt/repository/ubuntu/{conf,dists,incoming,indices,logs,pool,project,tmp}
cd /opt/repository/ubuntu/
vim conf/distributions

1
2
3
4
5
6
7
Origin: packages.localdomain                                                                                                                                      
Label: My Own Repository                                                                                                                                          
Codename: precise                                                                                                                                            
Architectures: amd64                                                                                                                                          
Components: main
Description: Allods Team repository
Version: 12.04

Codename should contain name of OS branch.

First initializing of repository:
Continue reading Ubuntu: Create own repository

Ubuntu: Create own deb package

I'll show you how to create own deb package using modified nginx
1) we download nginx sources
2) we download some external nginx modules
3) we run

1
2
3
4
5
6
7
./configure --with-cc-opt="-static -static-libgcc" --with-ld-opt="-Bstatic" --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid \
    --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx \
    --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed' \
    --add-module=./modules/naxsi/naxsi_src \
    --add-module=./modules/nginx-goodies-nginx-sticky-module-ng-bd312d586752 \
    --add-module=./modules/headers-more-nginx-module-0.25

4) make
after make we have out/nginx file so we could create own package using it

$ mkdir -p /opt/nginx/deb/nginx-ng
$ cd /opt/nginx/deb/nginx-ng
$ ls -1

1
2
3
4
DEBIAN
etc
usr
var

I downloaded original nginx deb and unpack it, after that I took DEBIAN, usr, var and etc folders from it
Continue reading Ubuntu: Create own deb package

Mongo: select data

1
2
> db.communities.find({name: "CZ CHAT"}, {"name":1, "_id":0, "communityId":1}).sort({"communityId":1}).pretty().limit(5)
{ "communityId" : NumberLong("468374361246531951"), "name" : "CZ CHAT" }

in sql it looks like:

1
select name, "communityId" from communities where name like 'CZ CHAT' order by "communityId" limit 5;

pretty () — just a formatted output.