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:
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

View File

@ -4,7 +4,7 @@
pikman [global options] command [command options] [arguments...]
## VERSION:
v1.23.6.5.2
v1.23.2.17.0
## COMMANDS:
@ -24,7 +24,6 @@ v1.23.6.5.2
- **unexport** - Unexport/Remove a program's desktop entry
- **update** - Update the list of 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
## GLOBAL OPTIONS:

View File

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

View File

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

5
debian/control vendored
View File

@ -16,9 +16,4 @@ Depends: ${misc:Depends},
flatpak,
nala,
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

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 ContainerSubsystem = "pikman-fedora-workstation"
var ApxSubsystem = "fedora-workstation"
var Commands = map[string]string{
"autoremove": "pikman-fedora-workstation autoremove",
"clean": "pikman-fedora-workstation clean",
"export": "pikman-fedora-workstation export",
"init": "subsystems new -n pikman-fedora-workstation -s fedora-workstation",
"install": "pikman-fedora-workstation install",
"list": "pikman-fedora-workstation list",
"purge": "pikman-fedora-workstation purge",
"run": "pikman-fedora-workstation run",
"remove": "pikman-fedora-workstation remove",
"enter": "pikman-fedora-workstation enter",
"search": "pikman-fedora-workstation search",
"show": "pikman-fedora-workstation show",
"update": "pikman-fedora-workstation update",
"upgrade": "pikman-fedora-workstation upgrade",
"unexport": "pikman-fedora-workstation unexport",
"autoremove": "--dnf autoremove",
"clean": "--dnf clean",
"export": "--dnf export",
"init": "--dnf init",
"install": "--dnf install",
"list": "--dnf list",
"log": "--dnf log",
"purge": "--dnf purge",
"run": "--dnf run",
"remove": "--dnf remove",
"enter": "--dnf enter",
"search": "--dnf search",
"show": "--dnf show",
"update": "--dnf update",
"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 (
"testing"
"pikman/types"
"testing"
)
func Test_getCommand(t *testing.T) {
@ -35,7 +34,7 @@ func Test_getCommand(t *testing.T) {
osType: types.Arch,
packageName: []string{"testPackage"},
},
want: "apx pikman-arch-linux install testPackage",
want: "apx --aur install testPackage",
wantErr: false,
},
{
@ -45,7 +44,7 @@ func Test_getCommand(t *testing.T) {
osType: types.Arch,
packageName: []string{"--name testName", "testPackage"},
},
want: "apx pikman-arch-linux install --name testName testPackage",
want: "apx --aur install --name testName testPackage",
wantErr: false,
},
{
@ -61,12 +60,7 @@ func Test_getCommand(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
command := &Command{
Command: tt.args.command,
OsType: tt.args.osType,
PackageName: tt.args.packageName,
}
got, err := command.getCommand()
got, err := getCommand(tt.args.command, tt.args.osType, tt.args.packageName)
if (err != nil) != tt.wantErr {
t.Errorf("getCommand() error = %v, wantErr %v", err, tt.wantErr)
return

168
main.go
View File

@ -3,27 +3,22 @@ package main
import (
"log"
"os"
"pikman/command"
"pikman/loader"
"pikman/types"
"github.com/urfave/cli/v2"
)
func main() {
if os.Getuid() == 0 {
log.Fatalf("Error: Do not run pikman as root")
}
cmd := &command.Command{
OsType: types.Ubuntu,
ContainerName: "",
IsUpgradable: false,
IsJSON: false,
IsInstalled: false,
PackageName: make([]string, 0),
}
osType := types.Ubuntu
containerName := ""
upgradableFlag := false
installedFlag := false
cli.VersionFlag = &cli.BoolFlag{
Name: "version",
Aliases: []string{"v"},
@ -33,7 +28,7 @@ func main() {
app := &cli.App{
Name: "pikman",
Usage: "One package manager to rule them all",
Version: "v1.23.6.5.2",
Version: "v1.23.2.17.0",
EnableBashCompletion: true,
Flags: []cli.Flag{
&cli.BoolFlag{
@ -42,7 +37,7 @@ func main() {
Usage: "Install Arch packages (including from the AUR)",
Action: func(cCtx *cli.Context, b bool) error {
if b {
cmd.OsType = types.Arch
osType = types.Arch
}
return nil
},
@ -53,7 +48,7 @@ func main() {
Usage: "Install Fedora packages",
Action: func(cCtx *cli.Context, b bool) error {
if b {
cmd.OsType = types.Fedora
osType = types.Fedora
}
return nil
},
@ -64,7 +59,7 @@ func main() {
Usage: "Install Alpine packages",
Action: func(cCtx *cli.Context, b bool) error {
if b {
cmd.OsType = types.Alpine
osType = types.Alpine
}
return nil
},
@ -75,7 +70,7 @@ func main() {
Usage: "Install Flatpak packages",
Action: func(cCtx *cli.Context, b bool) error {
if b {
cmd.OsType = types.Flatpak
osType = types.Flatpak
}
return nil
},
@ -83,41 +78,53 @@ func main() {
&cli.StringFlag{
Name: "name",
Usage: "Name of the managed container",
Destination: &cmd.ContainerName,
Destination: &containerName,
},
},
Commands: []*cli.Command{
{
Name: "autoremove",
Usage: "Remove all unused packages",
Action: cmd.Process,
Name: "autoremove",
Usage: "Remove all unused packages",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "clean",
Aliases: []string{"cl"},
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",
Usage: "Enter the container instance for select package manager",
Action: cmd.Process,
Name: "enter",
Usage: "Enter the container instance for select package manager",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "export",
Usage: "Export/Recreate a program's desktop entry from the container",
Action: cmd.Process,
Name: "export",
Usage: "Export/Recreate a program's desktop entry from the container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "init",
Usage: "Initialize a managed container",
Action: cmd.Process,
Name: "init",
Usage: "Initialize a managed container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "install",
Aliases: []string{"i"},
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",
@ -127,74 +134,83 @@ func main() {
&cli.BoolFlag{
Name: "upgradable",
Usage: "Used by list to check upgradable packages",
Destination: &cmd.IsUpgradable,
Destination: &upgradableFlag,
},
&cli.BoolFlag{
Name: "installed",
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",
Usage: "Show package manager logs",
Action: cmd.Process,
Name: "log",
Usage: "Show package manager logs",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "purge",
Usage: "Fully purge a package",
Action: cmd.Process,
Name: "purge",
Usage: "Fully purge a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "run",
Usage: "Run a command inside a managed container",
Action: cmd.Process,
Name: "run",
Usage: "Run a command inside a managed container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "remove",
Aliases: []string{"r"},
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",
Aliases: []string{"s"},
Usage: "Search for a package",
Action: cmd.Process,
},
{
Name: "show",
Usage: "Show details for a package",
Action: cmd.Process,
},
{
Name: "unexport",
Usage: "Unexport/Remove a program's desktop entry",
Action: cmd.Process,
},
{
Name: "update",
Usage: "Update the list of available packages",
Action: cmd.Process,
},
{
Name: "upgrade",
Usage: "Upgrade the system by installing/upgrading available packages",
Action: cmd.Process,
},
{
Name: "upgrades",
Usage: "List the available upgrades",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "json",
Usage: "Output in JSON",
Destination: &cmd.IsJSON,
},
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: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "unexport",
Usage: "Unexport/Remove a program's desktop entry",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false, false)
},
},
{
Name: "update",
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: "upgrade",
Usage: "Upgrade the system by installing/upgrading available packages",
Action: func(cCtx *cli.Context) error {
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
set -e
VERSION="1.25.3.0.1"
source ./pika-build-config.sh
echo "$PIKA_BUILD_ARCH" > pika-build-arch
DEBIAN_FRONTEND=noninteractive
# 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
mkdir -p ./pikman
cp -rvf ./* ./pikman || true
cp -rvf ./* ./pikman || echo
cd ./pikman
# 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
# Build package
LOGNAME=root dh_make --createorig -y -l -p pikman_"$VERSION" || echo "dh-make: Ignoring Last Error"
dpkg-buildpackage --no-sign
dpkg-buildpackage
# Move the debs to output
cd ../
mkdir -p ./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 -fuse-linker-plugin -falign-functions=32"
export DEB_CFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_CPPFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_CXXFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
export DEB_LDFLAGS_MAINT_APPEND="-march=x86-64-v3 -O3 -flto -fuse-linker-plugin -falign-functions=32"
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
rsync -azP --include './' --include '*.deb' --exclude '*' ./output/ ferreo@direct.pika-os.com:/srv/www/cockatiel-incoming/
# Sign the packages
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
var PackageManager = "sudo -S apt"
var PackageManager = "sudo -S nala"
var Commands = map[string]string{
"autoremove": "autoremove",
@ -12,5 +12,5 @@ var Commands = map[string]string{
"search": "search",
"show": "show",
"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
}