diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8d34d97 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: PikaOS Package Release + +on: + workflow_dispatch + +jobs: + build: + runs-on: self-hosted + container: + image: ghcr.io/pikaos-linux/pika-package-container:latest + volumes: + - /proc:/proc + options: --privileged -it + + steps: + - uses: actions/checkout@v3 + + - 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: chmod +x ./main.sh && ./main.sh + + - name: Release Package + run: chmod +x ./release.sh && ./release.sh + + - name: Purge cache + uses: strrife/cloudflare-chunked-purge-action@master + env: + # Zone is required by both authentication methods + CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }} + + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} + PURGE_URLS: ${{ vars.PURGE_URLS }} + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index d99db77..26ead2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -584,6 +584,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + [[package]] name = "malloc_buf" version = "0.0.6" @@ -696,6 +702,7 @@ dependencies = [ "os_pipe", "regex", "user", + "users", ] [[package]] @@ -1004,6 +1011,16 @@ dependencies = [ "winapi 0.1.23", ] +[[package]] +name = "users" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" +dependencies = [ + "libc", + "log", +] + [[package]] name = "version-compare" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 262de08..70e2b89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ gettext-rs = { version = "0.7", features = ["gettext-system"] } duct = "0.13.7" os_pipe = "1.1.5" user = "0.1.1" +users = "0.11.0" diff --git a/Makefile b/Makefile index 609e720..885fc1b 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ install: cp -vf target/release/pika-first-setup-gtk4 $(DESTDIR)/usr/bin/ chmod 755 $(DESTDIR)/usr/bin/pika-first-setup-gtk4 mkdir -p $(DESTDIR)/usr/share/glib-2.0/schemas/ + mkdir -p $(DESTDIR)/usr/lib/pika/pika-first-setup-gtk4/scripts/ + cp -rvf data/scripts/*.sh $(DESTDIR)/usr/lib/pika/pika-first-setup-gtk4/scripts/ + chmod 755 $(DESTDIR)/usr/lib/pika/pika-first-setup-gtk4/scripts/*.sh cp data/com.github.pikaos-linux.pikafirstsetup.gschema.xml $(DESTDIR)/usr/share/glib-2.0/schemas/ mkdir -p $(DESTDIR)/usr/share/applications cp -vf data/com.github.pikaos-linux.pikafirstsetup.desktop $(DESTDIR)/usr/share/applications/ diff --git a/data/com.github.pikaos-linux.pikafirstsetup.desktop b/data/com.github.pikaos-linux.pikafirstsetup.desktop index 5409c03..cd3bbc9 100644 --- a/data/com.github.pikaos-linux.pikafirstsetup.desktop +++ b/data/com.github.pikaos-linux.pikafirstsetup.desktop @@ -1,10 +1,11 @@ [Desktop Entry] -Name=PikaOS First Setup -Name[en_US]=PikaOS First Setup -Exec=pika-first-setup -Icon=com.github.pikaos-linux.pikafirstsetup -Terminal=false Type=Application -Encoding=UTF-8 +Name=PikaOS Initial User Setup +Exec=pika-first-setup-gtk4 +Hidden=false NoDisplay=true -StartupNotify=true +Icon=com.github.pikaos-linux.pikafirstsetup +X-GNOME-Autostart-enabled=true +X-KDE-AutostartScript=true +Categories=GNOME;GTK;Utility; +Keywords=Gnome;GTK \ No newline at end of file diff --git a/data/com.github.pikaos-linux.pikafirstsetup.svg b/data/com.github.pikaos-linux.pikafirstsetup.svg new file mode 100644 index 0000000..2fb5c74 --- /dev/null +++ b/data/com.github.pikaos-linux.pikafirstsetup.svg @@ -0,0 +1,832 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/scripts/pika-sudo.sh b/data/scripts/pika-sudo.sh new file mode 100755 index 0000000..7778840 --- /dev/null +++ b/data/scripts/pika-sudo.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +echo "pikaos" | sudo -S "$@" \ No newline at end of file diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f7618a2 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pika-first-setup (1.0.0-100pika1) pikauwu; urgency=low + + * First release + + -- Ward Nakchbandi Thu, 20 Sep 2022 22:01:00 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..aa97a26 --- /dev/null +++ b/debian/control @@ -0,0 +1,18 @@ +Source: pika-first-setup +Section: utils +Priority: optional +Maintainer: International Arms dealers +Build-Depends: build-essential, + debhelper, + cargo, + libadwaita-1-dev, + libgtk-4-dev, + desktop-file-utils, + make, + libvte-2.91-gtk4-dev +Rules-Requires-Root: no + +Package: pika-first-setup-gtk4 +Architecture: any +Depends: ${shlibs:Depends} +Description: A frontend in GTK 4 and Libadwaita for initial user setup in pika. diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..0e24131 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,10 @@ +#!/bin/sh + + +set -e + update-mime-database /usr/share/mime + update-desktop-database + glib-compile-schemas /usr/share/glib-2.0/schemas + + + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/main.sh b/main.sh new file mode 100644 index 0000000..acdea11 --- /dev/null +++ b/main.sh @@ -0,0 +1,15 @@ +# Clone Upstream +mkdir -p ./pika-first-setup +rsync -av --progress ./* ./pika-first-setup --exclude ./pika-first-setup +cd ./pika-first-setup + +# Get build deps +apt-get build-dep ./ -y + +# Build package +dpkg-buildpackage --no-sign + +# Move the debs to output +cd ../ +mkdir -p ./output +mv ./*.deb ./output/ diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..1575255 --- /dev/null +++ b/release.sh @@ -0,0 +1,8 @@ +# send debs to server +rsync -azP --include './' --include '*.deb' --exclude '*' ./output/ ferreo@direct.pika-os.com:/srv/www/incoming/ + +# add debs to repo +ssh ferreo@direct.pika-os.com 'aptly repo add -force-replace -remove-files pikauwu-main /srv/www/incoming/' + +# publish the repo +ssh ferreo@direct.pika-os.com 'aptly publish update -batch -skip-contents -force-overwrite pikauwu filesystem:pikarepo:' \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 6c0bbe3..ef6a27c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,3 +4,4 @@ pub const LOCALEDIR: &str = "/usr/share/locale"; //pub const PKGDATADIR: &str = " /usr/share"; //pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); //pub const VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const DISTRO_ICON: &str = "pika-logo"; diff --git a/src/first_setup/codec_carousel/mod.rs b/src/first_setup/codec_carousel/mod.rs index d6404f4..b69ca71 100644 --- a/src/first_setup/codec_carousel/mod.rs +++ b/src/first_setup/codec_carousel/mod.rs @@ -23,7 +23,7 @@ use std::io::BufReader; const CODEC_INSTALL_PROG: &str = " #! /bin/bash set -e -sudo apt update -y && sudo apt install pika-codecs-meta -y +/usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh apt update -y && /usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh apt install pika-codecs-meta -y "; fn codec_install( diff --git a/src/first_setup/final_carousel/mod.rs b/src/first_setup/final_carousel/mod.rs index eac141f..6aca39f 100644 --- a/src/first_setup/final_carousel/mod.rs +++ b/src/first_setup/final_carousel/mod.rs @@ -46,6 +46,6 @@ pub fn final_carousel(first_setup_carousel: &adw::Carousel) { first_setup_carousel.append(&first_setup_final_box); first_setup_start_button.connect_clicked( move |_| { - let _ = cmd!("sudo", "bash", "-c", REBOOT_PROG).read(); + let _ = cmd!("/usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh", "bash", "-c", REBOOT_PROG).read(); }); } diff --git a/src/first_setup/gameutils_carousel/mod.rs b/src/first_setup/gameutils_carousel/mod.rs index d0859a3..817025a 100644 --- a/src/first_setup/gameutils_carousel/mod.rs +++ b/src/first_setup/gameutils_carousel/mod.rs @@ -23,7 +23,7 @@ use std::io::BufReader; const GAMEUTILS_INSTALL_PROG: &str = " #! /bin/bash set -e -sudo apt update -y && sudo apt install pika-gameutils-meta -y +/usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh apt update -y && /usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh apt install pika-gameutils-meta -y "; fn gameutils_install( diff --git a/src/first_setup/initial_carousel/mod.rs b/src/first_setup/initial_carousel/mod.rs index 7559ee4..d0b0256 100644 --- a/src/first_setup/initial_carousel/mod.rs +++ b/src/first_setup/initial_carousel/mod.rs @@ -7,6 +7,7 @@ use glib::*; use gtk::*; use gettextrs::gettext; +use crate::config::{DISTRO_ICON}; pub fn initial_carousel(first_setup_carousel: &adw::Carousel) { let first_setup_initial_box = gtk::Box::builder() @@ -19,7 +20,7 @@ pub fn initial_carousel(first_setup_carousel: &adw::Carousel) { .build(); let first_setup_initial_box_text = adw::StatusPage::builder() - .icon_name("debian-swirl") + .icon_name(DISTRO_ICON) .title(gettext("first_setup_initial_box_text_title")) .description(gettext("first_setup_initial_box_text_description")) .build(); diff --git a/src/first_setup/update_carousel/mod.rs b/src/first_setup/update_carousel/mod.rs index 033a111..fc6cdff 100644 --- a/src/first_setup/update_carousel/mod.rs +++ b/src/first_setup/update_carousel/mod.rs @@ -23,7 +23,7 @@ use std::io::BufReader; const APT_UPDATE_PROG: &str = " #! /bin/bash set -e -sudo apt update -y && sudo apt full-upgrade -y +/usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh apt update -y && /usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh apt full-upgrade -y "; fn apt_update( diff --git a/src/first_setup/user_carousel/mod.rs b/src/first_setup/user_carousel/mod.rs index fafd275..9bba886 100644 --- a/src/first_setup/user_carousel/mod.rs +++ b/src/first_setup/user_carousel/mod.rs @@ -21,12 +21,12 @@ USERNAME="$0" PASSWORD="$1" FULLNAME="$2" adduser --quiet --disabled-password --shell /bin/bash --gecos "${FULLNAME}" "${USERNAME}" -echo "${USERNAME}":"${PASSWORD}" | sudo chpasswd -usermod -a -G sudo "${USERNAME}" +echo "${USERNAME}":"${PASSWORD}" | /usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh chpasswd +usermod -a -G /usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh "${USERNAME}" mkdir -p /home/"${USERNAME}" cp -rvf /etc/skel/.* /home/"${USERNAME}"/ || true chown -R "${USERNAME}":"${USERNAME}" /home/"${USERNAME}" -usermod -a -G adm,cdrom,sudo,render,dip,video,plugdev,input,render,lpadmin "${USERNAME}" +usermod -a -G adm,cdrom,/usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh,render,dip,video,plugdev,input,render,lpadmin "${USERNAME}" rm -rf /etc/sddm.conf.d/zautologin.conf || true "###; @@ -281,7 +281,7 @@ pub fn user_carousel(first_setup_carousel: &adw::Carousel) { })); user_next_button.connect_clicked(clone!(@weak first_setup_carousel, @weak user_info_username, @weak user_info_password, @weak user_info_full_name => move |_| { - let _ = cmd!("sudo", "bash", "-c", USER_CREATE_PROG, &user_info_username.text(), &user_info_password.text(), &user_info_full_name.text()).read(); + let _ = cmd!("/usr/lib/pika/pika-first-setup-gtk4/scripts/pika-sudo.sh", "bash", "-c", USER_CREATE_PROG, &user_info_username.text(), &user_info_password.text(), &user_info_full_name.text()).read(); first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(3), true); })); } diff --git a/src/main.rs b/src/main.rs index b5520f6..fea0ffe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use gdk::Display; use gtk::*; use gettextrs::{gettext, LocaleCategory}; +use users::*; use config::{GETTEXT_PACKAGE, LOCALEDIR, APP_ID}; // application crates @@ -47,5 +48,11 @@ fn main() { app.connect_activate(build_ui); }); - application.run(); + if get_current_username().unwrap() == "pikaos" { + application.run(); + } else { + println!("Error: This program can only be run via pikaos user"); + std::process::exit(1) + } + }