wok-current rev 17253
Add genromfs
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Oct 20 12:52:14 2014 +0200 (2014-10-20) |
parents | 589a225cacc7 |
children | 3ba86ab5ebce |
files | genromfs/receipt genromfs/stuff/genromfs.u |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/genromfs/receipt Mon Oct 20 12:52:14 2014 +0200 1.3 @@ -0,0 +1,30 @@ 1.4 +# SliTaz package receipt. 1.5 + 1.6 +PACKAGE="genromfs" 1.7 +VERSION="0.5.7" 1.8 +CATEGORY="base-system" 1.9 +SHORT_DESC="Romfs creation tool." 1.10 +MAINTAINER="pascal.bellard@slitaz.org" 1.11 +LICENSE="GPL2" 1.12 +TARBALL="$PACKAGE-$VERSION.tar.gz" 1.13 +WEB_SITE="http://romfs.sourceforge.net/" 1.14 +WGET_URL="https://github.com/chexum/$PACKAGE/archive/$VERSION.tar.gz" 1.15 + 1.16 +DEPENDS="" 1.17 +BUILD_DEPENDS="wget" 1.18 + 1.19 +# Rules to configure and make the package. 1.20 +compile_rules() 1.21 +{ 1.22 + patch -p0 < $stuff/genromfs.u 1.23 + make && 1.24 + make PREFIX=$DESTDIR install 1.25 +} 1.26 + 1.27 +# Rules to gen a SliTaz package suitable for Tazpkg. 1.28 +genpkg_rules() 1.29 +{ 1.30 + mkdir -p $fs/usr 1.31 + cp -a $install/usr/bin $fs/usr 1.32 + ln -s genromfs $fs/usr/bin/mkromfs 1.33 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/genromfs/stuff/genromfs.u Mon Oct 20 12:52:14 2014 +0200 2.3 @@ -0,0 +1,144 @@ 2.4 +--- genromfs.c 2.5 ++++ genromfs.c 2.6 +@@ -164,6 +164,7 @@ 2.7 + uid_t nuid; 2.8 + gid_t ngid; 2.9 + time_t ntime; 2.10 ++ nlink_t nlink; 2.11 + unsigned int offset; 2.12 + unsigned int realsize; 2.13 + unsigned int prepad; 2.14 +@@ -178,6 +179,8 @@ 2.15 + int extlen; 2.16 + }; 2.17 + 2.18 ++static int oldromfs = 1; 2.19 ++ 2.20 + #define EXTTYPE_UNKNOWN 0 2.21 + #define EXTTYPE_ALIGNMENT 1 2.22 + #define EXTTYPE_EXCLUDE 2 2.23 +@@ -361,7 +364,9 @@ 2.24 + } 2.25 + len+=16; 2.26 + ri=(struct romfh *)bigbuf; 2.27 +- if (n->offset) 2.28 ++ if (!oldromfs) 2.29 ++ ri->checksum = ntohl(n->ntime); 2.30 ++ else if (n->offset) 2.31 + fixsum(ri, len); 2.32 + dumpdata(bigbuf, len, f); 2.33 + #if 0 2.34 +@@ -373,6 +378,9 @@ 2.35 + #endif 2.36 + } 2.37 + 2.38 ++#define SIGNED_OVERFLOW(x,m) (((x) & (m)) != 0 && (((x) & (m)) | ~(m)) != ~0) 2.39 ++#define SIGNED_EXTENTION(x,m) (((x) & (((m)+1)>>1)) ? (x) | ~(m) : (x) & (m)) 2.40 ++ 2.41 + void dumpnode(struct filenode *node, FILE *f) 2.42 + { 2.43 + struct romfh ri; 2.44 +@@ -386,13 +394,33 @@ 2.45 + 2.46 + ri.nextfh = 0; 2.47 + ri.spec = 0; 2.48 ++ if (!oldromfs) { 2.49 ++ ri.spec = node->modes & (0x0FFF ^ S_IXUSR); 2.50 ++ ri.spec ^= S_IRUSR |S_IWUSR; 2.51 ++ ri.spec |= node->nuid << 20; 2.52 ++ ri.spec |= (node->ngid & 0xFF) << 12; 2.53 ++ if (node->ngid & 0x100) 2.54 ++ ri.spec |= S_IXUSR; 2.55 ++ if (SIGNED_OVERFLOW(node->nuid,0xF000)) { 2.56 ++ printf("%-50s : uid=%04X -> %04X \n", 2.57 ++ node->realname, node->nuid, 2.58 ++ (uid_t) SIGNED_EXTENTION(node->nuid,0x0FFF)); 2.59 ++ } 2.60 ++ if (SIGNED_OVERFLOW(node->ngid,0xFE00)) { 2.61 ++ printf("%-50s : gid=%04X -> %04X \n", 2.62 ++ node->realname, node->ngid, 2.63 ++ (gid_t) SIGNED_EXTENTION(node->ngid,0x01FF)); 2.64 ++ } 2.65 ++ } 2.66 ++ ri.spec = htonl(ri.spec); 2.67 + ri.size = htonl(node->realsize); 2.68 + ri.checksum = htonl(0x55555555); 2.69 + 2.70 + if (node->next && node->next->next) 2.71 + ri.nextfh = htonl(node->next->offset); 2.72 + if ((node->modes & 0111) && 2.73 +- (S_ISDIR(node->modes) || S_ISREG(node->modes))) 2.74 ++ (S_ISDIR(node->modes) || S_ISREG(node->modes) || 2.75 ++ (!oldromfs && (S_ISCHR(node->modes) || S_ISBLK(node->modes))))) 2.76 + ri.nextfh |= htonl(ROMFH_EXEC); 2.77 + 2.78 + if (node->orig_link) { 2.79 +@@ -403,11 +431,17 @@ 2.80 + dumpri(&ri, node, f); 2.81 + } else if (S_ISDIR(node->modes)) { 2.82 + ri.nextfh |= htonl(ROMFH_DIR); 2.83 ++ if (!oldromfs) 2.84 ++ ri.size = ri.spec; 2.85 + if (listisempty(&node->dirlist)) { 2.86 + ri.spec = htonl(node->offset); 2.87 + } else { 2.88 + ri.spec = htonl(node->dirlist.head->offset); 2.89 + } 2.90 ++ if (node->nlink > 0xf) 2.91 ++ node->nlink = 0xf; 2.92 ++ if (!oldromfs) 2.93 ++ ri.spec |= htonl(node->nlink); 2.94 + dumpri(&ri, node, f); 2.95 + } else if (S_ISLNK(node->modes)) { 2.96 + ri.nextfh |= htonl(ROMFH_LNK); 2.97 +@@ -464,10 +498,14 @@ 2.98 + } 2.99 + } else if (S_ISCHR(node->modes)) { 2.100 + ri.nextfh |= htonl(ROMFH_CHR); 2.101 ++ if (!oldromfs) 2.102 ++ ri.size = ri.spec; 2.103 + ri.spec = htonl(major(node->devnode)<<16|minor(node->devnode)); 2.104 + dumpri(&ri, node, f); 2.105 + } else if (S_ISBLK(node->modes)) { 2.106 + ri.nextfh |= htonl(ROMFH_BLK); 2.107 ++ if (!oldromfs) 2.108 ++ ri.size = ri.spec; 2.109 + ri.spec = htonl(major(node->devnode)<<16|minor(node->devnode)); 2.110 + dumpri(&ri, node, f); 2.111 + } else if (S_ISFIFO(node->modes)) { 2.112 +@@ -522,6 +560,7 @@ 2.113 + n->nuid = sb->st_uid; 2.114 + n->ngid = sb->st_gid; 2.115 + n->ntime = sb->st_mtime; 2.116 ++ n->nlink = sb->st_nlink; 2.117 + n->realsize = 0; 2.118 + /* only regular files and symlinks contain "data" in romfs */ 2.119 + if (S_ISREG(n->modes) || S_ISLNK(n->modes)) { 2.120 +@@ -574,6 +613,9 @@ 2.121 + node->ondev = -1; 2.122 + node->onino = -1; 2.123 + node->modes = -1; 2.124 ++ node->realsize = 0; 2.125 ++ node->devnode = 0; 2.126 ++ node->orig_link = NULL; 2.127 + node->offset = curroffset; 2.128 + node->align = DEFALIGN; 2.129 + 2.130 +@@ -935,6 +977,7 @@ 2.131 + printf("\n"); 2.132 + printf(" -f IMAGE Output the image into this file\n"); 2.133 + printf(" -d DIRECTORY Use this directory as source\n"); 2.134 ++ printf(" -t Time, uid & gid support (backward compatible)\n"); 2.135 + printf(" -v (Too) verbose operation\n"); 2.136 + printf(" -V VOLUME Use the specified volume name\n"); 2.137 + printf(" -a ALIGN Align regular file data to ALIGN bytes\n"); 2.138 +@@ -971,6 +1014,9 @@ 2.139 + break; 2.140 + case 'V': 2.141 + volname = optarg; 2.142 ++ break; 2.143 ++ case 't': 2.144 ++ oldromfs = 0; 2.145 + break; 2.146 + case 'v': 2.147 + verbose = 1;