File: install

package info (click to toggle)
libcpucycles 0~20260105-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 588 kB
  • sloc: ansic: 1,174; python: 404; sh: 62; makefile: 41
file content (28 lines) | stat: -rwxr-xr-x 789 bytes parent folder | download
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
28
#!/usr/bin/env python3

import os
import sys
import shutil
import tempfile

destdir = os.getenv('DESTDIR','')
prefix = sys.argv[1]
dirs = 'man/man1','man/man3','lib','include','bin'
install = {}

os.umask(0o22)

for target in dirs:
  install[target] = f'{destdir}{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))