mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
dankinstall: re-simplify installation
This commit is contained in:
@@ -645,19 +645,17 @@ func (m *ManualPackageInstaller) installMatugen(ctx context.Context, sudoPasswor
|
|||||||
func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
m.log("Installing DankMaterialShell (DMS)...")
|
m.log("Installing DankMaterialShell (DMS)...")
|
||||||
|
|
||||||
// Always install/update the DMS binary
|
|
||||||
if err := m.installDMSBinary(ctx, sudoPassword, progressChan); err != nil {
|
if err := m.installDMSBinary(ctx, sudoPassword, progressChan); err != nil {
|
||||||
m.logError("Failed to install DMS binary", err)
|
m.logError("Failed to install DMS binary", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle DMS config - clone if missing, pull if exists
|
|
||||||
dmsPath := filepath.Join(os.Getenv("HOME"), ".config/quickshell/dms")
|
dmsPath := filepath.Join(os.Getenv("HOME"), ".config/quickshell/dms")
|
||||||
|
|
||||||
if _, err := os.Stat(dmsPath); os.IsNotExist(err) {
|
if _, err := os.Stat(dmsPath); os.IsNotExist(err) {
|
||||||
// Config doesn't exist, clone it
|
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseSystemPackages,
|
Phase: PhaseSystemPackages,
|
||||||
Progress: 0.90,
|
Progress: 0.90,
|
||||||
Step: "Cloning DankMaterialShell config...",
|
Step: "Cloning DankMaterialShell...",
|
||||||
IsComplete: false,
|
IsComplete: false,
|
||||||
CommandInfo: "git clone https://github.com/AvengeMedia/DankMaterialShell.git",
|
CommandInfo: "git clone https://github.com/AvengeMedia/DankMaterialShell.git",
|
||||||
}
|
}
|
||||||
@@ -667,81 +665,89 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, s
|
|||||||
return fmt.Errorf("failed to create quickshell config directory: %w", err)
|
return fmt.Errorf("failed to create quickshell config directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpRepoPath := filepath.Join(os.TempDir(), "dms-clone-tmp")
|
|
||||||
defer os.RemoveAll(tmpRepoPath)
|
|
||||||
|
|
||||||
cloneCmd := exec.CommandContext(ctx, "git", "clone",
|
cloneCmd := exec.CommandContext(ctx, "git", "clone",
|
||||||
"https://github.com/AvengeMedia/DankMaterialShell.git", tmpRepoPath)
|
"https://github.com/AvengeMedia/DankMaterialShell.git", dmsPath)
|
||||||
if err := cloneCmd.Run(); err != nil {
|
if err := cloneCmd.Run(); err != nil {
|
||||||
return fmt.Errorf("failed to clone DankMaterialShell: %w", err)
|
return fmt.Errorf("failed to clone DankMaterialShell: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !forceDMSGit {
|
if !forceDMSGit {
|
||||||
fetchCmd := exec.CommandContext(ctx, "git", "-C", tmpRepoPath, "fetch", "--tags")
|
tagCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "describe", "--tags", "--abbrev=0", "origin/master")
|
||||||
if err := fetchCmd.Run(); err == nil {
|
tagOutput, err := tagCmd.Output()
|
||||||
tagCmd := exec.CommandContext(ctx, "git", "-C", tmpRepoPath, "describe", "--tags", "--abbrev=0", "origin/master")
|
if err != nil {
|
||||||
if tagOutput, err := tagCmd.Output(); err == nil {
|
m.log("Using default branch (no tags found)")
|
||||||
latestTag := strings.TrimSpace(string(tagOutput))
|
return nil
|
||||||
checkoutCmd := exec.CommandContext(ctx, "git", "-C", tmpRepoPath, "checkout", latestTag)
|
|
||||||
if err := checkoutCmd.Run(); err == nil {
|
|
||||||
m.log(fmt.Sprintf("Checked out latest tag: %s", latestTag))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
srcPath := filepath.Join(tmpRepoPath, "quickshell")
|
|
||||||
cpCmd := exec.CommandContext(ctx, "cp", "-r", srcPath, dmsPath)
|
|
||||||
if err := cpCmd.Run(); err != nil {
|
|
||||||
return fmt.Errorf("failed to copy quickshell directory: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
m.log("DankMaterialShell config cloned successfully")
|
|
||||||
} else {
|
|
||||||
// Config exists, update it
|
|
||||||
progressChan <- InstallProgressMsg{
|
|
||||||
Phase: PhaseSystemPackages,
|
|
||||||
Progress: 0.90,
|
|
||||||
Step: "Updating DankMaterialShell config...",
|
|
||||||
IsComplete: false,
|
|
||||||
CommandInfo: "Updating ~/.config/quickshell/dms",
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpRepoPath := filepath.Join(os.TempDir(), "dms-update-tmp")
|
|
||||||
defer os.RemoveAll(tmpRepoPath)
|
|
||||||
|
|
||||||
cloneCmd := exec.CommandContext(ctx, "git", "clone",
|
|
||||||
"https://github.com/AvengeMedia/DankMaterialShell.git", tmpRepoPath)
|
|
||||||
if err := cloneCmd.Run(); err != nil {
|
|
||||||
m.logError("Failed to clone DankMaterialShell for update", err)
|
|
||||||
} else {
|
|
||||||
if !forceDMSGit {
|
|
||||||
fetchCmd := exec.CommandContext(ctx, "git", "-C", tmpRepoPath, "fetch", "--tags")
|
|
||||||
if err := fetchCmd.Run(); err == nil {
|
|
||||||
tagCmd := exec.CommandContext(ctx, "git", "-C", tmpRepoPath, "describe", "--tags", "--abbrev=0", "origin/master")
|
|
||||||
if tagOutput, err := tagCmd.Output(); err == nil {
|
|
||||||
latestTag := strings.TrimSpace(string(tagOutput))
|
|
||||||
checkoutCmd := exec.CommandContext(ctx, "git", "-C", tmpRepoPath, "checkout", latestTag)
|
|
||||||
_ = checkoutCmd.Run()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srcPath := filepath.Join(tmpRepoPath, "quickshell")
|
latestTag := strings.TrimSpace(string(tagOutput))
|
||||||
rsyncCmd := exec.CommandContext(ctx, "rsync", "-a", "--delete", srcPath+"/", dmsPath+"/")
|
checkoutCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "checkout", latestTag)
|
||||||
if err := rsyncCmd.Run(); err != nil {
|
if err := checkoutCmd.Run(); err != nil {
|
||||||
cpCmd := exec.CommandContext(ctx, "cp", "-rf", srcPath+"/.", dmsPath+"/")
|
m.logError(fmt.Sprintf("Failed to checkout tag %s", latestTag), err)
|
||||||
if err := cpCmd.Run(); err != nil {
|
return nil
|
||||||
m.logError("Failed to update DankMaterialShell config", err)
|
|
||||||
} else {
|
|
||||||
m.log("DankMaterialShell config updated successfully")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m.log("DankMaterialShell config updated successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.log(fmt.Sprintf("Checked out latest tag: %s", latestTag))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.log("DankMaterialShell cloned successfully")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.90,
|
||||||
|
Step: "Updating DankMaterialShell...",
|
||||||
|
IsComplete: false,
|
||||||
|
CommandInfo: "Updating ~/.config/quickshell/dms",
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "fetch", "origin", "--tags", "--force")
|
||||||
|
if err := fetchCmd.Run(); err != nil {
|
||||||
|
m.logError("Failed to fetch updates", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
tagCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "describe", "--exact-match", "--tags", "HEAD")
|
||||||
|
onTag := tagCmd.Run() == nil
|
||||||
|
|
||||||
|
if onTag && !forceDMSGit {
|
||||||
|
latestTagCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "describe", "--tags", "--abbrev=0", "origin/master")
|
||||||
|
tagOutput, err := latestTagCmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
m.logError("Failed to get latest tag", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
latestTag := strings.TrimSpace(string(tagOutput))
|
||||||
|
checkoutCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "checkout", latestTag)
|
||||||
|
if err := checkoutCmd.Run(); err != nil {
|
||||||
|
m.logError(fmt.Sprintf("Failed to checkout tag %s", latestTag), err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
m.log(fmt.Sprintf("Updated to tag: %s", latestTag))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
branchCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "rev-parse", "--abbrev-ref", "HEAD")
|
||||||
|
branchOutput, err := branchCmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
m.logError("Failed to get current branch", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
branch := strings.TrimSpace(string(branchOutput))
|
||||||
|
if branch == "" {
|
||||||
|
branch = "master"
|
||||||
|
}
|
||||||
|
|
||||||
|
pullCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "pull", "origin", branch)
|
||||||
|
if err := pullCmd.Run(); err != nil {
|
||||||
|
m.logError("Failed to pull updates", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
m.log("DankMaterialShell updated successfully")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user