Merge lp:~mwhudson/ubuntu-cdimage/netboot-tarball into lp:ubuntu-cdimage

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 2053
Merged at revision: 2065
Proposed branch: lp:~mwhudson/ubuntu-cdimage/netboot-tarball
Merge into: lp:ubuntu-cdimage
Diff against target: 384 lines (+190/-3)
5 files modified
lib/cdimage/build.py (+18/-0)
lib/cdimage/livefs.py (+2/-1)
lib/cdimage/tests/test_livefs.py (+2/-0)
lib/cdimage/tests/test_tree.py (+45/-0)
lib/cdimage/tree.py (+123/-2)
To merge this branch: bzr merge lp:~mwhudson/ubuntu-cdimage/netboot-tarball
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Review via email: mp+423215@code.launchpad.net

Commit message

Publish netboot tarballs from livecd-rootfs

Description of the change

This is the companion part to https://code.launchpad.net/~mwhudson/livecd-rootfs/+git/livecd-rootfs/+merge/423209.

It downloads the netboot tarball that livecd-rootfs change makes and publishes it alongside the ISO, rewriting the config files to refer to where the ISO is being published. It turns out that if you name various files *just so* then a lot of things are taken care of by general machinery, but that general machinery is pretty opaque. Oh well!

I've tried to keep the code fairly generic so if we want, say, the desktop build to start spitting out netboot tarballs no changes should be required here.

The glaring thing this is missing that has to be addressed before merge is release publication, which will have to rewrite the config files again (which probably means we should put the unmodified netboot tarball file in the published directory too but hide it from the index... hmm...).

The other thing that I want to do is generate some nice headers and footers for the netboot/ directory and generate some snippets somewhere that have example dhcpd and dnsmasq config.

I've tested code like this, but I refactored a bit before review and haven't tested exactly this code. So it might be a bit broken.

To post a comment you must log in.
2040. By Michael Hudson-Doyle

download netboot tarball from livefs

2041. By Michael Hudson-Doyle

copy netboot tarball to location suitable for publication to find it

2042. By Michael Hudson-Doyle

copy any netboot tarball to target directory when publishing

2043. By Michael Hudson-Doyle

rewrite #ISOURL# to the url to the iso when publishing netboot tarball

2044. By Michael Hudson-Doyle

unpack netboot tarball during publication as well

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I've tested this now and it seems to work! I uploaded the result of a run to https://people.canonical.com/~mwh/20220525/ and it all looks fairly plausible to me (don't try to use the ISOs in that page, I shrank them to 100M before upload)

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

In general this feels good. Of course the re-tarring of the tarball is a bit controversial, but makes sense in this case - especially that per the specification we also want the contents to be untarred in the netboot/ directory anyway.

Left a few inline comments with some things that need changing though. Another thing that needs fixing is: we need unit tests for this new case. The cdimage codebase has usually quite a good test suit, so whenever we add something new, we should make sure it's tested as well. This way we can know if it works-ish.

That being said, I think currently the unit tests are failing! Mostly because of some issues with the simplestreams tests. I have a ticket open for that, so I'll try to fix those in the nearest week. For now, I'd recommend to just running a clean cdimage test run, noting which tests fail and then running with the new codebase + new tests ;p Sorry about that.

review: Needs Fixing
2045. By Michael Hudson-Doyle

add simple test to test_livefs.py

2046. By Michael Hudson-Doyle

add tests for and comments to publish_netboot

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

> In general this feels good.

Thanks!

> Of course the re-tarring of the tarball is a bit
> controversial, but makes sense in this case - especially that per the
> specification we also want the contents to be untarred in the netboot/
> directory anyway.

Yeah, that's definitely feels a bit unusual. One consequence is that we'll have to do it again when doing the release publication -- not sure the code is set up for that though, does it recompute checksums as part of release publication? (I guess given that in general, not every arch gets published, it must?)

> Left a few inline comments with some things that need changing though. Another
> thing that needs fixing is: we need unit tests for this new case. The cdimage
> codebase has usually quite a good test suit, so whenever we add something new,
> we should make sure it's tested as well. This way we can know if it works-ish.

