meta: implement linking whole component directories
This commit is contained in:
@@ -7,13 +7,15 @@ dotfile_dir = sys.argv[1]
|
|||||||
home_dir = str(pathlib.Path.home())
|
home_dir = str(pathlib.Path.home())
|
||||||
|
|
||||||
def install_component(comp):
|
def install_component(comp):
|
||||||
print('Installing configuration: {}...'.format(comp['name']))
|
print('Installing component: {}...'.format(comp['name']))
|
||||||
comp_dir = os.path.join(dotfile_dir, comp['name'])
|
comp_dir = os.path.join(dotfile_dir, comp['name'])
|
||||||
|
|
||||||
if 'link-files' in comp:
|
if 'link-files' in comp:
|
||||||
link_files = comp['link-files']
|
link_files = comp['link-files']
|
||||||
for f in link_files:
|
for f in link_files:
|
||||||
source_path = os.path.join(comp_dir, f['source'])
|
source_path = os.path.join(comp_dir, f['source'])
|
||||||
|
if f['source'] == '.':
|
||||||
|
source_path = comp_dir
|
||||||
dest_path = os.path.join(home_dir, f['dest'])
|
dest_path = os.path.join(home_dir, f['dest'])
|
||||||
if not os.path.exists(dest_path):
|
if not os.path.exists(dest_path):
|
||||||
print(' linking {} -> {}'.format(dest_path, source_path))
|
print(' linking {} -> {}'.format(dest_path, source_path))
|
||||||
@@ -23,6 +25,8 @@ def install_component(comp):
|
|||||||
link_dirs = comp['link-dirs']
|
link_dirs = comp['link-dirs']
|
||||||
for f in link_dirs:
|
for f in link_dirs:
|
||||||
source_path = os.path.join(comp_dir, f['source'])
|
source_path = os.path.join(comp_dir, f['source'])
|
||||||
|
if f['source'] == '.':
|
||||||
|
source_path = comp_dir
|
||||||
dest_path = os.path.join(home_dir, f['dest'])
|
dest_path = os.path.join(home_dir, f['dest'])
|
||||||
if not os.path.exists(dest_path):
|
if not os.path.exists(dest_path):
|
||||||
print(' linking {} -> {}'.format(dest_path, source_path))
|
print(' linking {} -> {}'.format(dest_path, source_path))
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ def uninstall_component(comp):
|
|||||||
for f in link_dirs:
|
for f in link_dirs:
|
||||||
source_path = os.path.join(comp_dir, f['source'])
|
source_path = os.path.join(comp_dir, f['source'])
|
||||||
dest_path = os.path.join(home_dir, f['dest'])
|
dest_path = os.path.join(home_dir, f['dest'])
|
||||||
if not os.path.exists(dest_path):
|
if os.path.exists(dest_path):
|
||||||
print(' removing link {} -> {}'.format(dest_path))
|
print(' removing link {}'.format(dest_path))
|
||||||
os.unlink(dest_path)
|
os.unlink(dest_path)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user