Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/modules/base/cleanup.50.cleanup.sh
blob: de6404511bd3506feead762d4d962443af1db50e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (C) 2009 One Laptop Per Child
# Licensed under the terms of the GNU GPL v2 or later; see COPYING for details.

. $OOB__shlib

image_number=$(image_name)
platform=$(read_config global target_platform)

umount $fsmount &>/dev/null || :
umount $intermediatesdir/mnt-root &>/dev/null || :
umount $intermediatesdir/mnt-boot &>/dev/null || :
umount $intermediatesdir/mnt-squashfs &>/dev/null || :
umount $intermediatesdir/mnt-iso &>/dev/null || :
cp $intermediatesdir/build.ks $outputdir/
mv $outputdir $outputdir.$image_number-$platform

# Sometimes, when image-creator is interrupted, it leaves mounts around.
# clean them up here

# instead of trying to figure out which order to umount the appropriate
# mounts, just take a brute-force approach
for tmp in $(seq 10); do
	oIFS=$IFS
	IFS=$'\n'
	for i in $(</proc/mounts); do
		dev=${i%% *}
		i=${i#* }
		i=${i%% *}
		if [[ "${i:0:18}" == "/var/tmp/imgcreate" ]]; then
			umount $i &>/dev/null || :
		fi
		if [[ "${dev:0:9}" == "/dev/loop" ]]; then
			losetup -d $dev &>/dev/null || :
		fi
	done
	IFS=oIFS
done