demo of project-builder.org
===========================

# First demonstrate the way of working for pb itself
cd ~/local/pb|~/pb|~/svn-git/pb
# Show the various versions available in this SVK exported dir
ls
# get the current tag of the SVK repository
#svk info
# get it from SVN directly
svn info svn+ssh://svn.mondorescue.org/prj/svn/pb/devel

# get the current version of project-builder
rpm -q project-builder
pb --help
pb

# Decide to build a package for project-builder based on that devel version
# to replace the one currently installed
pb -p pb -r devel sbx2build|cms2build

# Show the upstream part
ls -altg /home/bruno/svn-git/pb/pbdelivery/
tar tvfz /home/bruno/svn-git/pb/pbdelivery/project-builder-XXX.tar.gz

# Show the pb specific part
tar tvfz /home/bruno/svn-git/pb/pbdelivery/project-builder-develXXX.pbconf.tar.gz

# Now make the packages
pb -p pb build2pkg

# Look at the latest packages created
ls -altrg /home/bruno/svn-git/pb/pbbuild/RPMS/noarch

# Install the generated packages
sudo urpmi /home/bruno/svn-git/pb/pbbuild/RPMS/noarch/*.rpm

# Check that it's the right one
rpm -q project-builder
pb -h
git svn info

# Now  show how easy it's to build for another distro in a VM
ls /home/qemu
-> pb -p pb -m debian-7-x86_64 sbx2vm
ls -al /var/ftp/pub/pb/test/debian/7/
ls -al /var/ftp/pub/pb/test/debian/dists/7/

pb -p pb -m mageia-3-i386 sbx2vm
# Now  show how easy it's to build for another distro in a VE
ls /home/rpmbootstrap
pb -p pb -m centos-6-x86_64 build2ve
pb -p pb -m ubuntu-11.10-x86_64 build2ve
-> pb -p pb -m debian-6.0-x86_64 sbx2ve
ls -al /var/ftp/pub/pb/test/debian/6.0/
ls -al /var/ftp/pub/pb/test/debian/dists/6.0/

# Docker part
# Mount the external HDD if needed
sudo mount /dev/sdc1 /mnt
$ sudo mount -o bind /mnt/docker /var/cache/docker
# Then restart docker to avoid errors with Attempt to write a readonly database
$ sudo systemctl restart docker
#$ sudo systemctl restart docker_registry
# Now show how easy it's to build for another distro in a Docker VE
# Create Docker container
$ docker images

# If docker issue with net, restart docker
$ sudo ip link delete docker0
$ sudo systemctl restart docker.service

# Building with rpmbootstrap for a distro
# We already imported the upstream container images to save time
# Start with the local distro to simplify
# 
$ pb -p pb -m mageia-5-x86_64 -T docker -i mageia:5 newve 
# or without -i if time permits using rpmbootstrap
$ docker images | grep mageia-5
$ docker images | grep mageia-5 | awk '{print $3}'
$ docker run -ti `docker images | grep mageia-5 | head -1 | awk '{print $3}'` /bin/bash
[root@8158b86786a7 /]# cat /etc/mageia-release 
Mageia release 5 (Official) for x86_64
[root@8158b86786a7 /]# uname -a
Linux 8158b86786a7 3.19.8-desktop-3.mga5 #1 SMP Sat Jun 13 17:05:48 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@8158b86786a7 /]# urpmi tcsh
    http://distro.ibiblio.org/mageia/distrib/5/x86_64/media/core/release/tcsh-6.18.01-8.mga5.x86_64.rpm
installing tcsh-6.18.01-8.mga5.x86_64.rpm from /var/cache/urpmi/rpms           
Preparing...                     #############################################
      1/1: tcsh                  #############################################
[root@8158b86786a7 /]# pb --help
bash: pb: command not found
[root@8158b86786a7 /]# exit
$ pb -p pb -m mageia-5-x86_64 -T docker sbx2setupve
$ docker images | grep mageia-5
localhost:5000/pb                  mageia-5-x86_64-pb                   43bcfd269f29        2 minutes ago       376.2 MB
localhost:5000/pb                  mageia-5-x86_64                      466f10e78bba        16 minutes ago      184.5 MB
$ docker run -ti `docker images | grep mageia-5-x86_64-pb | awk '{print $3}'` /bin/bash
[root@bbd981bcf4cd /]# pb --help
pb (aka project-builder.org) Version devel20150930111943-2002
[root@bbd981bcf4cd /]# exit
$ pb -p pb -m mageia-5-x86_64 -T docker prepve
$ docker images | grep mageia-5-x86_64-pb-pb
localhost:5000/pb                  mageia-5-x86_64-pb-pb                66dd65cab2cc        About a minute ago   378.9 MB
$ pb -p pb -m mageia-5-x86_64  -T docker sbx2ve

# On another distro already preped
# we can launch in // the same for ubuntu 15.04
$ pb -p pb -m ubuntu-15.04-x86_64 -T docker -i ubuntu:15.04 newve 
$ pb -p pb -m ubuntu-15.04-x86_64 -T docker sbx2setupve
$ pb -p pb -m ubuntu-15.04-x86_64 -T docker prepve
$ pb -p pb -m ubuntu-15.04-x86_64 -T docker sbx2ve

# Instead of the video:
pb -p pb -T docker -m ubuntu-15.04-x86_64 -T docker -i ubuntu:15.04 newve
pb -p pb -T docker -m ubuntu-15.04-x86_64 -T docker sbx2setupve
pb -p pb -T docker -m ubuntu-15.04-x86_64 -T docker prepve
pb -p pb -T docker -m ubuntu-15.04-x86_64 -T docker build2ve

# and then another project
pb -p mondorescue -T docker -m ubuntu-15.04-x86_64 -T docker prepve

# After the Video:
# Another container Ubuntu 13.10
$ pb -p pb -m ubuntu-15.04-x86_64 -T docker build2ve
$ ls -al /var/ftp/pub/pb/test/ubuntu/15.04

# On another project 
$ pb -p mondorescue -m mageia-4-x86_64  -T docker prepve
$ docker images
$ ls -al /var/ftp/pub/pb/test/mageia/4/x86_64
$ ssh bruno@www.mondorescue.org ls -altrg /prj/ftp/test/mageia/4/x86_64

# Look at what was created
$ docker images
$ docker history localhost:5000/pb:mageia-4-x86_64-pb-pb

$ docker ps -a
$ docker attach <ctnid>
$ docker images
$ docker run -ti <imgid> /bin/bash
$ pb -h
$ docker run -ti <imgid> /bin/bash
$ ls -al /var/ftp/pub/pb/test/mageia/4/x86_64
#

# Now check what you built:
# On a deb based distro:
pb -p pb -m debian-9-x86_64 sbx2ve
docker run -ti pb:debian-9-x86_64 /bin/bash
pb --version
cd /etc/apt/sources.list.d/
apt-get install gnupg
wget -qO - ftp://ftp.mondorescue.org/debian/9/pb.pubkey | apt-key add -
wget ftp://ftp.mondorescue.org/debian/9/pb.sources.list
apt-get update
apt-get install project-builder
pb --version

# On a rpm based distro
pb -p pb -m fedora-25-x86_64 
docker run -ti pb:fedora-25-x86_64 /bin/bash
pb --version
cd /etc/yum.repos.d
wget ftp://ftp.mondorescue.org/fedora/25/x86_64/pb.repo
dnf install project-builder
pb --version

# WIth VMs
# Now  show how easy it's to build for another project for which I'm upstream
-> pb -p mondorescue -m debian-6.0-x86_64 sbx2ve

# Now  show how easy it's to build for another project for which I'm not upstream with patches
-> pb -p afio -r 2.5 -m debian-6.0-x86_64 sbx2ve

# Look at conf files
cat ~/.pbrc.yml
cat /home/rpmbootstrap/.pbrc.yml
cat ~/svn-git/pb/projects/afio/pbconf/2.5/afio.yml
cat ~/svn-git/pb/projects/afio/pbconf/2.5/afio/rpm/afio.spec
cat ~/svn-git/pb/projects/afio/pbconf/2.5/afio/deb/control
ls -R ~/svn-git/pb/projects/afio/pbconf/2.5/

# Short Lab
# in pblab account
# prepa
# As root
rm -rf /prj/svn
svnadmin create /prj/svn
cat >> /prj/svn/conf/authz << EOF
[/]
pblab = rw
* = r
EOF
cat >> /prj/svn/conf/passwd << EOF
pblab = pblab
EOF
cat > /prj/svn/conf/svnserve.conf << EOF
[general]
password-db = passwd
authz-db = authz
[sasl]
EOF
killall svnserve
~pblab/bin/rc.local

# as pblab
rm -rf pb .pbrc.yml
cat > afio.yml.add << EOF
  defpkgdir:
    afio : dummy
  pbpackager:
    default : Big Chief <bigchief@hp.com>
  projver:
    afio : 2.5
  projtag:
    afio : 1
  pbprojurl:
    afio : ftp://localhost/src/afio-2.5.tar.gz
  pbrepo:
    afio : ftp://localhost
EOF

pb -p afio clean
cat ~/.pbrc.yml
cat >> ~/.pbrc.yml << EOF
---
  pbconfurl:
    afio: svn://localhost/pb/afio/pbconf
EOF
echo "  pbdefdir:" >>  ~/.pbrc.yml
echo "    default: \$ENV{'HOME'}/pb" >>  ~/.pbrc.yml
mkdir pb
svn import pb svn://localhost/pb -m "Initial creation of pb repo"
# passwd asked here

cd pb
svn co svn://localhost/pb .
pb -p afio newproj afio
# passwd asked here

cat ~/afio.yml.add >> afio/pbconf/afio.yml
pb -p afio sbx2build

# with Ubuntu CD
cat >> ~/.pbrc.yml << EOF
  vmpath:
    default: /home/qemu
EOF

