Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the generic_package.sh script file #44

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Shwetha-Acharya
Copy link

This script file is used to build the rpms for
Debian and Ubuntu versions.

We can run this script on a ubuntu machine.
We create a chroot environment using pbuilder create.
This gives us the environment for both ubuntu and debian.
On this we build, sign and push the packages.

We update the changelogs and push them to the glusterfs-debian
repo as well.

Signed-off-by: Sheetal Pamecha [email protected]
Signed-off-by: hari gowtham [email protected]
Signed-off-by: Shwetha K Acharya [email protected]

This script file is used to build the rpms for
Debian and Ubuntu versions.

We can run this script on a ubuntu machine.
We create a chroot environment using pbuilder create.
This gives us the environment for both ubuntu and debian.
On this we build, sign and push the packages.

We update the changelogs and push them to the glusterfs-debian
repo as well.

Signed-off-by: Sheetal Pamecha <[email protected]>
Signed-off-by: hari gowtham <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
This helps in automating the packaging task of Gluster for
Debian and Ubuntu.

Change-Id: Icdbc718f0a3f020715d959486d01e962f89fa80f
Signed-off-by: hari gowtham <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
- string:
default:
description: Release number for the package to be built against.
Leave it empty if you are building above series 5.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh, what is series 5, you mean version 5 branch ? is it still supported, or can we drp it ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop them off.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the comment is still here, what is series 5 ? Do you mean "release 5" ? (and if we can drop, should it be removed from the description ?)

build-gluster-org/scripts/debian-ubuntu-package.sh Outdated Show resolved Hide resolved
../scripts/generic_package.sh ubuntu focal $SERIES $VERSION $RELEASE
elif [ "$OS" == "debian" ]; then
echo "packing debian alone"
if [ "$FLAVOR" == "stretch" ] || [ "$FLAVOR" == "9" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to have 1 single if with the 6 possibles values than 3 separate ones.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please elaborate this comment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, here we have 3 lines with if, they all run the same script with the same argument, the only difference is the echo. This seems harder to read while :

case $FLAVOR in
"stretch" | "9" | "buster" | "10" | "bullseye" | "11")
../scripts/generic_package.sh $OS $FLAVOR $SERIES $VERSION $RELEASE $LATEST_SERIES $LATEST_VERSION

is shorter

tar czf ~/${os}-${flavor}-Glusterfs-${version}/${flavor}-apt-amd64-${version}.tgz pool/ dists/

echo "Pushing Changelog changes.."
git push origin ${flavor}-${series}-local:${flavor}-glusterfs-${series}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to work if the clone is done over HTTP

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, but I still see https for the clone. I was not precise enough, I want to point that we can't push over http, including https. And if we need to push a new changelog, we need a ssh key.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clone is now changed to ssh

build-gluster-org/scripts/generic_package.sh Outdated Show resolved Hide resolved
sudo pbuilder build ~/${os}-${flavor}-Glusterfs-${version}/build/glusterfs_${version}-${release}.dsc | tee build.log

#move the packages to packages directory.
mv /var/cache/pbuilder/result/glusterfs*${version}-${release}*.deb ~/${os}-${flavor}-Glusterfs-${version}/packages/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure jenkins used can erase file in /var/cache , so mv would fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kalebskeithley Any suggestions on this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can safely replaced by "cp", at least.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to still be mv :/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But these files should be removed to avoid eventual filling up of space, How is such case handled generally with jenkins? @mscherer

echo "Uploading the packages.."
if [ "$os" == "ubuntu" ]; then
cd ..
dput ppa:gluster/glusterfs-${series} glusterfs_${version}-${os}1~${flavor}1_source.changes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it requires some authentication ? I do not see how it is done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, AIFIK. @kalebskeithley any more insights?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if could be without authentication, but then, we need some kind of signature, cause I do not think anyone can push debian package for us, no ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we would need to follow https://help.launchpad.net/Packaging/PPA/Uploading to get required authentiacation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation do not tell much, but if that use ssh, then we need to have the key available to the builder, which is not declared in the job yaml file. There is example here: https://github.com/gluster/build-jobs/blob/master/build-gluster-org/jobs/centos7-regression.yml#L64 for adding a credential

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenPGP keys are used for signing as described here
The above link also shows how a new key can be created and added to launcpad account.

