首页 > 其他分享 >setup_dev.ps1

setup_dev.ps1

时间:2023-06-20 20:01:15浏览次数:47  
标签:-- setup dev vs dir install ps1 pacman bash

##############################################################################

千里业务windows开发环境安装脚本

##############################################################################

note: 如果在运行中遇到安装权限问题:

以管理员身份打开powershell,并运行如下命令设置安装权限

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

TODO:

1, 提示界面,用户可选择需安装的组件

2,检查系统中已安装的组件,提升用户是否覆盖

3,安装完检查系统是否工作,并打印对于组件的版本号

$ErrorActionPreference = "Inquire"

$current_dir = Split-Path -Parent \(MyInvocation.MyCommand.Definition cd "\)current_dir"
\(install_dir = "D:\msys64_longsight" \)user_name = "longsight"

function Init-Msys {
Write-Host "Installing MSYS2..." -ForegroundColor Cyan

if(Test-Path "$install_dir") {
    Remove-Item "$install_dir" -Recurse -Force
}

# 下载msys2的自安装包到当前目录
Write-Host "Downloading MSYS2 SFX package..."
$msys_url = "http://longsight.inhuawei.com/download/tools/msys2-base-x86_64-20220603.sfx.exe"
$msys_installer = "$current_dir/msys2.exe"
(New-Object System.Net.WebClient).DownloadFile("$msys_url", "$msys_installer")
Write-Host "Extracting MSYS2 SFX pacakge and copy folder to $install_dir ..."
.\msys2.exe -y -o"$current_dir" # Extract to .\msys64
Remove-Item "$msys_installer"  # Delete the archive again
Move-Item .\msys64 "$install_dir" # Move to target folder

Write-Host "Modifying Configuration files of MSYS2 enviromnent..."
# 修改msys2的默认用户名为dev
(Get-Content -Path "$install_dir\etc\nsswitch.conf") -Replace "db_home: cygwin desc", "db_home: /home/$user_name" | Set-Content -Path "$install_dir\etc\nsswitch.conf"
# 更新pacman的镜像网站
Copy-Item .\pacman.conf -Destination "$install_dir\etc\pacman.conf" -Force
Copy-Item .\pacman.d -Recurse -Destination "$install_dir\etc" -Force
Add-Content "$install_dir\etc\profile.d\lang.sh" "export LANG=C"

}

function bash($command) {
Write-Host $command -NoNewline
D:\msys64_longsight\usr\bin\sh.exe --login -c $command
Write-Host " -OK" -ForegroundColor Green
}

function Update-Msys {
# Run for the first time
Write-Host "Initializing MSYS2 bash..."
bash ' '

Write-Host "Updating MSYS2 package..."
bash 'pacman --noconfirm -Syuu'  # Core update (in case any core packages are outdated)
bash 'pacman --noconfirm -Syuu'  # Normal update

}

function Setup-Tools {
Write-Host "Installing development tools..."
bash 'pacman --sync --noconfirm base-devel'
bash 'pacman --sync --noconfirm binutils'
bash 'pacman --sync --noconfirm vim'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-gcc-libs'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-gcc'
bash 'pacman --sync --noconfirm msys/git'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-git-lfs'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-cmake'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-ninja'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-python-pip'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-doxygen'
bash 'pacman --sync --noconfirm mingw-w64-x86_64-graphviz'
bash 'pacman --sync --noconfirm msys/zsh'

bash '/mingw64/bin/pip config set global.index-url http://mirrors.tools.huawei.com/pypi/simple'
bash '/mingw64/bin/pip config set install.trusted-host mirrors.tools.huawei.com'
bash '/mingw64/bin/pip install Sphinx'
bash '/mingw64/bin/pip install sphinx-rtd-theme'
bash '/mingw64/bin/pip install sphinx-sitemap'
bash '/mingw64/bin/pip install breathe'
bash '/mingw64/bin/pip install myst-parser'
bash '/mingw64/bin/pip install conan==1.52.0'

# 配置zsh为默认的shell
(Get-Content -Path "$install_dir\msys2_shell.cmd") -Replace 'LOGINSHELL=bash', 'LOGINSHELL=zsh' | Set-Content -Path "$install_dir\msys2_shell.cmd"
(Get-Content -Path "$install_dir\msys2_shell.cmd") -Replace 'rem set MSYS=winsymlinks:nativestrict', 'set MSYS=winsymlinks:nativestrict' | Set-Content -Path "$install_dir\msys2_shell.cmd"
(Get-Content -Path "$install_dir\msys2_shell.cmd") -Replace 'rem set MSYS2_PATH_TYPE=inherit', 'set MSYS2_PATH_TYPE=inherit' | Set-Content -Path "$install_dir\msys2_shell.cmd"
$call_vcvars = 'call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"'
(Get-Content -Path "$install_dir\msys2_shell.cmd") -Replace "@echo off", "@echo off`n$call_vcvars" | Set-Content -Path "$install_dir\msys2_shell.cmd"
Add-Content "$install_dir\msys2.ini" "SHELL=/usr/bin/zsh"
Write-Host "MSYS2 installed" -ForegroundColor Green

}

function Setup-Dotfiles {
Write-Host "Copy dotfiles to new development enviroment..."
Copy-Item -Path .\dotfiles* -Destination "$install_dir\home$user_name" -Recurse
}

function Setup-Conan {
Copy-Item -Path .\conan.zip -Destination "$install_dir\home$user_name"
bash '/mingw64/bin/conan config install ./conan.zip'
bash '/mingw64/bin/conan user -p Huawei@tesgine123 -r conan-tesgine ate-ax'
}

function Create-Installer {
7z a -sfx -m0=lzma2 -mfb=64 -md=32m -ms=on -mx=9 msys2-longsight-sfx.exe $install_dir
}

function Install-VSCommunity {
Write-Host "Installing VSCommunity 2022..." -ForegroundColor Cyan

# 下载VSCommunity的自安装包到当前目录
Write-Host "Downloading VSCommunity install package..."
$vs_url = "http://longsight.inhuawei.com/download/tools/vs_local.exe"
$vs_boostrap = "$current_dir/vs_local.exe"
(New-Object System.Net.WebClient).DownloadFile("$vs_url", "$vs_boostrap")
Write-Host "Download VSCommunity pacakge done" -ForegroundColor Green
.\vs_local.exe -y  # Extract to .\vs_local

$vs_download = "$current_dir/vs_local/"
$vs_installer = "$vs_download/vs_setup.exe"

$workload_argument = @(
	'--add Microsoft.VisualStudio.Workload.NativeDesktop',
	'--add Microsoft.VisualStudio.Component.VC.Llvm.Clang',
	'--add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset'
) 

$options_workload          = [string]::Join(" ", $workload_argument )
$options_quiet              = "--quiet"
$options_layout             = "--layout $vs_download"
$optionsIncludeRecommended = "--includeRecommended"
$vs_layout_options = @(
	$options_layout,
	$options_workload,
	"--lang En-us",
	"--includeRecommended",
	"--quiet",
	"--wait"
)
$vs_install_options = @(
	$options_workload,
	"--locale En-us",
	"--includeRecommended",
	"--wait",
	"--passive"
)

Write-Host "Start Installing VSCommunity..."
$process = Start-Process -FilePath "$vs_installer" -ArgumentList $vs_install_options -Wait -PassThru
Write-Host "Install VSCommunity Done" -ForegroundColor Green

#Remove-Item "$vs_boostrap"  # Delete the archive again
#Remove-Item "$vs_download"  # Delete the archive again
Write-Host "VSCommunity 2022 installed" -ForegroundColor Green

}

Init-Msys
Update-Msys
Setup-Tools
Setup-Dotfiles
Setup-Conan
Install-VSCommunity

Create-Installer

Write-Host "Done!!!" -ForegroundColor Green

标签:--,setup,dev,vs,dir,install,ps1,pacman,bash
From: https://www.cnblogs.com/ronaldHU/p/17494511.html

相关文章

  • DevOps|中式土味OKR与绩效考核落地与实践
    昨天一个小伙伴和我讨论了一下OKR和绩效管理,所以这次想简单明了地说下在中国怎么做比较合适,很多高大上的理论无法落地也是空中楼阁。首先说一些,我个人的理解道德品质和能力素质决定了一个人的职位行为职位行为决定了业务结果不同级别/工作性质的人员,绩效考核应该有不同权重组合团队......
  • DevOps|中式土味OKR与绩效考核落地与实践
    昨天一个小伙伴和我讨论了一下OKR和绩效管理,所以这次想简单明了地说下在中国怎么做比较合适,很多高大上的理论无法落地也是空中楼阁。 首先说一些,我个人的理解道德品质和能力素质决定了一个人的职位行为职位行为决定了业务结果不同级别/工作性质的人员,绩效考核应该有不......
  • A Practical Methodology, HSM, Handler,Service,Model, for Golang Backend Developm
    EverybodyisfamiliarwiththewidelyadoptedMVC(Model-View-Controller)pattern,whichhasbeenusedformanyyearsacrossvariouslanguagesandframeworks.MVChasproventobeapracticalpatternfororganizingprogramswithuserinterfacesandmultip......
  • DevExpress WPF功能区控件,更轻松创建商业应用工具栏!(下)
    在上文中(点击这里回顾>>),我们主要介绍了DevExpressWPF的Ribbon、Toolbar和Menus组件支持MVVM、功能区命令栏和视图等,本文将继续介绍这些组件的自定义功能等。DevExpressWPF拥有120+个控件和库,将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpressWPF能创建......
  • DevExpress中Diagram中常用的一些方法
    1、Diagram中插入一个形状的方法:DiagramShapediagramShape=newDiagramShape();//新建一个形状对象diagramShape.Shape=DevExpress.Diagram.Core.BasicShapes.Rectangle;//赋值为一个基础图形:矩形diagramShape.ConnectionPoints=newPointCollection(newList<PointFloa......
  • ShowMeBug与极狐(GitLab)战略合作,推动DevOps人才高效甄选
    近日,ShowMeBug与领先的开放式一体化安全DevOps平台提供商极狐(GitLab)达成深度合作协议,双方将致力于共同打造具有行业强认可度以及高实用性的DevOps岗位题型,助力企业通过更为专业、标准的技术笔试题型,提升DevOps岗位人才筛选效率。极狐GitLab是面向中国市场的开放式一体化安全Dev......
  • VCL界面控件DevExpress VCL v23.1.3全新首发 - 支持Windows 11新主题
    DevExpressVCL Controls是Devexpress公司旗下最老牌的用户界面套包,所包含的控件有:数据录入、图表、数据分析、导航、布局等。该控件能帮助您创建优异的用户体验,提供高影响力的业务解决方案,并利用您现有的VCL技能为未来构建下一代应用程序。DevExpressVCLv23.1官方正式版下载......
  • 安装openvas时候的报错 bash: openvas-setup: command not found
     由于kali官方默认没有安装openvas,但是kali源中有,需要我们使用apt命令手动安装。 错误一kali@kali:~$openvas-setupbash:openvas-setup:commandnotfound错误原因openvas官方在新版本中改名gvm解决方法 因此openvas命令改为gvm。 错误二kali@kali:~$sudogvm-setupER......
  • setContentView(R.layout.activity_);ui->setupUi(this);
    publicclassTutorialPartIIIextendsActivity{@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);//setContentView(R.layout.activity_tutorial_part_iii);//*......
  • findstr /s "AttachedDevice" *.cpp
    findstr/s"AttachedDevice"*.cppchapter22\FileFilter\DriverEntry.cpp:     if(!fido->AttachedDevice||(fido->AttachedDevice->Flags&DO_POWER_PAGABLE))chapter22\FileFilter\DriverEntry.cpp: PDEVICE_OBJECTldo=......