File size: 1,953 Bytes
646fa4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import shutil
import subprocess
import sys
import tarfile
import urllib.request

def download_blender(url, destination):
    urllib.request.urlretrieve(url, destination)

def extract_archive(archive_file, destination):
    with tarfile.open(archive_file, 'r:xz') as tar:
        tar.extractall(destination)

def remove_file(file_path):
    os.remove(file_path)

def move_folder(source, destination):
    shutil.move(source, destination)

def create_symbolic_link(source, target):
    os.symlink(source, target)

def install_packages(packages):
    subprocess.run(['sudo', 'apt-get', 'update'])
    subprocess.run(['sudo', 'apt-get', 'install'] + packages + ['-y'])

def main():
    blender_url = 'https://download.blender.org/release/Blender4.0/blender-4.0.2-linux-x64.tar.xz'
    archive_file = 'blender-4.0.2-linux-x64.tar.xz'
    extracted_folder = 'blender-4.0.2-linux-x64'
    destination_folder = '/opt/blender-4.0.2'
    symbolic_link = '/usr/local/bin/blender'
    packages_to_install = ['libxxf86vm1', 'libgl1-mesa-glx', 'libegl-mesa0', 'libegl1']

    # Download Blender
    print("Downloading Blender...")
    download_blender(blender_url, archive_file)

    # Extract the downloaded archive
    print("Extracting Blender archive...")
    extract_archive(archive_file, '.')

    # Remove the downloaded archive
    print("Removing downloaded archive...")
    remove_file(archive_file)

    # Move the extracted folder to the desired location
    print("Moving Blender folder...")
    move_folder(extracted_folder, destination_folder)

    # Create a symbolic link to the Blender executable
    print("Creating symbolic link to Blender executable...")
    create_symbolic_link(os.path.join(destination_folder, 'blender'), symbolic_link)

    # Install required packages
    print("Installing required packages...")
    install_packages(packages_to_install)

    print("Installation complete.")

if __name__ == "__main__":
    main()