From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6wu0-0002Oj-KU for barebox@lists.infradead.org; Wed, 16 Nov 2016 09:53:14 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 16 Nov 2016 10:52:44 +0100 Message-Id: <20161116095244.14288-4-u.kleine-koenig@pengutronix.de> In-Reply-To: <20161116095244.14288-1-u.kleine-koenig@pengutronix.de> References: <20161116095244.14288-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 4/4] scripts/kwbimage: allow to overwrite binary To: barebox@lists.infradead.org VGhpcyBpcyBhIHByZXBhcmF0aW9uIHRvIGxldCBiYXJlYm94IHByb3ZpZGUgdGhlIGJpbmFyeS4w LgoKU2lnbmVkLW9mZi1ieTogVXdlIEtsZWluZS1Lw7ZuaWcgPHUua2xlaW5lLWtvZW5pZ0BwZW5n dXRyb25peC5kZT4KLS0tClRoaXMgaXMgbmV3IGluIHRoaXMgc2VyaWVzIGFuZCBhIGxlZnQgb3Zl ciBmcm9tIG15IGVmZm9ydHMgdG8gbGV0CmJhcmVib3ggaW1wbGVtZW50IHRoZSBmdW5jdGlvbmFs aXR5IG9mIGJpbmFyeS4wLiBGb3Igbm93IHRoYXQgZmFpbGVkLApidXQgdGhpcyBwYXRjaCBzaG91 bGQgYmUgZmluZSBhbnlob3cuCgpCZXN0IHJlZ2FyZHMKVXdlCgogc2NyaXB0cy9rd2JpbWFnZS5j IHwgNDAgKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKystLS0tLQogMSBmaWx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