Compare commits

..

No commits in common. "main" and "kinetic" have entirely different histories.

30 changed files with 312 additions and 694 deletions

View File

@ -1 +0,0 @@
1

View File

@ -1 +0,0 @@
1

View File

@ -1 +0,0 @@
1

View File

@ -1 +0,0 @@
2

View File

@ -1,40 +0,0 @@
name: PikaOS Package Build Only (Canary) (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/build-canary-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:canaryv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh

View File

@ -1,40 +0,0 @@
name: PikaOS Package Build Only (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/build-nest-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:nestv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh

28
.github/workflows/go.yml vendored Normal file
View File

@ -0,0 +1,28 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...

View File

@ -1,43 +0,0 @@
name: PikaOS Package Build & Release (Canary) (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/release-canary-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:canaryv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh
- name: Release Package
run: ./release.sh

View File

@ -1,43 +0,0 @@
name: PikaOS Package Build & Release (amd64-v3)
on:
push:
branches:
- main
paths:
- '.github/release-nest-v3'
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/pikaos-linux/pikaos-builder:nestv3
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Update APT Cache
run: apt-get update -y
- name: Set Build Config
run: cp -vf ./pika-build-config/amd64-v3.sh ./pika-build-config.sh
- name: Setup Makefile
run: cp -vf ./Makefile-v3 ./Makefile
- name: Build Package
run: ./main.sh
- name: Release Package
run: ./release.sh

40
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: PikaOS Package Release
on:
workflow_dispatch
jobs:
build:
runs-on: self-hosted
container:
image: ubuntu:22.10
volumes:
- /proc:/proc
options: --privileged -it
steps:
- uses: actions/checkout@v3
- name: Install needed packages
run: apt update && apt install software-properties-common sudo git bc gpg gpg-agent bison build-essential ccache cpio fakeroot flex git kmod libelf-dev libncurses5-dev libssl-dev lz4 qtbase5-dev rsync schedtool wget zstd tar reprepro dpkg-sig devscripts -y
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
if_key_exists: replace
- name: Build Package
run: ./main.sh
- name: Release Package
run: ./release.sh

View File

@ -3,5 +3,5 @@ all:
install: install:
mkdir -p $(DESTDIR)/usr/bin/ mkdir -p $(DESTDIR)/usr/bin/
GOAMD=v3 go build -ldflags="-s -w" -o $(DESTDIR)/usr/bin/pikman -buildvcs=false go build -ldflags="-s -w" -o $(DESTDIR)/usr/bin/pikman
chmod 755 $(DESTDIR)/usr/bin/pikman chmod 755 $(DESTDIR)/usr/bin/pikman

View File

@ -4,7 +4,7 @@
pikman [global options] command [command options] [arguments...] pikman [global options] command [command options] [arguments...]
## VERSION: ## VERSION:
v1.23.6.5.2 v1.23.2.17.0
## COMMANDS: ## COMMANDS:
@ -24,7 +24,6 @@ v1.23.6.5.2
- **unexport** - Unexport/Remove a program's desktop entry - **unexport** - Unexport/Remove a program's desktop entry
- **update** - Update the list of available packages - **update** - Update the list of available packages
- **upgrade** - Upgrade the system by installing/upgrading available packages - **upgrade** - Upgrade the system by installing/upgrading available packages
- **upgrades** - List the available upgrades
- **help, h** - Shows a list of commands or help for one command - **help, h** - Shows a list of commands or help for one command
## GLOBAL OPTIONS: ## GLOBAL OPTIONS:

View File

@ -2,24 +2,20 @@ package alpine
var PackageManager = "apx" var PackageManager = "apx"
var ContainerSubsystem = "pikman-alpine"
var ApxSubsystem = "alpine"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "pikman-alpine autoremove", "autoremove": "--apk autoremove",
"clean": "pikman-alpine clean", "clean": "--apk clean",
"export": "pikman-alpine export", "export": "--apk export",
"init": "subsystems new -n pikman-alpine -s alpine", "init": "--apk init",
"install": "pikman-alpine install", "install": "--apk install",
"list": "pikman-alpine list", "list": "--apk list",
"purge": "pikman-alpine purge", "log": "--apk log",
"run": "pikman-alpine run", "purge": "--apk purge",
"remove": "pikman-alpine remove", "run": "--apk run",
"enter": "pikman-alpine enter", "remove": "--apk remove",
"search": "pikman-alpine search", "enter": "--apk enter",
"show": "pikman-alpine show", "search": "--apk search",
"update": "pikman-alpine update", "show": "--apk show",
"upgrade": "pikman-alpine upgrade", "update": "--apk update",
"unexport": "pikman-alpine unexport", "upgrade": "--apk upgrade",
} }

View File

@ -2,24 +2,20 @@ package arch
var PackageManager = "apx" var PackageManager = "apx"
var ContainerSubsystem = "pikman-arch-linux"
var ApxSubsystem = "arch-linux"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "pikman-arch-linux autoremove", "autoremove": "--aur autoremove",
"clean": "pikman-arch-linux clean", "clean": "--aur clean",
"export": "pikman-arch-linux export", "export": "--aur export",
"init": "subsystems new -n pikman-arch-linux -s arch-linux", "init": "--aur init",
"install": "pikman-arch-linux install", "install": "--aur install",
"list": "pikman-arch-linux list", "list": "--aur list",
"purge": "pikman-arch-linux purge", "log": "--aur log",
"run": "pikman-arch-linux run", "purge": "--aur purge",
"remove": "pikman-arch-linux remove", "run": "--aur run",
"enter": "pikman-arch-linux enter", "remove": "--aur remove",
"search": "pikman-arch-linux search", "enter": "--aur enter",
"show": "pikman-arch-linux show", "search": "--aur search",
"update": "pikman-arch-linux update", "show": "--aur show",
"upgrade": "pikman-arch-linux upgrade", "update": "--aur update",
"unexport": "pikman-arch-linux unexport", "upgrade": "--aur upgrade",
} }

