@@ -0,0 +1,1357 @@
+#!/usr/bin/env python%0Aimport hashlib%0Aimport etcd%0Aimport re%0A%0Aetcd_client = etcd.Client(port=2379)%0AETCD_PREFIX = %22kpm/packages/%22%0A%0A%0Apath = ETCD_PREFIX%0Ar = %7B%7D%0Apackages = etcd_client.read(path, recursive=True)%0A%0Afor child in packages.children:%0A    m = re.match(%22%5E/%25s(.+?)/(.+?)/(.+?)$%22 %25 ETCD_PREFIX, child.key)%0A    if m is None:%0A        continue%0A    organization, name, version = (m.group(1), m.group(2), m.group(3))%0A    if len(version.split(%22/%22)) %3E 1:%0A        continue%0A    package = %22%25s/%25s%22 %25 (organization, name)%0A    pv = %22%25s/%25s%22 %25 (package, version)%0A    data = etcd_client.read(ETCD_PREFIX + pv)%0A    etcd_client.write(ETCD_PREFIX + package + %22/%22 + %22releases%22 + %22/%22 + version, data.value)%0A    etcd_client.delete(ETCD_PREFIX + pv)%0A    print %22%25s/%25s%22 %25 (package, version)%0A%0Afor child in packages.children:%0A    m = re.match(%22%5E/%25s(.+?)/(.+?)/releases/(.+?)$%22 %25 ETCD_PREFIX, child.key)%0A    if m is None:%0A        continue%0A    organization, name, version = (m.group(1), m.group(2), m.group(3))%0A    if len(version.split(%22/%22)) %3E 1:%0A        continue%0A    package = %22%25s/%25s%22 %25 (organization, name)%0A    pv = %22%25s/%25s%22 %25 (package, version)%0A    data = etcd_client.read(ETCD_PREFIX + package + %22/releases/%22 + version)%0A    print pv%0A    sha = hashlib.sha256(data.value).hexdigest()%0A    etcd_client.write(ETCD_PREFIX + package + %22/%22 + %22digests%22 + %22/%22 + sha, data.value)%0A    print sha%0A

migrate data script