diff --git a/assemble_image.sh b/assemble_image.sh
index 9f36acecf8afaa1dc00d07365158180713901167..5521e19bf385a354b9679c3b728826720ad5c38f 100755
--- a/assemble_image.sh
+++ b/assemble_image.sh
@@ -8,6 +8,13 @@ img1="kubuntu-20.04.3-desktop-amd64.iso"
 img2="kubuntu-21.10-desktop-amd64.iso"
 bootimg="$img1"
 : ${workspace:="/workspace"}
+: ${USE_OFFLINE_REPO:=0}
+if [[ "$USE_OFFLINE_REPO" -eq 1 ]]
+then
+    offlinerepo1='archives-focal'
+    offlinerepo2='archives-impish'
+    image_size='13G'
+fi
 
 # mtools, ddrescure, fdisk, grub, 7z
 rm -rf "$workspace/part_files"
@@ -34,8 +41,14 @@ cp grub_template.cfg "$workspace/part_files/boot/grub/grub.cfg"
 fill_grub_config_template "$img1" "$workspace/part_files/boot/grub/grub.cfg"
 fill_grub_config_template "$img2" "$workspace/part_files/boot/grub/grub.cfg"
 
-#./create_offlinerepo.sh "$workspace/part_files/archives" "$img1" $(grep '^[^#]' packages | cut -d'|' -f 2)
-#./create_offlinerepo.sh "$workspace/part_files/archives" "$img2" $(grep '^[^#]' packages | cut -d'|' -f 2)
+if [[ "$USE_OFFLINE_REPO" -eq 1 ]]
+then
+    # Note: in practice you might still want to create the offline repo separately and just copy or move the directories here.
+    # Creating the offline repo requires root privileges and can be quite slow.
+    ./create_offlinerepo.sh "$workspace/part_files/$offlinerepo1" "$img1" $(grep '^[^#]' packages | cut -d'|' -f 2)
+    ./create_offlinerepo.sh "$workspace/part_files/$offlinerepo2" "$img2" $(grep '^[^#]' packages | cut -d'|' -f 2)
+fi
+
 cp packages "$workspace/part_files/packages"
 # The following command is dangerous: If offline repo is missing and "download updates while installing" is selected (default), this will install ALL listed packages during the installation.
 #echo "ubiquity ubiquity/keep-installed string $(grep '^[^#]' packages | cut -d'|' -f 2 | tr '\n' ' ')" >> "$workspace/part_files/preseed/lip.seed"