summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/image-writer
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/bin/image-writer')
-rwxr-xr-xbitbake/bin/image-writer127
1 files changed, 0 insertions, 127 deletions
diff --git a/bitbake/bin/image-writer b/bitbake/bin/image-writer
deleted file mode 100755
index 40e284d59c..0000000000
--- a/bitbake/bin/image-writer
+++ /dev/null
@@ -1,127 +0,0 @@
1#!/usr/bin/env python3
2
3# Copyright (c) 2012 Wind River Systems, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12# See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18import os
19import sys
20sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname( \
21 os.path.abspath(__file__))), 'lib'))
22try:
23 import bb
24except RuntimeError as exc:
25 sys.exit(str(exc))
26
27from gi import pygtkcompat
28
29pygtkcompat.enable()
30pygtkcompat.enable_gtk(version='3.0')
31
32import gtk
33import optparse
34
35from bb.ui.crumbs.hobwidget import HobAltButton, HobButton
36from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog
37from bb.ui.crumbs.hig.deployimagedialog import DeployImageDialog
38from bb.ui.crumbs.hig.imageselectiondialog import ImageSelectionDialog
39
40# I put all the fs bitbake supported here. Need more test.
41DEPLOYABLE_IMAGE_TYPES = ["jffs2", "cramfs", "ext2", "ext3", "ext4", "btrfs", "squashfs", "ubi", "vmdk"]
42Title = "USB Image Writer"
43
44class DeployWindow(gtk.Window):
45 def __init__(self, image_path=''):
46 super(DeployWindow, self).__init__()
47
48 if len(image_path) > 0:
49 valid = True
50 if not os.path.exists(image_path):
51 valid = False
52 lbl = "<b>Invalid image file path: %s.</b>\nPress <b>Select Image</b> to select an image." % image_path
53 else:
54 image_path = os.path.abspath(image_path)
55 extend_name = os.path.splitext(image_path)[1][1:]
56 if extend_name not in DEPLOYABLE_IMAGE_TYPES:
57 valid = False
58 lbl = "<b>Undeployable imge type: %s</b>\nPress <b>Select Image</b> to select an image." % extend_name
59
60 if not valid:
61 image_path = ''
62 crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
63 button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
64 HobButton.style_button(button)
65 crumbs_dialog.run()
66 crumbs_dialog.destroy()
67
68 self.deploy_dialog = DeployImageDialog(Title, image_path, self,
69 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
70 , None, standalone=True)
71#FIXME | gtk.DIALOG_NO_SEPARATOR
72 close_button = self.deploy_dialog.add_button("Close", gtk.RESPONSE_NO)
73 HobAltButton.style_button(close_button)
74 close_button.connect('clicked', gtk.main_quit)
75
76 write_button = self.deploy_dialog.add_button("Write USB image", gtk.RESPONSE_YES)
77 HobAltButton.style_button(write_button)
78
79 self.deploy_dialog.connect('select_image_clicked', self.select_image_clicked_cb)
80 self.deploy_dialog.connect('destroy', gtk.main_quit)
81 response = self.deploy_dialog.show()
82
83 def select_image_clicked_cb(self, dialog):
84 cwd = os.getcwd()
85 dialog = ImageSelectionDialog(cwd, DEPLOYABLE_IMAGE_TYPES, Title, self, gtk.FILE_CHOOSER_ACTION_SAVE )
86 button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
87 HobAltButton.style_button(button)
88 button = dialog.add_button("Open", gtk.RESPONSE_YES)
89 HobAltButton.style_button(button)
90 response = dialog.run()
91
92 if response == gtk.RESPONSE_YES:
93 if not dialog.image_names:
94 lbl = "<b>No selections made</b>\nClicked the radio button to select a image."
95 crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
96 button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
97 HobButton.style_button(button)
98 crumbs_dialog.run()
99 crumbs_dialog.destroy()
100 dialog.destroy()
101 return
102
103 # get the full path of image
104 image_path = os.path.join(dialog.image_folder, dialog.image_names[0])
105 self.deploy_dialog.set_image_text_buffer(image_path)
106 self.deploy_dialog.set_image_path(image_path)
107
108 dialog.destroy()
109
110def main():
111 parser = optparse.OptionParser(
112 usage = """%prog [-h] [image_file]
113
114%prog writes bootable images to USB devices. You can
115provide the image file on the command line or select it using the GUI.""")
116
117 options, args = parser.parse_args(sys.argv)
118 image_file = args[1] if len(args) > 1 else ''
119 dw = DeployWindow(image_file)
120
121if __name__ == '__main__':
122 try:
123 main()
124 gtk.main()
125 except Exception:
126 import traceback
127 traceback.print_exc()