Skip to content

Commit

Permalink
Update the build and packaging script for Fedora 37. (#109)
Browse files Browse the repository at this point in the history
Fedora 37 includes GNOME 43, which is not backwards compatible with packages built against older versions. We used to build new Fedora versions on Ubuntu, but they removed support for building RPM packages in 20.04. By updating the build script to run on Fedora, this allows us to release coreyberla's fix, resolving #108 and #101.

Co-authored-by: Geoffry Song <[email protected]>
  • Loading branch information
jewelpit and goffrie authored Dec 7, 2022
1 parent 5e788ac commit 8cc1635
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 129 deletions.
4 changes: 2 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
All notable changes to this project will be documented in this file.
Date based versioning is now used in this project. This is so that it doesn't get confused with the Dropbox desktop client.

Unreleased
----------
Version 2022.12.05
------------------
* Update to use libnautilus-extension-4 and gtk4, supporting Nautilus 43+.
* Fix various uses of deprecated APIs, such as the "DeprecationWarning: isSet() is deprecated" warning.
* Fix colors of ignored files in `dropbox filestatus`.
Expand Down
70 changes: 42 additions & 28 deletions HOWTO_PACKAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,60 @@

This is a work-in-progress guide on how to build Ubuntu, Debian, and
Fedora packages for nautilus-dropbox. It assumes you're building from
a 16.04 Ubuntu machine.
an Ubuntu 22.10 machine for the `.deb` build and a Fedora 37 machine for the `.rpm` build.

1. Obtain the signing key. Add it to your keyring using `gpg --import /path/to/key`.
1. Obtain the signing tarball and extract all of the files into your `~/.gnupg`
directory. If producing an RPM build, also import it into RPM with
`sudo rpm --import /path/to/key`.

2. Install the build dependencies.
2. On a Debian/Ubuntu machine:
1. Install dependencies:

This is a non-exhaustive list of what you'll need:
```
sudo apt-get install pbuilder debootstrap devscripts libnautilus-extension-dev cdbs gnome-common debian-archive-keyring python3-docutils
```
```
sudo apt-get install pbuilder debootstrap devscripts libnautilus-extension-dev mock rpm expect createrepo cdbs gnome-common debian-archive-keyring python3-docutils
```
2. Copy `.pbuilderrc` to `~/.pbuilderrc`
3. Copy .pbuilderrc to ~/.pbuilderrc
3. Create chroots for each of the Debian or Ubuntu builds you'll be doing.
4. Create chroots for each of the Debian or Ubuntu builds you'll be doing.
```
sudo DIST=trusty ARCH=i386 pbuilder create --debootstrapopts --variant=buildd
sudo DIST=trusty ARCH=amd64 pbuilder create --debootstrapopts --variant=buildd
sudo DIST=jessie ARCH=i386 pbuilder create --debootstrapopts --variant=buildd
sudo DIST=jessie ARCH=amd64 pbuilder create --debootstrapopts --variant=buildd
```
```
sudo DIST=trusty ARCH=i386 pbuilder create --debootstrapopts --variant=buildd
sudo DIST=trusty ARCH=amd64 pbuilder create --debootstrapopts --variant=buildd
sudo DIST=jessie ARCH=i386 pbuilder create --debootstrapopts --variant=buildd
sudo DIST=jessie ARCH=amd64 pbuilder create --debootstrapopts --variant=buildd
```
4. Build all the packages with: `python3 build_packages.py deb`
5. Add yourself to the mock group (create it if it doesn't exist), and
then logout and login for the group to take affect.
Probably you have to run `build_packages.py` command with `sudo` permission which
means you should add your root account to the mock group. Otherwise, you will see
`The password you typed is invalid.` error.
3. On a Fedora machine:
1. Install dependencies:
6. Copy rpm_resources/fedora-*.cfg to /etc/mock.
```
sudo dnf install devscripts libnautilus-extension-dev mock rpm rpm-sign rpmdevtools rpmlint expect createrepo cdbs gnome-common python3-docutils rpm-build gawk nautilus-devel
```
If you need to add new configs when we start targetting a new Fedora version,
you can find all the configs here: https://github.com/rpm-software-management/mock
2. Add yourself to the mock group (create it if it doesn't exist), and
then logout and login for the group to take affect.
`build_packages.py` will use `sudo` for a few of the commands, so add both
your user account and root to the group.
7. Copy rpm_resources/.rpmmacros to ~/.rpmmacros
3. Copy `rpm_resources/fedora-*.cfg` to `/etc/mock`.
8. Build all the packages with: `python3 build_packages.py`
If you need to add new configs when we start targetting a new Fedora
version, you can find all the configs here:
https://github.com/rpm-software-management/mock.
If the build is successful, a tar of the output will be in: /tmp/nautilus-dropbox-release.tar.gz
The configs in that repo are templatized, so you'll also have to manually
copy the template contents into your copy.
8. Update the ChangeLog with all the changes in the release.
4. Copy `rpm_resources/.rpmmacros` to `~/.rpmmacros`
9. Tag the release and push the tag to GitHub.
5. Build all the packages with: `python3 build_packages.py rpm`
4. Gather the built outputs from both machines, and put them in the repo root
(this step can be done on either machine). Run `python3 build_packages.py package`.
5. Update the ChangeLog with all the changes in the release.
6. Tag the release and push the tag to GitHub.
69 changes: 37 additions & 32 deletions build_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ def generate_packages(self):
assert self.system('rm -f /tmp/nautilus-dropbox-release.tar.gz') == 0

# Source
assert self.system('cp nautilus-dropbox-*.tar.bz2 /home/releng/result/packages') == 0
assert self.system('cp nautilus-dropbox-*.tar.bz2 /tmp/dbx_build/result/packages') == 0

# Get dropbox.py
assert self.system('make dropbox') == 0
assert self.system(
'cp {REPO_DIR}/dropbox /home/releng/result/packages/dropbox.py'.format(
'cp {REPO_DIR}/dropbox /tmp/dbx_build/result/packages/dropbox.py'.format(
REPO_DIR=REPO_DIR,
)) == 0

# Tar it up
assert self.system('cd /home/releng/result/; tar czvf /tmp/nautilus-dropbox-release.tar.gz *') == 0
assert self.system('cd /tmp/dbx_build/result/; tar czvf /tmp/nautilus-dropbox-release.tar.gz *') == 0

def build_deb(self, dist, arch):
assert self.system('sh generate-deb.sh') == 0
Expand All @@ -58,7 +58,7 @@ def build_deb(self, dist, arch):

def generate_deb_repo(self, distro_upper, codenames, dist, archs):
distro = distro_upper.lower()
result = '/home/releng/result/%s' % distro
result = '/tmp/dbx_build/result/%s' % distro
assert self.system('rm -rf %s' % result) == 0
assert self.system('mkdir -p %s/pool/main' % result) == 0
for arch in archs:
Expand All @@ -74,43 +74,43 @@ def generate_deb_repo(self, distro_upper, codenames, dist, archs):

# Add pacakge symlinks
files = os.listdir(os.path.join(result, 'pool', 'main'))
assert self.system('mkdir -p /home/releng/result/packages/%s' % distro) == 0
assert self.system('mkdir -p /tmp/dbx_build/result/packages/%s' % distro) == 0
for f in files:
if f.endswith('.deb'):
assert self.system('ln -s ../../%s/pool/main/%s /home/releng/result/packages/%s' %
assert self.system('ln -s ../../%s/pool/main/%s /tmp/dbx_build/result/packages/%s' %
(distro, f, distro)) == 0

def generate_yum_repo(self, distro_upper, codenames, dist, archs, dist_name):
distro = distro_upper.lower()
assert self.system('rm -rf /home/releng/result/fedora') == 0
assert self.system('mkdir -p /home/releng/result/fedora/pool/') == 0
assert self.system('rm -rf /tmp/dbx_build/result/fedora') == 0
assert self.system('mkdir -p /tmp/dbx_build/result/fedora/pool/') == 0

for arch in archs:
assert self.system('cp %s/%s-%s/result/*.rpm /home/releng/result/fedora/pool' % (MOCK_OUT, dist, arch)) == 0
assert self.system('cp %s/%s-%s/result/*.rpm /tmp/dbx_build/result/fedora/pool' % (MOCK_OUT, dist, arch)) == 0

files = os.listdir('/home/releng/result/fedora/pool')
files = os.listdir('/tmp/dbx_build/result/fedora/pool')
for f in files:
f = '/home/releng/result/fedora/pool/' + f
f = '/tmp/dbx_build/result/fedora/pool/' + f
newname = f.replace(dist_name, 'fedora')
os.rename(f, newname)

old = os.getcwd()
os.chdir('/home/releng/result/fedora')
os.chdir('/tmp/dbx_build/result/fedora')
try:
assert self.system('DISTS="%s" sh %s/create-yum-repo.sh' % (codenames, old)) == 0
finally:
os.chdir(old)

# Add pacakge symlinks
assert self.system('mkdir -p /home/releng/result/packages/%s' % distro) == 0
files = os.listdir('/home/releng/result/fedora/pool')
assert self.system('mkdir -p /tmp/dbx_build/result/packages/%s' % distro) == 0
files = os.listdir('/tmp/dbx_build/result/fedora/pool')
for f in files:
if re.match(r'nautilus-dropbox-[0-9.-]*\.fedora\.(i386|x86_64)\.rpm', f):
assert self.system('ln -s ../../%s/pool/%s /home/releng/result/packages/%s' %
assert self.system('ln -s ../../%s/pool/%s /tmp/dbx_build/result/packages/%s' %
(distro, f, distro)) == 0

def build_rpm(self, config):
# config='fedora-21-i386,fedora-21-x86_64'
# config='fedora-37-i386,fedora-37-x86_64'
assert self.system('sh generate-rpm.sh') == 0

path = None
Expand All @@ -132,7 +132,7 @@ def build_rpm(self, config):

try:
assert self.system(
'/usr/bin/mock -r {config} --resultdir={mock_config_out} rebuild {path}'.format(
'sudo /usr/bin/mock -r {config} --resultdir={mock_config_out} rebuild {path}'.format(
config=config,
mock_config_out=mock_config_out,
path=path)) == 0
Expand All @@ -141,7 +141,9 @@ def build_rpm(self, config):
self.system('cat %s/*.log >&2' % (mock_config_out,))
raise
else:
assert self.system('find %s/ -name *.rpm | xargs /usr/bin/expect sign-rpm.exp' % (
username = cmd('whoami').decode('utf-8')
assert self.system('sudo chown -R %s:%s %s' % (username, username, mock_config_out)) == 0
assert self.system('find %s/ -name *.rpm -exec /usr/bin/expect sign-rpm.exp {} \\;' % (
mock_config_out,)) == 0

def build_all(self):
Expand All @@ -153,25 +155,28 @@ def build_all(self):
with open("distro-info.sh") as f:
exec(f.read(), {}, info)

assert self.system('rm -rf /home/releng/result') == 0
assert self.system('mkdir -p /home/releng/result/packages') == 0
assert self.system('rm -rf /tmp/dbx_build/result') == 0
assert self.system('mkdir -p /tmp/dbx_build/result/packages') == 0

# Ubuntu
self.build_deb('trusty', 'i386')
self.build_deb('trusty', 'amd64')
self.generate_deb_repo('Ubuntu', info['UBUNTU_CODENAMES'], 'trusty', ['amd64', 'i386'])
if len(sys.argv) == 1 or 'deb' in sys.argv:
# Ubuntu
self.build_deb('trusty', 'i386')
self.build_deb('trusty', 'amd64')
self.generate_deb_repo('Ubuntu', info['UBUNTU_CODENAMES'], 'trusty', ['amd64', 'i386'])

# Debian
self.build_deb('jessie', 'i386')
self.build_deb('jessie', 'amd64')
self.generate_deb_repo('Debian', info['DEBIAN_CODENAMES'], 'jessie', ['amd64', 'i386'])
# Debian
self.build_deb('jessie', 'i386')
self.build_deb('jessie', 'amd64')
self.generate_deb_repo('Debian', info['DEBIAN_CODENAMES'], 'jessie', ['amd64', 'i386'])

# Fedora
self.build_rpm('fedora-21-i386')
self.build_rpm('fedora-21-x86_64')
self.generate_yum_repo('Fedora', info['FEDORA_CODENAMES'], 'fedora-21', ['i386', 'x86_64'], 'fc21')
if len(sys.argv) == 1 or 'rpm' in sys.argv:
# Fedora dropped 32-bit support several versions ago.
self.build_rpm('fedora-37-x86_64')
self.generate_yum_repo('Fedora', info['FEDORA_CODENAMES'], 'fedora-37', ['x86_64'], 'fc37')

self.generate_packages()
if len(sys.argv) == 1 or 'package' in sys.argv:
self.generate_packages()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Initialization

AC_INIT([nautilus-dropbox], 2020.03.04)
AC_INIT([nautilus-dropbox], 2022.12.05)

AM_INIT_AUTOMAKE([foreign])

Expand Down
2 changes: 1 addition & 1 deletion create-yum-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

# DISTS must be defined.
ARCHS="i386 x86_64"
ARCHS="x86_64"

for DIST in $DISTS; do

Expand Down
2 changes: 1 addition & 1 deletion distro-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# This file also gets execfile'd by python so don't do anything here besides set variables.
UBUNTU_CODENAMES="trusty utopic vivid wily xenial yakkety zesty artful bionic cosmic disco eoan"
DEBIAN_CODENAMES="jessie stretch buster sid"
FEDORA_CODENAMES="21 22 23 24 25 26 27 28 29 30 31"
FEDORA_CODENAMES="21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37"
Loading

0 comments on commit 8cc1635

Please sign in to comment.