View File

@ -1,178 +0,0 @@
package command
import (
"encoding/json"
"fmt"
"os"
"os/exec"
"strings"
"pikman/alpine"
"pikman/arch"
"pikman/fedora"
"pikman/flatpak"
"pikman/types"
"pikman/ubuntu"
"pikman/updates"
"github.com/urfave/cli/v2"
)
var commandsMap = map[types.OSType]map[string]string{
types.Ubuntu: ubuntu.Commands,
types.Arch: arch.Commands,
types.Fedora: fedora.Commands,
types.Alpine: alpine.Commands,
types.Flatpak: flatpak.Commands,
}
var packageManagerMap = map[types.OSType]string{
types.Ubuntu: ubuntu.PackageManager,
types.Arch: arch.PackageManager,
types.Fedora: fedora.PackageManager,
types.Alpine: alpine.PackageManager,
types.Flatpak: flatpak.PackageManager,
}
var containerSubsystemMap = map[types.OSType]string{
types.Arch: arch.ContainerSubsystem,
types.Fedora: fedora.ContainerSubsystem,
types.Alpine: alpine.ContainerSubsystem,
}
func (c *Command) ContainerSubsystem() string {
return containerSubsystemMap[c.OsType]
}
var apxSubsystemMap = map[types.OSType]string{
types.Arch: arch.ApxSubsystem,
types.Fedora: fedora.ApxSubsystem,
types.Alpine: alpine.ApxSubsystem,
}
func (c *Command) ApxSubsystem() string {
return apxSubsystemMap[c.OsType]
}
type Command struct {
Command string
OsType types.OSType
ContainerName string
PackageName []string
IsUpgradable bool
IsInstalled bool
IsJSON bool
}
func (c *Command) Process(cCtx *cli.Context) error {
c.Command = cCtx.Command.FullName()
c.PackageName = cCtx.Args().Slice()
return c.processCommand()
}
func (c *Command) processCommand() error {
if (c.OsType == types.Ubuntu || c.OsType == types.Flatpak) && c.Command == "upgrades" {
return c.runUpgrades()
}
var err error
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.Command != "init" {
err = c.initContainer()
if err != nil {
return err
}
}
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.ContainerName != "" {
c.PackageName = append([]string{"--name " + c.ContainerName}, c.PackageName...)
}
if c.OsType == types.Ubuntu && c.IsUpgradable {
c.PackageName = append([]string{"--upgradable"}, c.PackageName...)
}
if c.OsType == types.Ubuntu && c.IsInstalled {
c.PackageName = append([]string{"--installed"}, c.PackageName...)
}
commandToExecute, err := c.getCommand()
if err != nil {
return err
}
cmd := exec.Command("/bin/sh", "-c", commandToExecute)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err = cmd.Run()
if err != nil {
return err
}
return nil
}
func (c *Command) getCommand() (string, error) {
commandMap := commandsMap[c.OsType]
cmd, ok := commandMap[c.Command]
if ok {
return fmt.Sprintf("%s %s %s", packageManagerMap[c.OsType], cmd, strings.Join(c.PackageName, " ")), nil
}
return "", fmt.Errorf("%s: is not a valid command for this distro", c.Command)
}
func (c *Command) runUpgrades() error {
if c.OsType == types.Ubuntu {
return updates.GetUbuntuUpdates(c.IsJSON)
}
return updates.GetFlatpakUpdates(c.IsJSON)
}
func (c *Command) initContainer() error {
contName := c.ContainerName
if contName == "" {
contName = c.ContainerSubsystem()
}
cmd := exec.Command("/bin/bash", "-c", "apx subsystems list -j")
outb, err := cmd.Output()
if err != nil {
return err
}
var out []apxSubs
err = json.Unmarshal(outb, &out)
if err != nil {
return err
}
isMatch := false
for _, sub := range out {
if sub.Name == contName {
isMatch = true
break
}
}
if !isMatch {
fmt.Println("Warning: Subsystem hasn't been pre-initialized, initializing...")
cmd_exec := exec.Command("/bin/bash", "-c", "apx subsystems new -n "+contName+" -s "+c.ApxSubsystem())
cmd_exec.Stdout = os.Stdout
cmd_exec.Stdin = os.Stdin
cmd_exec.Stderr = os.Stderr
if err := cmd_exec.Run(); err != nil {
fmt.Println("Apx Error: ", err)
return err
}
}
return nil
}
type apxSubs struct {
Name string `json:"name"`
}

