Browse code

Copy initrd image created by dracut in cloud images

Change-Id: If3c5359cf13d21048da239fce2da812494992fe6
Reviewed-on: http://photon-jenkins.eng.vmware.com/28
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>

suezzelur authored on 2015/10/03 08:40:51
Showing 4 changed files
... ...
@@ -135,7 +135,7 @@ packages-minimal: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
135 135
                 -t ${THREADS}
136 136
 
137 137
 iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES) ostree-repo
138
-	@echo "Building Photon FUll ISO..."
138
+	@echo "Building Photon Full ISO..."
139 139
 	@cd $(PHOTON_INSTALLER_DIR) && \
140 140
         sudo $(PHOTON_INSTALLER) -i $(PHOTON_STAGE)/photon.iso \
141 141
                 -w $(PHOTON_STAGE)/photon_iso \
... ...
@@ -358,13 +358,13 @@ photon-vagrant-local: check-packer check-vagrant
358 358
 		echo "Unable to find $(PHOTON_STAGE)/photon.iso ... aborting build"; \
359 359
 	fi
360 360
 
361
-cloud-image: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
361
+cloud-image: $(PHOTON_STAGE) iso
362 362
 	@echo "Building cloud image $(IMG_NAME)..."
363 363
 	@cd $(PHOTON_CLOUD_IMAGE_BUILDER_DIR)
364 364
 	$(PHOTON_CLOUD_IMAGE_BUILDER) $(PHOTON_CLOUD_IMAGE_BUILDER_DIR) $(IMG_NAME) $(SRCROOT) $(PHOTON_GENERATED_DATA_DIR) $(PHOTON_STAGE) $(ADDITIONAL_RPMS_PATH)
365 365
 
366 366
 
367
-cloud-image-all: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
367
+cloud-image-all: $(PHOTON_STAGE) iso
368 368
 	@echo "Building cloud images - gce, ami, azure and ova..."
369 369
 	@cd $(PHOTON_CLOUD_IMAGE_BUILDER_DIR)
370 370
 	$(PHOTON_CLOUD_IMAGE_BUILDER) $(PHOTON_CLOUD_IMAGE_BUILDER_DIR) gce $(SRCROOT) $(PHOTON_GENERATED_DATA_DIR) $(PHOTON_STAGE) $(ADDITIONAL_RPMS_PATH)
... ...
@@ -287,7 +287,7 @@ class Installer(object):
287 287
             # remove the installer directory
288 288
             process = subprocess.Popen(['rm', '-rf', os.path.join(self.photon_root, "installer")], stdout=self.output)
289 289
             retval = process.wait()
290
-        else:
290
+        elif not self.install_config['vmdk_install']:
291 291
             #Build the initramfs by passing in the kernel version
292 292
             version_string = ''	
293 293
             for root, dirs, files in os.walk(self.rpm_path):
... ...
@@ -137,6 +137,7 @@ if __name__ == '__main__':
137 137
             parser.error("Incorrect arguments")
138 138
         config = {}
139 139
         config['iso_system'] = True
140
+        config['vmdk_install'] = False
140 141
 
141 142
     elif options.vmdk_path:
142 143
         # Check the arguments
... ...
@@ -164,6 +165,7 @@ if __name__ == '__main__':
164 164
         config = (JsonWrapper(args[0])).read()
165 165
 
166 166
         config['iso_system'] = False
167
+        config['vmdk_install'] = False
167 168
 
168 169
     if 'password' in config:
169 170
         # crypt the password if needed
... ...
@@ -18,6 +18,8 @@ GENERATED_DATA_PATH=$4
18 18
 PHOTON_STAGE_PATH=$5
19 19
 ADDITIONAL_RPMS_PATH=$6
20 20
 INSTALLER_PATH=$PHOTON_STAGE_PATH/$IMG_NAME
21
+PHOTON_ISO_PATH=$PHOTON_STAGE_PATH/photon.iso
22
+ISO_MOUNT_FOLDER=$PHOTON_STAGE_PATH/iso_mount
21 23
 
22 24
 PHOTON_IMG_OUTPUT_PATH=$PHOTON_STAGE_PATH/$IMG_NAME
23 25
 
... ...
@@ -69,6 +71,8 @@ echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p2"
69 69
 rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
70 70
 mkdir $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
71 71
 
72
+mkdir -p $ISO_MOUNT_FOLDER
73
+mount -o loop $PHOTON_ISO_PATH $ISO_MOUNT_FOLDER
72 74
 mount -v -t ext4 /dev/mapper/${DEVICE_NAME}p2 $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
73 75
 rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/installer
74 76
 rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/LOGS
... ...
@@ -87,11 +91,22 @@ if [ -n "$ADDITIONAL_RPMS_PATH" ]
87 87
     mkdir $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/var/run
88 88
     cp -f $PHOTON_STAGE_PATH/RPMS/additonal/* $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/additional_rpms/
89 89
     chroot $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME} /bin/bash -c "rpm -i /additional_rpms/*"
90
+    rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/additional_rpms/
90 91
 fi
91 92
 
92 93
 if [ $IMG_NAME != "ova" ] && [ $IMG_NAME != "ova_uefi" ]
93 94
   then
94
-
95
+    #Copy the initrd image
96
+    rm -rf /tmp/initrd*
97
+    rm -rf /tmp/installer
98
+    cp $ISO_MOUNT_FOLDER/isolinux/initrd.img /tmp/initrd.gz
99
+    gunzip /tmp/initrd.gz
100
+    cd /tmp
101
+    cpio -id < initrd
102
+    cp /tmp/installer/boot/initrd.img* $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/boot/
103
+    rm -rf /tmp/initrd*
104
+    rm -rf /tmp/installer
105
+    cd $BUILD_SCRIPTS_PATH
95 106
     if [ $IMG_NAME = "gce" ]
96 107
       then
97 108
         cp ntpd.service $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
... ...
@@ -119,6 +134,8 @@ umount $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/dev/pts
119 119
 umount $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/dev
120 120
 umount $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/proc
121 121
 umount $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
122
+umount $ISO_MOUNT_FOLDER
123
+rm -rf $ISO_MOUNT_FOLDER
122 124
 
123 125
 echo "Deleting device map partition"
124 126
 kpartx -d $DISK_DEVICE