Good point. I've added test cases to test_livefs.py and test_tree.py. Couldn't figure out how to test the build.py change!

Revision history for this message
Michael Hudson-Doyle (mwhudson) :
2047. By Michael Hudson-Doyle

release publication for netboot tarballs, maybe?

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I added some stuff around release publication but it doesn't get the release URLs right. I don't think I understand how the directories release publication puts things in map to URLs on releases.ubuntu.com yet...

2048. By Michael Hudson-Doyle

a little refactoring. add a comment where there is something wrong

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

This looks okay. There's two inline comments that can be addressed but don't have to be.

As for the publish bits - without any test coverage for those, it's hard to see if the release URLs are right or not. Can you maybe paste what end URLs are you getting in the tarball with the current changes? It would make it much easier for me to figure out how to make the mapping better.

Let's merge this tomorrow after we discuss those ^

review: Approve
2049. By Michael Hudson-Doyle

fix tarball save path

2050. By Michael Hudson-Doyle

more fixes

2051. By Michael Hudson-Doyle

rewrite SimpleReleaseTree.url_for_path a bit

2052. By Michael Hudson-Doyle

logging, dry run

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

> This looks okay. There's two inline comments that can be addressed but don't
> have to be.

Thanks. I actually hadn't pushed my most recent commit and it was interesting coming back to this code after a week or two, I think it helped me see the wood for the trees a bit.

> As for the publish bits - without any test coverage for those, it's hard to
> see if the release URLs are right or not. Can you maybe paste what end URLs
> are you getting in the tarball with the current changes? It would make it much
> easier for me to figure out how to make the mapping better.

I think I have this right now, lets see, for daily publication:

SUBPROJECT=live DIST=jammy PROJECT=ubuntu-server-live for-project ubuntu-server cron.daily-live

gives in the log:

Rewriting /home/ubuntu/cdimage/www/full/ubuntu-server/jammy/daily-live/20220621.6/.jammy-netboot-amd64.tar.gz to /home/ubuntu/cdimage/www/full/ubuntu-server/jammy/daily-live/20220621.6/jammy-netboot-amd64.tar.gz with iso_url=https://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/20220621.6/jammy-live-server-amd64.iso

And publish-release seems to do the right thing now:

DIST=jammy for-project ubuntu publish-release --dry-run ubuntu-server/daily-live 20220621.5 live-server yes
...
Rewriting /home/ubuntu/cdimage/www/full/ubuntu-server/jammy/daily-live/20220621.5/.jammy-netboot-amd64.tar.gz to /home/ubuntu/cdimage/www/simple/jammy/ubuntu-22.04-netboot-amd64.tar.gz with iso_url=https://releases.ubuntu.com/22.04/ubuntu-22.04-live-server-amd64.iso

DIST=jammy for-project ubuntu publish-release --dry-run ubuntu-server/daily-live 20220621.5 live-server named
...
Rewriting /home/ubuntu/cdimage/www/full/ubuntu-server/jammy/daily-live/20220621.5/.jammy-netboot-amd64.tar.gz to /home/ubuntu/cdimage/www/full/releases/jammy/release/ubuntu-22.04-netboot-amd64.tar.gz with iso_url=https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04-live-server-amd64.iso

> Let's merge this tomorrow after we discuss those ^

Looking forward to it :-)

Revision history for this message
Michael Hudson-Doyle (mwhudson) :
2053. By Michael Hudson-Doyle

sigh

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Okay, I think this looks good now. So merging this branch causes some tests to fail, but I can fix those after merging this. They're trivial to fix it seems. So don't worry about those! But a note for the future: even if tests are not 100% green, be sure to check if your branch doesn't cause new test failures ;p (the test case should be much happier now though)