57
debian/changelog vendored
View File

@ -1,60 +1,3 @@
pikman (1.25.3.0.1-101pika1) pika; urgency=low
* Update to upgrade
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.2.0.1-101pika1) pika; urgency=low
* Nala is gone
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.1.0.1-101pika1) pika; urgency=low
* Update to PikaOS 4
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.1.0.1-100pika1) pikauwu; urgency=low
* Nala is back
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.0.0.3-100pika1) pikauwu; urgency=low
* Update to PikaOS 3
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.25.0.0.3-99pika2.lunar) lunar; urgency=low
* APX container init if needed
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.24.0.0.3-99pika2.lunar) lunar; urgency=low
* Nala -> apt until nala-rs is out
* Fix bug in upgrades
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.23.6.5.1-99pika2.lunar) lunar; urgency=low
* Add upgrades with --json flag
* Big refactor, code is nicer now
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.23.2.17.1-99pika2.lunar) lunar; urgency=low
* Update.
-- Ward Nakchbandi <hotrod.master@hotmail.com> Sat, 10 Dec 2022 13:48:00 +0300
pikman (1.23.2.17.1-99pika2) kinetic; urgency=low pikman (1.23.2.17.1-99pika2) kinetic; urgency=low
* Update. * Update.

5
debian/control vendored
View File

@ -16,9 +16,4 @@ Depends: ${misc:Depends},
flatpak, flatpak,
nala, nala,
apx, apx,
pika-apx-configs,
vanilla-apx-gui,
Conflicts: apx-subsystem-settings
Provides: apx-subsystem-settings
Replaces: apx-subsystem-settings
Description: One package manager to rule them all Description: One package manager to rule them all

View File

@ -1 +1 @@
3.0 (quilt) 3.0 (native)

4
debian/upstream/metadata vendored Normal file
View File

@ -0,0 +1,4 @@
Bug-Database: https://github.com/PikaOS-Linux/pikman/issues
Bug-Submit: https://github.com/PikaOS-Linux/pikman/issues/new
Repository: https://github.com/PikaOS-Linux/pikman.git
Repository-Browse: https://github.com/PikaOS-Linux/pikman

2
debian/watch vendored Normal file
View File

@ -0,0 +1,2 @@
version=4
https://github.com/PikaOS-Linux/pikman/tags (?:.*?/)?v?@ANY_VERSION@@ARCHIVE_EXT@