$ gpg --list-keys on the machine rhs-vm-17.storage-dev.lab.eng.bos.redhat.com under the user glusterpackager, shows the already existing keys. (documented the same in the mojo doc draft: let me know if any more information is needed to be documented)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's a internal VM, and Jenkins is hosted outside of the lan. I may miss something obvious, but Jenkins can't connect to that server, and I think Product Security would strongly dislike that a external server (build.gluster.org) is able to remotely execute any code on a internal system ( rhs-vm-17.storage-dev.lab.eng.bos.redhat.com ).

So we need to have the key as secret in the job, and store that in Jenkins. We can't use RH internal system.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can store the key as secret in the job. We can add it in jenkins machine, I can help in getting it from rhs-vm-17.storage-dev.lab.eng.bos.redhat.com


echo "Building source package.."
cd ../glusterfs-${version}
debuild -S -sa -k${debuild_key}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would the signing key stored ? (since -k requires that)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debuild_key variable contains the key.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't clear on my question. From what I understand, -k is the key identifier. But the actual private key is somewhere else (I think in ~/.gnupg), and so we need to discuss how that part is going to be managed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are initialising the values for debuild keys in https://github.com/gluster/build-jobs/pull/44/files/b32e0625d90b8c89432e753aab502d5e72b64b46#diff-02d2c32f5282eea2a7412f831420ae8c2f55ce0ed17671f6878e110c258b2e6bR29

The key creation is something we have maintained in a particular machine, whose access is not given to wider audience.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, where is that machine ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Page does not exist :/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build-gluster-org/scripts/generic_package.sh Outdated Show resolved Hide resolved
build-gluster-org/scripts/generic_package.sh Outdated Show resolved Hide resolved

cd /var/www/repos/apt/debian/