Revision history for this message
Łukasz Zemczak (sil2100) :
review: Approve
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Thanks for the review and merge and sorry about the tests! I should see if I can write some tests for the release publication I guess.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/cdimage/build.py'
--- lib/cdimage/build.py 2022-06-02 05:07:57 +0000
+++ lib/cdimage/build.py 2022-06-21 04:29:40 +0000
@@ -523,6 +523,23 @@
523 snap, "%s.%s.snap" % (output_prefix, snaptype))523 snap, "%s.%s.snap" % (output_prefix, snaptype))
524524
525525
526def copy_netboot_tarballs(config):
527 # cp $scratch/$arch.netboot.tar.gz $output/$series-netboot-$arch.tar.gz
528 scratch_dir = os.path.join(
529 config.root, "scratch", config.project, config.full_series,
530 config.image_type)
531 for arch in config.arches:
532 netboot_path = os.path.join(
533 live_output_directory(config),
534 '%s.netboot.tar.gz' % (arch,))
535 if os.path.exists(netboot_path):
536 output_dir = os.path.join(scratch_dir, "debian-cd", arch)
537 shutil.copy2(
538 netboot_path, os.path.join(
539 output_dir,
540 '%s-netboot-%s.tar.gz' % (config.series, arch)))
541
542
526def _debootstrap_script(config):543def _debootstrap_script(config):
527 return "usr/share/debootstrap/scripts/%s" % config.series544 return "usr/share/debootstrap/scripts/%s" % config.series
528545
@@ -724,6 +741,7 @@
724 configure_splash(config)741 configure_splash(config)
725742
726 run_debian_cd(config)743 run_debian_cd(config)
744 copy_netboot_tarballs(config)
727 fix_permissions(config)745 fix_permissions(config)
728746
729 # Temporarily turned off for live builds.747 # Temporarily turned off for live builds.
730748
=== modified file 'lib/cdimage/livefs.py'
--- lib/cdimage/livefs.py 2022-06-10 12:55:35 +0000
+++ lib/cdimage/livefs.py 2022-06-21 04:29:40 +0000
@@ -560,7 +560,7 @@
560 "azure.device.tar.gz", "raspi2.device.tar.gz", "plano.device.tar.gz",560 "azure.device.tar.gz", "raspi2.device.tar.gz", "plano.device.tar.gz",
561 "tar.xz", "iso", "os.snap", "kernel.snap", "disk1.img.xz",561 "tar.xz", "iso", "os.snap", "kernel.snap", "disk1.img.xz",
562 "dragonboard.kernel.snap", "raspi2.kernel.snap",562 "dragonboard.kernel.snap", "raspi2.kernel.snap",
563 "img.xz", "model-assertion", "qcow2", "yaml",563 "img.xz", "model-assertion", "qcow2", "yaml", "netboot.tar.gz"
564 ):564 ):
565 if item == "ext4" and arch == "armhf+nexus7":565 if item == "ext4" and arch == "armhf+nexus7":
566 for url in urls_for(566 for url in urls_for(
@@ -793,6 +793,7 @@
793 elif download_live_items(config, arch, "squashfs"):793 elif download_live_items(config, arch, "squashfs"):
794 download_live_items(config, arch, "modules.squashfs")794 download_live_items(config, arch, "modules.squashfs")
795 download_live_items(config, arch, "yaml")795 download_live_items(config, arch, "yaml")
796 download_live_items(config, arch, "netboot.tar.gz")
796 got_image = True797 got_image = True
797 elif download_live_items(config, arch, "rootfs.tar.gz"):798 elif download_live_items(config, arch, "rootfs.tar.gz"):
798 got_image = True799 got_image = True
799800
=== modified file 'lib/cdimage/tests/test_livefs.py'
--- lib/cdimage/tests/test_livefs.py 2022-05-29 19:28:43 +0000
+++ lib/cdimage/tests/test_livefs.py 2022-06-21 04:29:40 +0000
@@ -1272,6 +1272,8 @@
1272 "bionic", "squashfs", ["installer.squashfs"])1272 "bionic", "squashfs", ["installer.squashfs"])
1273 self.assert_server_live_download_items(1273 self.assert_server_live_download_items(
1274 "bionic", "yaml", ["installer.yaml"])1274 "bionic", "yaml", ["installer.yaml"])
1275 self.assert_server_live_download_items(
1276 "bionic", "netboot.tar.gz", ["netboot.tar.gz"])
12751277
1276 def test_download_live_server_boot_items(self):1278 def test_download_live_server_boot_items(self):
1277 self.assert_server_live_download_items(1279 self.assert_server_live_download_items(
12781280
=== modified file 'lib/cdimage/tests/test_tree.py'
--- lib/cdimage/tests/test_tree.py 2022-05-29 19:39:25 +0000
+++ lib/cdimage/tests/test_tree.py 2022-06-21 04:29:40 +0000
@@ -24,10 +24,12 @@
24 from html.parser import HTMLParser24 from html.parser import HTMLParser
25except ImportError:25except ImportError:
26 from HTMLParser import HTMLParser26 from HTMLParser import HTMLParser
27import io
27import os28import os
28import shutil29import shutil
29import sys30import sys
30from textwrap import dedent31from textwrap import dedent
32import tarfile
31import traceback33import traceback
3234
33try:35try:
@@ -891,6 +893,46 @@
891 target_dir, "%s-desktop-i386.iso.zsync" % self.config.series),893 target_dir, "%s-desktop-i386.iso.zsync" % self.config.series),
892 "%s-desktop-i386.iso" % self.config.series)894 "%s-desktop-i386.iso" % self.config.series)
893895
896 def test_publish_netboot(self):
897 publisher = self.make_publisher("ubuntu-server", "daily-live")
898 source_dir = publisher.image_output("amd64")
899 tarname = "%s-netboot-amd64.tar.gz" % self.config.series
900 isoname = "%s-live-server-amd64.iso" % self.config.series
901 date = "20201215"
902 os.makedirs(source_dir)
903 with tarfile.open(os.path.join(source_dir, tarname), 'w:gz') as tf:
904 ti = tarfile.TarInfo('config.in')
905 content = b'v=#ISOURL#'
906 ti.size = len(content)
907 tf.addfile(ti, io.BytesIO(content))
908 target_dir = os.path.join(publisher.publish_base, date)
909 target_image = os.path.join(target_dir, isoname)
910 touch(target_image)
911
912 publisher.publish_netboot("amd64", target_image)
913
914 self.assertCountEqual([
915 tarname,
916 isoname,
917 "netboot",
918 ], os.listdir(target_dir))
919 self.assertCountEqual([
920 "config",
921 ], os.listdir(os.path.join(target_dir, "netboot")))
922 with open(os.path.join(target_dir, "netboot/config")) as fp:
923 self.assertEqual(
924 'v=https://%s/ubuntu-server/daily-live/%s/%s' % (
925 publisher.tree.site_name, date, isoname),
926 fp.read())
927 with tarfile.open(os.path.join(target_dir, tarname), 'r:gz') as tf:
928 for ti in tf:
929 self.assertEqual(ti.name, 'config')
930 self.assertEqual(
931 ('v=https://%s/ubuntu-server/daily-live/%s/%s' % (
932 publisher.tree.site_name, date, isoname)
933 ).encode('utf-8'),
934 tf.extractfile(ti).read())
935
894 @mock.patch("cdimage.osextras.find_on_path", return_value=True)936 @mock.patch("cdimage.osextras.find_on_path", return_value=True)
895 @mock.patch("cdimage.tree.DailyTreePublisher.detect_image_extension",937 @mock.patch("cdimage.tree.DailyTreePublisher.detect_image_extension",
896 return_value="img.xz")938 return_value="img.xz")
@@ -2084,6 +2126,9 @@
2084 def test_publish_core_binary(self):2126 def test_publish_core_binary(self):
2085 pass2127 pass
20862128
2129 def test_publish_netboot(self):
2130 pass
2131
2087 def test_publish_appliance_binary(self):2132 def test_publish_appliance_binary(self):
2088 pass2133 pass
20892134
20902135
=== modified file 'lib/cdimage/tree.py'
--- lib/cdimage/tree.py 2022-06-08 08:29:32 +0000
+++ lib/cdimage/tree.py 2022-06-21 04:29:40 +0000
@@ -20,6 +20,7 @@
20from __future__ import print_function20from __future__ import print_function
2121
22import errno22import errno
23import io
23from itertools import count24from itertools import count
24from optparse import OptionParser25from optparse import OptionParser
25import os26import os
@@ -33,6 +34,7 @@
33import stat34import stat
34import subprocess35import subprocess
35import sys36import sys
37import tarfile
36from textwrap import dedent38from textwrap import dedent
37import time39import time
38import traceback40import traceback
@@ -93,6 +95,35 @@
93 subprocess.check_call(command)95 subprocess.check_call(command)
9496
9597
98def rewrite_and_unpack_tarball(dry_run, source_path, target_path, iso_url):
99 logger.info(
100 "Rewriting %s to %s with iso_url=%s",
101 source_path, target_path, iso_url)
102 if dry_run:
103 return
104 iso_url_b = iso_url.encode('utf-8')
105 netboot_dir = os.path.join(os.path.dirname(target_path), 'netboot')
106 osextras.ensuredir(netboot_dir)
107
108 with tarfile.open(source_path) as inf:
109 with tarfile.open(target_path, 'w:gz') as outf:
110 for ti in inf:
111 if ti.name.endswith('.in'):
112 new_ti = inf.getmember(ti.name)
113 new_ti.name = ti.name[:-3]
114 content = inf.extractfile(ti).read()
115 content = content.replace(b"#ISOURL#", iso_url_b)
116 new_ti.size = len(content)
117 with open(
118 os.path.join(netboot_dir, new_ti.name),
119 'wb') as fp:
120 fp.write(content)
121 outf.addfile(new_ti, io.BytesIO(content))
122 else:
123 inf.extract(ti, netboot_dir)
124 outf.addfile(ti, inf.extractfile(ti))
125
126
96class Tree:127class Tree:
97 """A publication tree."""128 """A publication tree."""
98129
@@ -168,6 +199,13 @@
168 """Return the public host name corresponding to this tree."""199 """Return the public host name corresponding to this tree."""
169 raise NotImplementedError200 raise NotImplementedError
170201
202 def url_for_path(self, path):
203 """Return the public URL for the file at `path`.
204
205 `path` must be under self.directory.
206 """
207 raise NotImplementedError
208
171 def path_to_manifest(self, path):209 def path_to_manifest(self, path):
172 """Return a manifest file entry for a tree-relative path.210 """Return a manifest file entry for a tree-relative path.
173211
@@ -487,6 +525,8 @@
487 return "classroom server %s" % cd525 return "classroom server %s" % cd
488 else:526 else:
489 return "server install %s" % cd527 return "server install %s" % cd
528 elif publish_type == "netboot":
529 return "netboot tarball"
490 elif publish_type == "legacy-server":530 elif publish_type == "legacy-server":
491 return "legacy server install %s" % cd531 return "legacy server install %s" % cd
492 elif publish_type == "serveraddon":532 elif publish_type == "serveraddon":
@@ -579,6 +619,10 @@
579 sentences.append(619 sentences.append(
580 "The install %s allows you to install %s permanently on a "620 "The install %s allows you to install %s permanently on a "
581 "computer." % (cd, capproject))621 "computer." % (cd, capproject))
622 elif publish_type == "netboot":
623 sentences.append(
624 "The netboot tarball contains files needed to boot the %s "
625 "installer over the network." % (capproject,))
582 elif publish_type == "alternate":626 elif publish_type == "alternate":
583 sentences.append(627 sentences.append(
584 "The alternate install %s allows you to perform certain "628 "The alternate install %s allows you to perform certain "
@@ -1121,6 +1165,7 @@
1121 all_publish_types = (1165 all_publish_types = (
1122 "live", "desktop",1166 "live", "desktop",
1123 "live-server",1167 "live-server",
1168 "netboot",
1124 "legacy-server",1169 "legacy-server",
1125 "server", "install", "alternate",1170 "server", "install", "alternate",
1126 "serveraddon", "addon",1171 "serveraddon", "addon",
@@ -1653,7 +1698,8 @@
1653 print("ReadmeName FOOTER.html", file=htaccess)1698 print("ReadmeName FOOTER.html", file=htaccess)
1654 print(1699 print(
1655 "IndexIgnore .htaccess HEADER.html FOOTER.html "1700 "IndexIgnore .htaccess HEADER.html FOOTER.html "
1656 "published-ec2-daily.txt published-ec2-release.txt",1701 "published-ec2-daily.txt published-ec2-release.txt "
1702 ".*.tar.gz",
1657 file=htaccess)1703 file=htaccess)
1658 print(1704 print(
1659 "IndexOptions NameWidth=* DescriptionWidth=* "1705 "IndexOptions NameWidth=* DescriptionWidth=* "
@@ -1760,6 +1806,16 @@
1760 def site_name(self):1806 def site_name(self):
1761 return "cdimage.ubuntu.com"1807 return "cdimage.ubuntu.com"
17621808
1809 def url_for_path(self, path):
1810 logger.info(
1811 "url_for_path(%s), self.directory = %s", path, self.directory)
1812 if not path.startswith(self.directory):
1813 raise Exception(
1814 "url_for_path(%r) did not start with self.directory (%r)"
1815 % (path, self.directory))
1816 url_path = path[len(self.directory):].lstrip('/')
1817 return "https://%s/%s" % (self.site_name, url_path)
1818
1763 def manifest_files(self):1819 def manifest_files(self):
1764 """Yield all the files to include in a manifest of this tree."""1820 """Yield all the files to include in a manifest of this tree."""
1765 seen_inodes = []1821 seen_inodes = []
@@ -2002,6 +2058,30 @@
2002 for line in jigdo_in:2058 for line in jigdo_in:
2003 jigdo_out.write(line.replace(from_line, to_line))2059 jigdo_out.write(line.replace(from_line, to_line))
20042060
2061 def publish_netboot(self, arch, image_path):
2062 # Publishing a netboot tarball is a bit more complicated than
2063 # just copying it into place, as we also unpack it into a
2064 # netboot/ directory and replace rewrite any foo.cfg.in files
2065 # referencing #ISOURL# to foo.cfg referencing the actual URL
2066 # of the image.
2067 #
2068 # We also save a copy of the netboot tarball so we can rewrite
2069 # it again during release publication.
2070 tarname = "%s-netboot-%s.tar.gz" % (self.config.series, arch)
2071 source_path = os.path.join(self.image_output(arch), tarname)
2072 if not os.path.exists(source_path):
2073 return
2074
2075 save_target_path = os.path.join(
2076 os.path.dirname(image_path), '.' + tarname)
2077 target_path = os.path.join(os.path.dirname(image_path), tarname)
2078
2079 shutil.move(source_path, save_target_path)
2080
2081 rewrite_and_unpack_tarball(
2082 False, save_target_path, target_path,
2083 self.tree.url_for_path(image_path))
2084
2005 def publish_binary(self, publish_type, arch, date):2085 def publish_binary(self, publish_type, arch, date):
2006 in_prefix = "%s-%s-%s" % (self.config.series, publish_type, arch)2086 in_prefix = "%s-%s-%s" % (self.config.series, publish_type, arch)
2007 if publish_type == "live-core":2087 if publish_type == "live-core":
@@ -2024,9 +2104,11 @@
2024 logger.info("Publishing %s ..." % arch)2104 logger.info("Publishing %s ..." % arch)
2025 osextras.ensuredir(target_dir)2105 osextras.ensuredir(target_dir)
2026 extension = self.detect_image_extension(source_prefix)2106 extension = self.detect_image_extension(source_prefix)
2107 target_path = "%s.%s" % (target_prefix, extension)
2027 shutil.move(2108 shutil.move(
2028 "%s.%s" % (source_prefix, self.source_extension),2109 "%s.%s" % (source_prefix, self.source_extension),
2029 "%s.%s" % (target_prefix, extension))2110 target_path)
2111 self.publish_netboot(arch, target_path)
2030 if os.path.exists("%s.list" % source_prefix):2112 if os.path.exists("%s.list" % source_prefix):
2031 shutil.move("%s.list" % source_prefix, "%s.list" % target_prefix)2113 shutil.move("%s.list" % source_prefix, "%s.list" % target_prefix)
2032 self.checksum_dirs.append(source_dir)2114 self.checksum_dirs.append(source_dir)
@@ -2938,6 +3020,12 @@
2938 directory = os.path.join(config.root, "www", "simple")3020 directory = os.path.join(config.root, "www", "simple")
2939 super(SimpleReleaseTree, self).__init__(config, directory)3021 super(SimpleReleaseTree, self).__init__(config, directory)
29403022
3023 def url_for_path(self, path):
3024 series = self.config["DIST"]
3025 version = getattr(series, "pointversion", series.version)
3026 basename = os.path.basename(path)
3027 return "https://%s/%s/%s" % (self.site_name, version, basename)
3028
2941 def get_publisher(self, image_type, official, status=None, dry_run=False):3029 def get_publisher(self, image_type, official, status=None, dry_run=False):
2942 return SimpleReleasePublisher(3030 return SimpleReleasePublisher(
2943 self, image_type, official, status=status, dry_run=dry_run)3031 self, image_type, official, status=status, dry_run=dry_run)
@@ -3200,6 +3288,24 @@
3200 def want_torrent(self, publish_type):3288 def want_torrent(self, publish_type):
3201 raise NotImplementedError3289 raise NotImplementedError
32023290
3291 def publish_release_netboot(self, daily_dir, prefix, arch, image_path):
3292 """Publish release images for a single architecture."""
3293 logger.info("Copying netboot-%s image ..." % (arch, ))
3294
3295 source_tarname = ".%s-netboot-%s.tar.gz" % (self.config.series, arch)
3296 source_tarpath = os.path.join(daily_dir, source_tarname)
3297
3298 if not os.path.exists(source_tarpath):
3299 return
3300
3301 target_tarname = "%s-netboot-%s.tar.gz" % (prefix, arch)
3302 target_tarpath = os.path.join(
3303 os.path.dirname(image_path), target_tarname)
3304
3305 rewrite_and_unpack_tarball(
3306 self.dry_run, source_tarpath, target_tarpath,
3307 self.tree.url_for_path(image_path))
3308
3203 def publish_release_arch(self, source, date, publish_type, arch):3309 def publish_release_arch(self, source, date, publish_type, arch):
3204 """Publish release images for a single architecture."""3310 """Publish release images for a single architecture."""
3205 logger.info("Copying %s-%s image ..." % (publish_type, arch))3311 logger.info("Copying %s-%s image ..." % (publish_type, arch))
@@ -3236,9 +3342,12 @@
3236 return os.path.join(3342 return os.path.join(
3237 torrent_dir, "%s%s%s" % (base_plain, sep, ext))3343 torrent_dir, "%s%s%s" % (base_plain, sep, ext))
32383344
3345 main_img = None
3346
3239 for ext in ("iso", "img", "img.gz", "img.xz", "tar.gz", "img.tar.gz",3347 for ext in ("iso", "img", "img.gz", "img.xz", "tar.gz", "img.tar.gz",
3240 "tar.xz"):3348 "tar.xz"):
3241 if os.path.exists(daily(ext)):3349 if os.path.exists(daily(ext)):
3350 main_img = daily(ext)
3242 break3351 break
3243 else:3352 else:
3244 return3353 return
@@ -3254,8 +3363,20 @@
3254 self.copy(daily(ext), pool(ext))3363 self.copy(daily(ext), pool(ext))
3255 if self.want_dist:3364 if self.want_dist:
3256 self.symlink(pool(ext), dist(ext))3365 self.symlink(pool(ext), dist(ext))
3366 if daily(ext) == main_img:
3367 self.publish_release_netboot(
3368 os.path.dirname(daily(ext)),
3369 prefix_status,
3370 arch,
3371 dist(ext))
3257 if self.want_full:3372 if self.want_full:
3258 self.copy(daily(ext), full(ext))3373 self.copy(daily(ext), full(ext))
3374 if daily(ext) == main_img:
3375 self.publish_release_netboot(
3376 os.path.dirname(daily(ext)),
3377 prefix,
3378 arch,
3379 full(ext))
32593380
3260 for ext in (3381 for ext in (
3261 "initrd-ec2", "initrd-virtual", "vmlinuz-ec2", "vmlinuz-virtual",3382 "initrd-ec2", "initrd-virtual", "vmlinuz-ec2", "vmlinuz-virtual",

Subscribers

People subscribed via source and target branches