View File

@ -2,24 +2,20 @@ package fedora
var PackageManager = "apx" var PackageManager = "apx"
var ContainerSubsystem = "pikman-fedora-workstation"
var ApxSubsystem = "fedora-workstation"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "pikman-fedora-workstation autoremove", "autoremove": "--dnf autoremove",
"clean": "pikman-fedora-workstation clean", "clean": "--dnf clean",
"export": "pikman-fedora-workstation export", "export": "--dnf export",
"init": "subsystems new -n pikman-fedora-workstation -s fedora-workstation", "init": "--dnf init",
"install": "pikman-fedora-workstation install", "install": "--dnf install",
"list": "pikman-fedora-workstation list", "list": "--dnf list",
"purge": "pikman-fedora-workstation purge", "log": "--dnf log",
"run": "pikman-fedora-workstation run", "purge": "--dnf purge",
"remove": "pikman-fedora-workstation remove", "run": "--dnf run",
"enter": "pikman-fedora-workstation enter", "remove": "--dnf remove",
"search": "pikman-fedora-workstation search", "enter": "--dnf enter",
"show": "pikman-fedora-workstation show", "search": "--dnf search",
"update": "pikman-fedora-workstation update", "show": "--dnf show",
"upgrade": "pikman-fedora-workstation upgrade", "update": "--dnf update",
"unexport": "pikman-fedora-workstation unexport", "upgrade": "--dnf upgrade",
} }

69
loader/loader.go Normal file
View File

@ -0,0 +1,69 @@
package loader
import (
"fmt"
"os"
"os/exec"
"pikman/alpine"
"pikman/arch"
"pikman/fedora"
"pikman/flatpak"
"pikman/types"
"pikman/ubuntu"
"strings"
)
var commandsMap = map[types.OSType]map[string]string{
types.Ubuntu: ubuntu.Commands,
types.Arch: arch.Commands,
types.Fedora: fedora.Commands,
types.Alpine: alpine.Commands,
types.Flatpak: flatpak.Commands,
}
var packageManagerMap = map[types.OSType]string{
types.Ubuntu: ubuntu.PackageManager,
types.Arch: arch.PackageManager,
types.Fedora: fedora.PackageManager,
types.Alpine: alpine.PackageManager,
types.Flatpak: flatpak.PackageManager,
}
func ProcessCommand(command string, osType types.OSType, containerName string, packageName []string, upgradableFlag bool, installedFlag bool) error {
var err error
if osType != types.Ubuntu && osType != types.Flatpak && containerName != "" {
packageName = append([]string{"--name " + containerName}, packageName...)
}
if osType == types.Ubuntu && upgradableFlag {
packageName = append([]string{"--upgradable"}, packageName...)
}
if osType == types.Ubuntu && installedFlag {
packageName = append([]string{"--installed"}, packageName...)
}
commandToExecute, err := getCommand(command, osType, packageName)
cmd := exec.Command("/bin/sh", "-c", commandToExecute)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
err = cmd.Run()
if err != nil {
return err
}
return nil
}
func getCommand(command string, osType types.OSType, packageName []string) (string, error) {
commandMap := commandsMap[osType]
cmd, ok := commandMap[command]
if ok {
return fmt.Sprintf("%s %s %s", packageManagerMap[osType], cmd, strings.Join(packageName, " ")), nil
}
return "", fmt.Errorf("%s: is not a valid command for this distro", command)
}

View File