rm -rf pool/* dists/* db/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure jenkins can erase file there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a trail run to verify it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if we create file here, shouldn't it be cleaned with a trap, like the rest ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, can be done

This helps in automating the packaging task of Gluster for
Debian and Ubuntu.

Change-Id: Icdbc718f0a3f020715d959486d01e962f89fa80f
Signed-off-by: hari gowtham <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
This helps in automating the packaging task of Gluster for
Debian and Ubuntu.

Change-Id: Icdbc718f0a3f020715d959486d01e962f89fa80f
Signed-off-by: hari gowtham <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
update mv to cp

Signed-off-by: Shwetha K Acharya <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
@Shwetha-Acharya
Copy link
Author

Requesting next round of review @mscherer

#removing folders created while packaging
rm -rf ~/${os}-${flavor}-Glusterfs-${version}
}
trap finish EXIT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traps should be placed at the start of the script. Otherwise, it be used only when the script is over, which is not useful.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

#copy the tar.gz file produced by the build to download.rht.gluster.org:/var/www/scratch
scp $flavor-apt-amd64-$version.tgz [email protected]:/var/www/scratch

ssh [email protected] /var/www/html/pub/gluster/unpacking-script.sh series version os flavor latest_version latest_series
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be "$version", etc ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


#move the packages to packages directory.
cp /var/cache/pbuilder/result/glusterfs*${version}-${release}*.deb ~/${os}-${flavor}-Glusterfs-${version}/packages/
rm -rf /var/cache/pbuilder/result/glusterfs*${version}-${release}*.deb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not mv instead of cp + rm ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

cp /var/cache/pbuilder/result/glusterfs*${version}-${release}*.deb ~/${os}-${flavor}-Glusterfs-${version}/packages/
rm -rf /var/cache/pbuilder/result/glusterfs*${version}-${release}*.deb

if [ "$flavor" != "stretch" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, why is stretch special here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because /var/cache/pbuilder/result/libg*${version}-${release}*.deb are not created only in stretch. In buster and bullseye, they will be created

replace cp+rm with mv
add misisng $

Signed-off-by: Shwetha K Acharya <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
Signed-off-by: Shwetha K Acharya <[email protected]>
@Shwetha-Acharya
Copy link
Author

@mscherer all the requested change sets are uploaded.

Base automatically changed from master to main February 17, 2021 09:51
@mscherer
Copy link
Collaborator

mscherer commented Mar 9, 2021

So, since the review is getting a bit messy with comments, the blocking part is the gpg key secret integration for now.

@mscherer
Copy link
Collaborator

mscherer commented Mar 9, 2021

(and conflicts)

name: ANNOUNCE_EMAIL

builders:
- shell: /opt/qa/debian-ubuntu-package.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Location is not correct. You have added the file in build-gluster-org/scripts/debian-ubuntu-package.sh

according to the actual loaction of the script

Signed-off-by: Shwetha K Acharya <[email protected]>
echo "building everything"
echo "packing debian distribution"
for i in ${!deb_flavors[@]}; do
~/build-gluster-org/scripts/generic_package.sh debian ${deb_flavors[$i]} $SERIES $VERSION $RELEASE $LATEST_SERIES $LATEST_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This location is wrong here. It should be ${WORKSPACE}/build-gluster-org/scripts/generic_package.sh

@Shwetha-Acharya
Copy link
Author

So, since the review is getting a bit messy with comments, the blocking part is the gpg key secret integration for now.

Action plan to resolve gpg key integration part: https://docs.google.com/document/d/1KRuzMC9zPD6K-5k03_5vUGjWrR0kUFiN2UhaYm18phQ/edit?usp=sharing

Also as agreed earlier, infra team is upposed to create the following users for these scripts to work:

  1. user named gluster_ant in the build machine, who has permission to access download.rht.gluster.org , so that
    built packages can be pushed to download.rht.gluster.org

  2. github user so that script can push the changelogs to respective github reposotories.

@@ -0,0 +1,57 @@
- job:
name: debian-package-builder
node: master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the label debian10 for this job. We have a machine existing on jenkins https://build.gluster.org/computer/builder-deb10-1.int.rht.gluster.org/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepshikhaaa please validate the liburing-devel support as well.

@Shwetha-Acharya
Copy link
Author

Shwetha-Acharya commented Jul 8, 2021

We need a machaine with kernel 5.1 or above inorder to enable io-uring support with the builds. Please let me know which node can be used.

As mentioned earlier there is an Action plan to resolve gpg key integration part.

@mscherer @deepshikhaaa can we take this forward?
Going forward it is very much essential to keep this packaging and building part automated.

@mscherer
Copy link
Collaborator

We only have Debian 10 hosts, not Ubuntu one. I can try to spin a Ubuntu one but that would be the 1st we have, so I am unsure how long it will take.

@mscherer
Copy link
Collaborator

Ok so the Ubuntu installer do not work (and I do not understand why yet, there is no obvious error message). But so, do we need the kernel to be up to date for package building ? Given this will use a pbuilder, the headers would be there and nothing more should be needed, unless I am missing something ?

@mscherer
Copy link
Collaborator

So the Ubuntu installer didn't work because:

  • the firewall blocked the network (each time, i forget)
  • some weird ansible issue with variable (so it was installing centos), I fixed
  • then ubuntu changed the installer and so our RHEL 7 host is too old to detect that

So I am doing 18.04 and upgrade manually.

@Shwetha-Acharya
Copy link
Author

Ok so the Ubuntu installer do not work (and I do not understand why yet, there is no obvious error message). But so, do we need the kernel to be up to date for package building ? Given this will use a pbuilder, the headers would be there and nothing more should be needed, unless I am missing something ?

Right, in this script the latest chroot will be created. We would require a ubuntu mechine as discussed offline as it is tested in ubuntu.

@mscherer
Copy link
Collaborator

But testing is done on a different job than the packaging one, no ? I still do not get the issue, at what point is the deb packages tested, and how ?

@mscherer
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants