File: install

package info (click to toggle)
librandombytes 0~20240318-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 328 kB
  • sloc: ansic: 411; python: 340; sh: 137; makefile: 23
file content (27 lines) | stat: -rwxr-xr-x 749 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3

import os
import sys
import shutil
import tempfile

prefix = sys.argv[1]
dirs = 'man/man1','man/man3','lib','include','bin'
install = {}

os.umask(0o22)

for target in dirs:
  install[target] = '%s/%s'%(prefix,target)
  os.makedirs(install[target],exist_ok=True)

os.umask(0o77)

for target in dirs:
  with tempfile.TemporaryDirectory(dir=install[target]) as t:
    for fn in sorted(os.listdir('package/'+target)):
      try:
        shutil.copy2('package/%s/%s' % (target,fn),'%s/%s' % (t,fn),follow_symlinks=False)
      except TypeError: # XXX: old python3; should copy symlinks manually
        shutil.copy2('package/%s/%s' % (target,fn),'%s/%s' % (t,fn))
      os.rename('%s/%s' % (t,fn),'%s/%s' % (install[target],fn))