@ -1,9 +1,8 @@
package command package loader
import ( import (
"testing"
"pikman/types" "pikman/types"
"testing"
) )
func Test_getCommand(t *testing.T) { func Test_getCommand(t *testing.T) {
@ -35,7 +34,7 @@ func Test_getCommand(t *testing.T) {
osType: types.Arch, osType: types.Arch,
packageName: []string{"testPackage"}, packageName: []string{"testPackage"},
}, },
want: "apx pikman-arch-linux install testPackage", want: "apx --aur install testPackage",
wantErr: false, wantErr: false,
}, },
{ {
@ -45,7 +44,7 @@ func Test_getCommand(t *testing.T) {
osType: types.Arch, osType: types.Arch,
packageName: []string{"--name testName", "testPackage"}, packageName: []string{"--name testName", "testPackage"},
}, },
want: "apx pikman-arch-linux install --name testName testPackage", want: "apx --aur install --name testName testPackage",
wantErr: false, wantErr: false,
}, },
{ {
@ -61,12 +60,7 @@ func Test_getCommand(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
command := &Command{ got, err := getCommand(tt.args.command, tt.args.osType, tt.args.packageName)
Command: tt.args.command,
OsType: tt.args.osType,
PackageName: tt.args.packageName,
}
got, err := command.getCommand()
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("getCommand() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("getCommand() error = %v, wantErr %v", err, tt.wantErr)
return return

168
main.go
View File

@ -3,27 +3,22 @@ package main
import ( import (
"log" "log"
"os" "os"
"pikman/loader"
"pikman/command"
"pikman/types" "pikman/types"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
func main() { func main() {
if os.Getuid() == 0 { if os.Getuid() == 0 {
log.Fatalf("Error: Do not run pikman as root") log.Fatalf("Error: Do not run pikman as root")
} }
cmd := &command.Command{ osType := types.Ubuntu
OsType: types.Ubuntu, containerName := ""
ContainerName: "", upgradableFlag := false
IsUpgradable: false, installedFlag := false
IsJSON: false,
IsInstalled: false,
PackageName: make([]string, 0),
}
cli.VersionFlag = &cli.BoolFlag{ cli.VersionFlag = &cli.BoolFlag{
Name: "version", Name: "version",
Aliases: []string{"v"}, Aliases: []string{"v"},
@ -33,7 +28,7 @@ func main() {
app := &cli.App{ app := &cli.App{
Name: "pikman", Name: "pikman",
Usage: "One package manager to rule them all", Usage: "One package manager to rule them all",
Version: "v1.23.6.5.2", Version: "v1.23.2.17.0",
EnableBashCompletion: true, EnableBashCompletion: true,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
@ -42,7 +37,7 @@ func main() {
Usage: "Install Arch packages (including from the AUR)", Usage: "Install Arch packages (including from the AUR)",
Action: func(cCtx *cli.Context, b bool) error { Action: func(cCtx *cli.Context, b bool) error {
if b { if b {
cmd.OsType = types.Arch osType = types.Arch
} }
return nil return nil
}, },
@ -53,7 +48,7 @@ func main() {
Usage: "Install Fedora packages", Usage: "Install Fedora packages",
Action: func(cCtx *cli.Context, b bool) error { Action: func(cCtx *cli.Context, b bool) error {
if b { if b {
cmd.OsType = types.Fedora osType = types.Fedora
} }
return nil return nil
}, },
@ -64,7 +59,7 @@ func main() {
Usage: "Install Alpine packages", Usage: "Install Alpine packages",
Action: func(cCtx *cli.Context, b bool) error { Action: func(cCtx *cli.Context, b bool) error {
if b { if b {
cmd.OsType = types.Alpine osType = types.Alpine
} }
return nil return nil
}, },
@ -75,7 +70,7 @@ func main() {
Usage: "Install Flatpak packages", Usage: "Install Flatpak packages",
Action: func(cCtx *cli.Context, b bool) error { Action: func(cCtx *cli.Context, b bool) error {
if b { if b {
cmd.OsType = types.Flatpak osType = types.Flatpak
} }
return nil return nil
}, },
@ -83,41 +78,53 @@ func main() {
&cli.StringFlag{ &cli.StringFlag{
Name: "name", Name: "name",
Usage: "Name of the managed container", Usage: "Name of the managed container",
Destination: &cmd.ContainerName, Destination: &containerName,
}, },
}, },
Commands: []*cli.Command{ Commands: []*cli.Command{
{ {
Name: "autoremove", Name: "autoremove",
Usage: "Remove all unused packages", Usage: "Remove all unused packages",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "clean", Name: "clean",
Aliases: []string{"cl"}, Aliases: []string{"cl"},
Usage: "Clean the package manager cache", Usage: "Clean the package manager cache",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "enter", Name: "enter",
Usage: "Enter the container instance for select package manager", Usage: "Enter the container instance for select package manager",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "export", Name: "export",
Usage: "Export/Recreate a program's desktop entry from the container", Usage: "Export/Recreate a program's desktop entry from the container",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "init", Name: "init",
Usage: "Initialize a managed container", Usage: "Initialize a managed container",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "install", Name: "install",
Aliases: []string{"i"}, Aliases: []string{"i"},
Usage: "Install the specified package(s)", Usage: "Install the specified package(s)",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "list", Name: "list",
@ -127,74 +134,83 @@ func main() {
&cli.BoolFlag{ &cli.BoolFlag{
Name: "upgradable", Name: "upgradable",
Usage: "Used by list to check upgradable packages", Usage: "Used by list to check upgradable packages",
Destination: &cmd.IsUpgradable, Destination: &upgradableFlag,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "installed", Name: "installed",
Usage: "Used by list to check installed packages", Usage: "Used by list to check installed packages",
Destination: &cmd.IsInstalled, Destination: &installedFlag,
}, },
}, },
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), upgradableFlag, installedFlag)
},
}, },
{ {
Name: "log", Name: "log",
Usage: "Show package manager logs", Usage: "Show package manager logs",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "purge", Name: "purge",
Usage: "Fully purge a package", Usage: "Fully purge a package",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "run", Name: "run",
Usage: "Run a command inside a managed container", Usage: "Run a command inside a managed container",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "remove", Name: "remove",
Aliases: []string{"r"}, Aliases: []string{"r"},
Usage: "Remove an installed package", Usage: "Remove an installed package",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
}, },
{ {
Name: "search", Name: "search",
Aliases: []string{"s"}, Aliases: []string{"s"},
Usage: "Search for a package", Usage: "Search for a package",
Action: cmd.Process, Action: func(cCtx *cli.Context) error {
}, return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
{ },
Name: "show", },
Usage: "Show details for a package", {
Action: cmd.Process, Name: "show",
}, Usage: "Show details for a package",
{ Action: func(cCtx *cli.Context) error {
Name: "unexport", return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
Usage: "Unexport/Remove a program's desktop entry", },
Action: cmd.Process, },
}, {
{ Name: "unexport",
Name: "update", Usage: "Unexport/Remove a program's desktop entry",
Usage: "Update the list of available packages", Action: func(cCtx *cli.Context) error {
Action: cmd.Process, return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
}, },
{ },
Name: "upgrade", {
Usage: "Upgrade the system by installing/upgrading available packages", Name: "update",
Action: cmd.Process, Usage: "Update the list of available packages",
}, Action: func(cCtx *cli.Context) error {
{ return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
Name: "upgrades", },
Usage: "List the available upgrades", },
Flags: []cli.Flag{ {
&cli.BoolFlag{ Name: "upgrade",
Name: "json", Usage: "Upgrade the system by installing/upgrading available packages",
Usage: "Output in JSON", Action: func(cCtx *cli.Context) error {
Destination: &cmd.IsJSON, cCtx.Args().Tail()
}, return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
}, },
Action: cmd.Process,
}, },
}, },
} }

23
main.sh
View File

@ -1,26 +1,25 @@
#! /bin/bash DEBIAN_FRONTEND=noninteractive
set -e
VERSION="1.25.3.0.1"
source ./pika-build-config.sh
echo "$PIKA_BUILD_ARCH" > pika-build-arch
# Add dependent repositories
wget -q -O - https://ppa.pika-os.com/key.gpg | sudo apt-key add -
add-apt-repository https://ppa.pika-os.com
add-apt-repository ppa:pikaos/pika
add-apt-repository ppa:kubuntu-ppa/backports
# Clone Upstream # Clone Upstream
mkdir -p ./pikman mkdir -p ./pikman
cp -rvf ./* ./pikman || true cp -rvf ./* ./pikman || echo
cd ./pikman cd ./pikman
# Get build deps # Get build deps
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
apt-get build-dep ./ -y apt-get build-dep ./ -y
# Build package # Build package
LOGNAME=root dh_make --createorig -y -l -p pikman_"$VERSION" || echo "dh-make: Ignoring Last Error" dpkg-buildpackage
dpkg-buildpackage --no-sign
# Move the debs to output # Move the debs to output
cd ../ cd ../
mkdir -p ./output mkdir -p ./output
mv ./*.deb ./output/ mv ./*.deb ./output/

View File

@ -1,10 +0,0 @@
#! /bin/bash
export PIKA_BUILD_ARCH="amd64-v3"
export DEBIAN_FRONTEND="noninteractive"
export DEB_BUILD_MAINT_OPTIONS="optimize=+lto -march=x86-64-v3 -O3 -flto=auto"
export DEB_CFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto=auto"
export DEB_CPPFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto=auto"
export DEB_CXXFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto=auto"
export DEB_LDFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto=auto"
export DEB_BUILD_OPTIONS="nocheck notest terse"
export DPKG_GENSYMBOLS_CHECK_LEVEL=0

View File

@ -1,5 +0,0 @@
#! /bin/bash
export PIKA_BUILD_ARCH="i386"
export DEBIAN_FRONTEND="noninteractive"
export DEB_BUILD_OPTIONS="nocheck notest terse"
export DPKG_GENSYMBOLS_CHECK_LEVEL=0

View File

@ -1,2 +1,11 @@
# send debs to server # Sign the packages
rsync -azP --include './' --include '*.deb' --exclude '*' ./output/ ferreo@direct.pika-os.com:/srv/www/cockatiel-incoming/ dpkg-sig --sign builder ./output/*.deb
# Pull down existing ppa repo db files etc
rsync -azP --exclude '*.deb' ferreo@direct.pika-os.com:/srv/www/pikappa/ ./output/repo
# Add the new package to the repo
reprepro -V --basedir ./output/repo/ includedeb kinetic ./output/*.deb
# Push the updated ppa repo to the server
rsync -azP ./output/repo/ ferreo@direct.pika-os.com:/srv/www/pikappa/

View File

@ -1,6 +1,6 @@
package ubuntu package ubuntu
var PackageManager = "sudo -S apt" var PackageManager = "sudo -S nala"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "autoremove", "autoremove": "autoremove",
@ -12,5 +12,5 @@ var Commands = map[string]string{
"search": "search", "search": "search",
"show": "show", "show": "show",
"update": "update", "update": "update",
"upgrade": "update && sudo -S apt dist-upgrade", "upgrade": "upgrade",
} }

View File

@ -1,105 +0,0 @@
package updates
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"os/exec"
"regexp"
"strings"
)
func GetUbuntuUpdates(isJSON bool) error {
cmd := exec.Command("apt", "list", "--upgradable")
out, err := cmd.Output()
if err != nil {
return fmt.Errorf("running apt list: %s", err)
}
re := regexp.MustCompile(`^([^ ]+) ([^ ]+) ([^ ]+)( \[upgradable from: [^\[\]]*\])?`)
scanner := bufio.NewScanner(bytes.NewReader(out))
output := make([]aptPackage, 0)
for scanner.Scan() {
matches := re.FindAllStringSubmatch(scanner.Text(), -1)
if len(matches) == 0 {
continue
}
name := strings.Split(matches[0][1], "/")[0]
if isJSON {
pack := &aptPackage{
Name: name,
Version: matches[0][2],
Architecture: matches[0][3],
}
output = append(output, *pack)
} else {
println(name)
}
}
if isJSON {
jsonout, err := json.Marshal(output)
if err != nil {
return fmt.Errorf("formatting apt list output: %s", err)
}
println(string(jsonout))
}
return nil
}
func GetFlatpakUpdates(isJSON bool) error {
cmd := exec.Command("flatpak", "remote-ls", "--updates")
out, err := cmd.Output()
if err != nil {
return fmt.Errorf("running flatpak list: %s", err)
}
re := regexp.MustCompile(`(?-s)(\S+)`)
scanner := bufio.NewScanner(bytes.NewReader(out))
output := make([]flatPackage, 0)
for scanner.Scan() {
matches := re.FindAllString(scanner.Text(), -1)
if len(matches) == 0 {
continue
}
if isJSON {
pack := &flatPackage{
Name: matches[0],
ApplicationID: matches[1],
Branch: matches[2],
Arch: matches[3],
}
output = append(output, *pack)
} else {
println(matches[0])
}
}
if isJSON {
jsonout, err := json.Marshal(output)
if err != nil {
return fmt.Errorf("formatting apt list output: %s", err)
}
println(string(jsonout))
}
return nil
}
type aptPackage struct {
Name string
Version string
Architecture string
}
type flatPackage struct {
Name string
ApplicationID string
Branch string
Arch string
}