package/mtd-utils: update to 1.4.5

This updates packages/utils/mtd-utils and includes all patches from
tools/mtd-utils, so the two may eventually be merged.
I also added 150-fix_ubi-utils_static.patch which is a hack needed
to include libcrc32.o in the static binaries.
Having them static makes sense as only ubiformat is required on the target.

[juhosg:
- add build-time dependency on util-linux
- allow to specify dependency for each subpackage
- update ubifs optional lzo patch
- add more patches]

Signed-off-by: Daniel Golle <dgolle@allnet.de>

git-svn-id: svn://svn.openwrt.org/openwrt/packages@31913 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2012-05-27 16:40:32 +00:00
parent 9685efd146
commit b797a23e77
8 changed files with 5337 additions and 60 deletions

View File

@ -1,4 +1,4 @@
#
#
# Copyright (C) 2009-2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
@ -8,75 +8,68 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mtd-utils
PKG_REV:=a2d010f8fca904fffa3c6e5a5d148cc96a37a08a
PKG_VERSION:=20090227
PKG_RELEASE:=2
PKG_REV:=5319b84974fcb71504aed2d1b8285e9c0a4a4bb8
PKG_VERSION:=1.4.5
PKG_RELEASE:=1
PKG_INSTALL:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=git://git.infradead.org/mtd-utils.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_BUILD_DEPENDS:=util-linux
include $(INCLUDE_DIR)/package.mk
FILES:= \
ubiupdatevol \
flash_otp_info \
nandtest \
ubimkvol \
ubigen \
serve_image \
recv_image \
ubinfo \
ubirename \
mkpfi \
nandwrite \
flash_eraseall \
mkbootenv \
ftl_format \
nand2bin \
ubiattach \
nftl_format \
nanddump \
ubinize \
docfdisk \
ubimirror \
ubicrc32.pl \
ftl_check \
flashcp \
jffs2dump \
ubiformat \
ubidetach \
flash_lock \
bin2nand \
pfiflash \
mtd_debug \
pddcustomize \
flash_unlock \
doc_loadbios \
nftldump \
mkfs.jffs2 \
flash_info \
ubicrc32 \
ubirmvol \
unubi \
pfi2bin \
mkfs.ubifs \
sumtool \
docfdisk \
flash_erase \
rfddump \
flash_eraseall \
flash_info \
flash_lock \
flash_otp_dump \
rfdformat
flash_otp_info \
flash_unlock \
flashcp \
ftl_check \
ftl_format \
jffs2dump \
mkfs.jffs2 \
mkfs.ubifs:+libuuid \
mtd_debug \
mtdinfo \
nanddump \
nandtest \
nandwrite \
nftldump \
nftl_format \
recv_image \
rfddump \
rfdformat \
serve_image \
sumtool \
ubiattach \
ubicrc32 \
ubidetach \
ubiformat \
ubimkvol \
ubinfo \
ubinize \
ubirename \
ubirmvol \
ubirsvol \
ubiupdatevol
define PartGen
define Package/mtd-utils-$(subst _,-,$(1))
TITLE:=MTD $(1)
define Package/mtd-utils-$(subst _,-,$(firstword $(subst :, ,$(1))))
TITLE:=$(firstword $(subst :, ,$(1))) package from mtd-utils
URL:=http://www.linux-mtd.infradead.org/
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=mtd-utils +zlib +liblzo +libuuid
DEPENDS:=mtd-utils $(wordlist 2,$(words $(subst :, ,$(1))),$(subst :, ,$(1)))
endef
endef
@ -84,6 +77,7 @@ define Package/mtd-utils
TITLE:=Utilities for flash info/debug
SECTION:=utils
CATEGORY:=Utilities
URL:=http://www.linux-mtd.infradead.org/
MENU:=1
endef
@ -101,15 +95,16 @@ MAKE_FLAGS += \
DESTDIR="$(PKG_INSTALL_DIR)" \
BUILDDIR="$(PKG_BUILD_DIR)" \
LDLIBS+="$(LIBGCC_S)" \
WITHOUT_XATTR=1
WITHOUT_XATTR=1 \
WITHOUT_LZO=1
define PartInstall
define Package/mtd-utils-$(subst _,-,$(1))/install
define Package/mtd-utils-$(subst _,-,$(firstword $(subst :, ,$(1))))/install
$(INSTALL_DIR) \
$$(1)/usr/sbin
$(INSTALL_BIN) \
$(PKG_INSTALL_DIR)/usr/sbin/$(1) \
$(PKG_INSTALL_DIR)/usr/sbin/$(firstword $(subst :, ,$(1))) \
$$(1)/usr/sbin/
endef
endef
@ -117,4 +112,4 @@ endef
$(foreach file,$(FILES),$(eval $(call PartInstall,$(file))))
$(eval $(call BuildPackage,mtd-utils))
$(foreach file,$(FILES),$(eval $(call BuildPackage,mtd-utils-$(subst _,-,$(file)))))
$(foreach file,$(FILES),$(eval $(call BuildPackage,mtd-utils-$(subst _,-,$(firstword $(subst :, ,$(file)))))))

View File

@ -1,6 +1,6 @@
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -236,6 +236,7 @@ int showinfo (int fd)
@@ -238,6 +238,7 @@ int showinfo (int fd)
int i,err,n;
struct mtd_info_user mtd;
static struct region_info_user region[1024];
@ -8,7 +8,7 @@
err = getmeminfo (fd,&mtd);
if (err < 0)
@@ -328,6 +329,11 @@ int showinfo (int fd)
@@ -330,6 +331,11 @@ int showinfo (int fd)
printf ("\nmtd.oobsize = ");
printsize (mtd.oobsize);
@ -20,7 +20,7 @@
printf ("\n"
"regions = %d\n"
"\n",
@@ -347,6 +353,50 @@ int showinfo (int fd)
@@ -349,6 +355,50 @@ int showinfo (int fd)
return (0);
}
@ -68,6 +68,6 @@
+ return ibbCounter;
+}
+
void showusage (const char *progname)
void showusage(void)
{
fprintf (stderr,

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -7,7 +7,7 @@ SUBDIRS =
# CFLAGS += -Werror
CPPFLAGS += -I../include
LIBS = libmtd
-TARGETS = libmtd.a
+override TARGETS = libmtd.a
include ../common.mk

View File

@ -0,0 +1,119 @@
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
-#include <lzo/lzo1x.h>
#include <linux/types.h>
#define crc32 __zlib_crc32
@@ -35,7 +34,6 @@
#include "ubifs-media.h"
#include "mkfs.ubifs.h"
-static void *lzo_mem;
static unsigned long long errcnt = 0;
static struct ubifs_info *c = &info_;
@@ -86,6 +84,25 @@ static int zlib_deflate(void *in_buf, si
return 0;
}
+#ifndef WITHOUT_LZO
+#include <lzo/lzo1x.h>
+
+static void *lzo_mem;
+
+static int lzo_init(void)
+{
+ lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
+ if (!lzo_mem)
+ return -1;
+
+ return 0;
+}
+
+static void lzo_fini(void)
+{
+ free(lzo_mem);
+}
+
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
@@ -103,6 +120,12 @@ static int lzo_compress(void *in_buf, si
return 0;
}
+#else
+static inline int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
+ size_t *out_len) { return -1; }
+static inline int lzo_init(void) { return 0; }
+static inline void lzo_fini(void) { }
+#endif
static int no_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
@@ -123,7 +146,6 @@ static int favor_lzo_compress(void *in_b
lzo_len = zlib_len = *out_len;
lzo_ret = lzo_compress(in_buf, in_len, out_buf, &lzo_len);
zlib_ret = zlib_deflate(in_buf, in_len, zlib_buf, &zlib_len);
-
if (lzo_ret && zlib_ret)
/* Both compressors failed */
return -1;
@@ -198,23 +220,28 @@ int compress_data(void *in_buf, size_t i
int init_compression(void)
{
- lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
- if (!lzo_mem)
- return -1;
+ int ret;
+
+ ret = lzo_init();
+ if (ret)
+ goto err;
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
- if (!zlib_buf) {
- free(lzo_mem);
- return -1;
- }
+ if (!zlib_buf)
+ goto err_lzo;
return 0;
+
+err_lzo:
+ lzo_fini();
+err:
+ return ret;
}
void destroy_compression(void)
{
free(zlib_buf);
- free(lzo_mem);
+ lzo_fini();
if (errcnt)
fprintf(stderr, "%llu compression errors occurred\n", errcnt);
}
--- a/mkfs.ubifs/Makefile
+++ b/mkfs.ubifs/Makefile
@@ -6,7 +6,13 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
TARGETS = mkfs.ubifs
-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
+ifeq ($(WITHOUT_LZO), 1)
+ CPPFLAGS += -DWITHOUT_LZO
+else
+ LZOLDLIBS = -llzo2
+endif
+
+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd
LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)

View File

@ -0,0 +1,28 @@
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -109,7 +109,7 @@ static char *output;
static int out_fd;
static int out_ubi;
static int squash_owner;
-static int squash_rino_perm;
+static int squash_rino_perm = -1;
/* The 'head' (position) which nodes are written */
static int head_lnum;
@@ -683,6 +683,7 @@ static int get_options(int argc, char**a
printf("WARNING: --squash-rino-perm is depricated, do not use it\n");
break;
case 'q':
+ squash_rino_perm = 0;
printf("WARNING: --nosquash-rino-perm is depricated, do not use it\n");
break;
}
@@ -1686,7 +1687,7 @@ static int write_data(void)
if (err)
return sys_err_msg("bad root file-system directory '%s'",
root);
- if (squash_rino_perm) {
+ if (squash_rino_perm > 0) {
root_st.st_uid = root_st.st_gid = 0;
root_st.st_mode = mode;
}

View File

@ -0,0 +1,61 @@
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -110,6 +110,7 @@ static int out_fd;
static int out_ubi;
static int squash_owner;
static int squash_rino_perm = -1;
+static int overwrite_volume;
/* The 'head' (position) which nodes are written */
static int head_lnum;
@@ -132,7 +133,7 @@ static struct inum_mapping **hash_table;
/* Inode creation sequence number */
static unsigned long long creat_sqnum;
-static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq";
+static const char *optstring = "d:r:m:o:OD:h?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq";
static const struct option longopts[] = {
{"root", 1, NULL, 'r'},
@@ -140,6 +141,7 @@ static const struct option longopts[] =
{"leb-size", 1, NULL, 'e'},
{"max-leb-cnt", 1, NULL, 'c'},
{"output", 1, NULL, 'o'},
+ {"overwrite", 0, NULL, 'O'},
{"devtable", 1, NULL, 'D'},
{"help", 0, NULL, 'h'},
{"verbose", 0, NULL, 'v'},
@@ -176,6 +178,7 @@ static const char *helptext =
"-e, --leb-size=SIZE logical erase block size\n"
"-c, --max-leb-cnt=COUNT maximum logical erase block count\n"
"-o, --output=FILE output to FILE\n"
+"-O, --overwrite force overwriting of the existing volume\n"
"-j, --jrn-size=SIZE journal size\n"
"-R, --reserved=SIZE how much space should be reserved for the super-user\n"
"-x, --compr=TYPE compression type - \"lzo\", \"favor_lzo\", \"zlib\" or\n"
@@ -594,6 +597,9 @@ static int get_options(int argc, char**a
case 'o':
output = strdup(optarg);
break;
+ case 'O':
+ overwrite_volume = 1;
+ break;
case 'D':
tbl_file = optarg;
if (stat(tbl_file, &st) < 0)
@@ -2180,8 +2186,13 @@ static int open_target(void)
if (ubi_set_property(out_fd, UBI_PROP_DIRECT_WRITE, 1))
return sys_err_msg("ubi_set_property failed");
- if (check_volume_empty())
- return err_msg("UBI volume is not empty");
+ if (check_volume_empty()) {
+ if (overwrite_volume)
+ if (verbose)
+ printf("Warning: overwriting existing data\n");
+ else
+ return err_msg("UBI volume is not empty");
+ }
} else {
out_fd = open(output, O_CREAT | O_RDWR | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);

View File

@ -0,0 +1,32 @@
--- a/ubi-utils/Makefile
+++ b/ubi-utils/Makefile
@@ -22,7 +22,7 @@ $(TARGETS): $(addprefix $(BUILDDIR)/,\
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lubi -o $@
$(BUILDDIR)/ubicrc32: $(addprefix $(BUILDDIR)/,\
- ubicrc32.o)
+ ../lib/libcrc32.o ubicrc32.o)
# $(CC) $(CFLAGS) -o $@ $^
$(BUILDDIR)/ubinize: $(addprefix $(BUILDDIR)/,\
@@ -30,16 +30,17 @@ $(BUILDDIR)/ubinize: $(addprefix $(BUILD
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -liniparser -lubigen -o $@
$(BUILDDIR)/mtdinfo: $(addprefix $(BUILDDIR)/,\
- libubigen.a ubiutils-common.o)
+ ../lib/libmtd.o ../lib/libmtd_legacy.o libubigen.a ubiutils-common.o)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lubigen -o $@
$(BUILDDIR)/ubiformat: $(addprefix $(BUILDDIR)/,\
- ubiformat.o ubiutils-common.o libscan.a libubi.a libubigen.a)
+ ../lib/libmtd.o ../lib/libmtd_legacy.o ubiformat.o ubiutils-common.o libscan.a libubi.a libubigen.a)
# $(CC) $(CFLAGS) $(filter %.o, $^) -L. -lmtd -lscan -lubi -lubigen -o $@
$(BUILDDIR)/libubi.a: $(BUILDDIR)/libubi.o
-$(BUILDDIR)/libubigen.a: $(BUILDDIR)/libubigen.o
+$(BUILDDIR)/libubigen.a: $(addprefix $(BUILDDIR)/,\
+ ../lib/libcrc32.o libubigen.o)
$(BUILDDIR)/libiniparser.a: $(addprefix $(BUILDDIR)/,\
libiniparser.o dictionary.o)