Rizin
unix-like reverse engineering framework and cli tools
InstallSymlink Namespace Reference

Functions

def install_symlink (src, dst, install_dir, dst_is_dir=False, dir_mode=0o777)
 
def main ()
 

Function Documentation

◆ install_symlink()

def InstallSymlink.install_symlink (   src,
  dst,
  install_dir,
  dst_is_dir = False,
  dir_mode = 0o777 
)

Definition at line 16 of file InstallSymlink.py.

16 def install_symlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777):
17  if not install_dir.exists():
18  install_dir.mkdir(mode=dir_mode, parents=True, exist_ok=True)
19  if not install_dir.is_dir():
20  raise NotADirectoryError(install_dir)
21 
22  new_dst = install_dir.joinpath(dst)
23  if new_dst.is_symlink() and os.readlink(new_dst) == src:
24  print('File exists: {!r} -> {!r}'.format(new_dst, src))
25  return
26  print('Installing symlink {!r} -> {!r}'.format(new_dst, src))
27  new_dst.symlink_to(src, target_is_directory=dst_is_dir)
28 
29 

Referenced by main().

◆ main()

def InstallSymlink.main ( void  )

Definition at line 30 of file InstallSymlink.py.

30 def main():
31  import argparse
32  parser = argparse.ArgumentParser(description='Install a symlink',
33  usage='{0} [-h] [-d] [-m MODE] source dest install_dir\n\n'
34  'example:\n'
35  ' {0} dash sh /bin'.format(pathlib.Path(__file__).name))
36  parser.add_argument('source', help='target to link')
37  parser.add_argument('dest', help='link name')
38  parser.add_argument('install_dir', help='installation directory')
39  parser.add_argument('-d', '--isdir',
40  action='store_true',
41  help='dest is a directory')
42  parser.add_argument('-m', '--mode',
43  help='directory mode on creating if not exist',
44  default='0o755')
45  args = parser.parse_args()
46 
47  dir_mode = int(args.mode, 8)
48 
49  meson_destdir = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX', default='')
50  install_dir = pathlib.Path(meson_destdir, args.install_dir)
51  install_symlink(args.source, args.dest, install_dir, args.isdir, dir_mode)
52 
53 
static int
Definition: sfsocketcall.h:114

References install_symlink(), and int.