view scripts/ @ 1087:b73a61542297 draft

I've finally gotten 'cpio' into a shape where it could be useable. This version can archive and extract directories, sockets, FIFOs, devices, symlinks, and regular files. Supported options are -iot, -H FMT (which is a dummy right now). It only writes newc, and could read newc or newcrc. This does NOT implement -d, which essentially is equivalent to mkdir -p $(dirname $FILE) for every file that needs it. Hard links are not supported, though it would be easy to add them given a hash table or something like that. I also have not implemented the "<n> blocks" output on stderr. If desired, I can add it pretty simply. There is one assumption this makes: that the mode of a file, as mode_t, is bitwise equivalent to the mode as defined for the cpio format. This is true of Linux, but is not mandated by POSIX. If it is compiled for a system where that is false, the archives will not be portable.
author Isaac Dunham <>
date Mon, 14 Oct 2013 11:15:22 -0500
parents 6b4529a50b72
children bd745ae2b115
line wrap: on
line source


# Create status.html

import subprocess,sys

def readit(args):
  blob=subprocess.Popen(args, stdout=subprocess.PIPE, shell=False)
  for i in"\n"):
    if not i: continue
  return ret,arr

# Run sed on roadmap and status pages to get command lists, and run toybox too
# This gives us a dictionary of types, each with a list of commands

stuff,blah=readit(["sed","-n", 's/<span id=\\([a-z_]*\\)>/\\1 /;t good;d;:good;h;:loop;n;s@</span>@@;t out;H;b loop;:out;g;s/\\n/ /g;p', "www/roadmap.html", "www/status.html"])

# Create reverse mappings: command is in which

for i in stuff:
  for j in stuff[i]:
    try: reverse[j].append(i)
    except: reverse[j]=[i]

for i in toystuff:
    if ("ready" in reverse[i]) or ("pending" in reverse[i]): continue
  except: pass
  print i


print "all commands=%s" % len(reverse)

outfile=open("www/status.gen", "w")
outfile.write("<a name=all><h2><a href=#all>All commands</a></h2><blockquote><p>\n")

conv = [("posix", '<a href="">%%s</a>', "[%s]"),
        ("lsb", '<a href="">%%s</a>', '&lt;%s&gt;'),
        ("development", '<a href="">%%s</a>', '(%s)'),
        ("toolbox", "", '{%s}'), ("klibc_cmd", "", '=%s='),
        ("sash_cmd", "", '#%s#'), ("sbase_cmd", "", '@%s@'),
        ("beastiebox_cmd", "", '*%s*'),
        ("request", '<a href="">%%s</a>', '+%s+')]

def categorize(reverse, i, skippy=""):
  linky = "%s"
  out = i

  if skippy: types = filter(lambda a: a != skippy, reverse[i])
  else: types = reverse[i]

  for j in conv:
    if j[0] in types:
      if j[1]: linky = j[1] % i
      out = j[2] % out
      if not skippy: break
  if (not skippy) and out == i:
    sys.stderr.write("unknown %s %s\n" % (i,reverse[i]))

  return linky % out

for i in blah:
  out=categorize(reverse, i)
  if "ready" in reverse[i] or "pending" in reverse[i]:
    out='<strike>%s</strike>' % out
  else: pending.append(out)


print "done=%s" % len(done)

outfile.write("<a name=todo><h2><a href=#todo>TODO</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pending))
outfile.write("<a name=done><h2><a href=#done>Done</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(done))

outfile.write("<hr><h2>Categories of remaining todo items</h2>")

for i in stuff:
  todo = []

  for j in stuff[i]:
    if "ready" in reverse[j]: continue
    else: todo.append(categorize(reverse,j,i))

  if todo:
    k = i
    for j in conv:
      if j[0] == i:
        k = j[2] % i

    outfile.write("<a name=%s><h2><a href=#%s>%s<a></h2><blockquote><p>" % (i,i,k))
    outfile.write(" ".join(todo))