Fix broken links after moving the bin and sbin directories
This commit is contained in:
parent
551647a017
commit
69c69d0e13
@ -161,25 +161,3 @@ class Install(object):
|
|||||||
# remove dirs from etc/rc.d
|
# remove dirs from etc/rc.d
|
||||||
dirs = ('rc?.d', 'rc', 'rc.local', 'rc.sysinit')
|
dirs = ('rc?.d', 'rc', 'rc.local', 'rc.sysinit')
|
||||||
map(lambda dir: rm(os.path.join(self.conf.treedir, 'etc', 'rc.d', dir)), dirs)
|
map(lambda dir: rm(os.path.join(self.conf.treedir, 'etc', 'rc.d', dir)), dirs)
|
||||||
|
|
||||||
def fix_links(self):
|
|
||||||
print("Fixing broken links")
|
|
||||||
for dir in ('bin', 'sbin'):
|
|
||||||
dir = os.path.join(self.conf.treedir, 'usr', dir)
|
|
||||||
|
|
||||||
brokenlinks = []
|
|
||||||
for root, dnames, fnames in os.walk(dir):
|
|
||||||
for fname in fnames:
|
|
||||||
fname = os.path.join(root, fname)
|
|
||||||
if os.path.islink(fname):
|
|
||||||
target = os.readlink(fname)
|
|
||||||
if not os.path.exists(fname):
|
|
||||||
brokenlinks.append(fname)
|
|
||||||
|
|
||||||
for link in brokenlinks:
|
|
||||||
target = os.readlink(link)
|
|
||||||
for dir in ('bin', 'sbin'):
|
|
||||||
newtarget = re.sub(r'^\.\./\.\./%s/(.*)' % dir, '../%s/\g<1>' % dir, target)
|
|
||||||
if newtarget != target:
|
|
||||||
os.unlink(link)
|
|
||||||
os.symlink(newtarget, link)
|
|
||||||
|
@ -24,6 +24,7 @@ import os
|
|||||||
import glob
|
import glob
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import shutil
|
import shutil
|
||||||
|
import re
|
||||||
|
|
||||||
from utils.fileutils import copy, move, remove, replace, touch
|
from utils.fileutils import copy, move, remove, replace, touch
|
||||||
|
|
||||||
@ -485,6 +486,25 @@ class InstallTree(object):
|
|||||||
dst_path=os.path.join("usr", "sbin"))
|
dst_path=os.path.join("usr", "sbin"))
|
||||||
remove(os.path.join(self.conf.treedir, "sbin"))
|
remove(os.path.join(self.conf.treedir, "sbin"))
|
||||||
|
|
||||||
|
# fix broken links
|
||||||
|
brokenlinks = []
|
||||||
|
for dir in ("bin", "sbin"):
|
||||||
|
dir = os.path.join(self.conf.treedir, "usr", dir)
|
||||||
|
for root, dnames, fnames in os.walk(dir):
|
||||||
|
for fname in fnames:
|
||||||
|
fname = os.path.join(root, fname)
|
||||||
|
if os.path.islink(fname) and not os.path.exists(fname):
|
||||||
|
brokenlinks.append(fname)
|
||||||
|
|
||||||
|
for link in brokenlinks:
|
||||||
|
target = os.readlink(link)
|
||||||
|
newtarget = re.sub(r"^\.\./\.\./(bin|sbin)/(.*)$", "../\g<1>/\g<2>",
|
||||||
|
target)
|
||||||
|
|
||||||
|
if newtarget != target:
|
||||||
|
os.unlink(link)
|
||||||
|
os.symlink(newtarget, link)
|
||||||
|
|
||||||
def scrub(self):
|
def scrub(self):
|
||||||
self.copy_stubs()
|
self.copy_stubs()
|
||||||
self.create_dogtail_conf()
|
self.create_dogtail_conf()
|
||||||
|
Loading…
Reference in New Issue
Block a user