Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOWI Administratoren
Scripts
Commits
28a7dc92
Commit
28a7dc92
authored
1 year ago
by
Saad Chaaban
Browse files
Options
Downloads
Patches
Plain Diff
package_auto_updater_RStudio.ps1 hochgeladen.
parent
13d8316d
No related branches found
No related tags found
1 merge request
!7
Scripte aktualisiert
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
windows/chocolatey/package_auto_updater_RStudio.ps1
+102
-0
102 additions, 0 deletions
windows/chocolatey/package_auto_updater_RStudio.ps1
with
102 additions
and
0 deletions
windows/chocolatey/package_auto_updater_RStudio.ps1
0 → 100644
+
102
−
0
View file @
28a7dc92
$SOURCE_FILE
=
'\\husowi28c.user.hu-berlin.de\sowiabteilungen\edv\chocolatey-packages\R.Studio\tools\chocolateyInstall.ps1'
$Online_Url
=
'https://posit.co/download/rstudio-desktop/#download'
$Date
=
Get-Date
-Format
"yyyy-MM-dd"
$BACKUP_FILE
=
'\\husowi28c.user.hu-berlin.de\sowiabteilungen\edv\chocolatey-packages\R.Studio\tools\'
+
$Date
+
'_BAK_chocolateyInstall.ps1'
$NUSPEC
=
'\\husowi28c.user.hu-berlin.de\sowiabteilungen\edv\chocolatey-packages\R.Studio\R.Studio.nuspec'
$NUSPEC_BACKUP
=
'\\husowi28c.user.hu-berlin.de\sowiabteilungen\edv\chocolatey-packages\R.Studio\R.Studio.nuspec.BAK'
<#
Schritt 1
Alte Chocolatey Dateien Auslesen und String der URL sichern!
#>
$OLD_URL
=
Get-Content
$SOURCE_FILE
|
Select
-Index
4
<#
Entferne Nicht gewünschte Zeichen aus dem String.
Kurze regex Erklärung
Alles vor https://
Mögliche Sonderzeichen im Code
Entferne alle (falls vorhanden) Leerzeichen vor dem https
#>
$OLD_URL
=
$OLD_URL
-replace
'.*(?=https://)'
`
-replace
'[<>'']'
`
-replace
'\s'
<#
Schritt 2
WebRequest auf die R.Studio Seite.
Alle Links Filtern.
Nur den Link der Exe File kopieren.
#>
$Updated_URL
=
(
Invoke-WebRequest
$Online_URL
-UseBasicParsing
)
.
Links
|
Select-Object
-Property
href
|
where
href
-like
'https://download1.rstudio.org/electron/windows/*.exe'
$case
=
0
while
(
$case
-ne
999
)
{
switch
(
$case
)
{
0
{
<#
Ist unser Script up to Date?
Vergleiche die alte URL mit der neuen IRL
#>
$match
=
$Updated_URL
.
href
[
-1
]
-eq
$OLD_URL
If
(
-Not
$match
)
{
Write-Output
"Neue Version verfügbar!"
;
$case
=
1
}
else
{
$case
=
999
Write-Host
"Everything is Fine!"
;
}
}
1
{
$match
=
Get-Item
$BACKUP_FILE
If
(
-Not
$match
)
{
Write-Output
"Erstelle Backup!"
;
Copy-Item
$SOURCE_FILE
-Destination
$BACKUP_FILE
-Force
-Recurse
$case
=
2
}
else
{
$case
=
2
}
}
2
{
<# CASE2
Dateien bearbeiten
#>
# Hashwerte aus alter Datei lesen
$OLD_SHA
=
Get-Content
$SOURCE_FILE
|
Select
-Index
6
$OLD_SHA
=
$OLD_SHA
-replace
"'"
$wc
=
[
System.Net.WebClient
]::
new
()
$NEW_SHA
=
Get-FileHash
-InputStream
(
$wc
.
OpenRead
(
$Updated_URL
.
href
[
-1
]))
Write-Host
-NoNewline
"URL Online: "
$Updated_URL
.
href
[
-1
]
Write-Host
-NoNewline
"Hashwert Online: "
;
$NEW_SHA
.
Hash
.
ToLower
()
<#
ERSETZE SHA UND URL IN FILE
#>
(
Get-Content
$SOURCE_FILE
)
.
Replace
(
$OLD_URL
,
$Updated_URL
.
href
[
-1
])
|
Set-Content
$SOURCE_FILE
(
Get-Content
$SOURCE_FILE
)
.
Replace
(
$OLD_SHA
.
substring
(
13
),
$NEW_SHA
.
Hash
.
ToLower
())
|
Set-Content
$SOURCE_FILE
<#
Updaten der Nuspec File!
#>
Copy-Item
$NUSPEC
-Destination
$NUSPEC_BACKUP
-Force
-Recurse
# Lese die Version aus der URL heraus
$Version
=
$Updated_URL
.
href
[
-1
]
$Version
=
$Version
.
substring
(
$Version
.
length
-
17
,
9
)
$Version
=
" <version>
$Version
</version>"
$content
=
Get-Content
$NUSPEC
$content
[
19
]
=
$Version
# Schreibe neu Version in die Datei!
$content
|
Out-File
$NUSPEC
$case
=
3
}
3
{
<#
Pushen des aktualisierten Pakets
Noch nicht aktiv da dies mit einer Chocolatey Abfrage gekoppelt werden sollte!
$nupkg = choco pack $NUSPEC
$nupkg = $nupkg -replace "'" | Select -index 2
choco push $nupkg.Substring(29) --source=https://push.chocolatey.org/
Remove-Item $nupkg.Substring(29)
#>
$case
=
999
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment