Merge branch 'fpkg-v2' into 'master'

[FeatureBranch] FPKGv2

See merge request FG42/FG42!19
This commit is contained in:
Sameer Rahmani 2020-03-16 21:51:43 +00:00
commit 2490cf876e
6 changed files with 132 additions and 56 deletions

3
.gitignore vendored
View File

@ -22,4 +22,5 @@ nohup.out
lib/**/*.elc
*.elc
tmp/
test-runner/
test-runner/
.fpkg/

24
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,24 @@
stages:
- build
build:
image: debian:stable-slim
stage: build
before_script:
- apt update && apt install -y make wget git emacs sudo
- git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ && cd ~/.fg42/ && make install &&
script:
- cd ~/.fg42/ && fg42 -nw --script build.el
build-package:
extends: build
script:
- cd ~/.fg42/ && fg42 -nw --script build.el
- cd && tar zcf fg42.$CI_COMMIT_TAG.tar.gz ~/.fg42/
artifacts:
when: on_success
paths:
- ~/fg42.$CI_COMMIT_TAG.tar.gz
only:
- tags
- master

View File

@ -1,6 +1,22 @@
.PHONY: update
update:
@git remote set-url origin git://gitlab.com/FG42/FG42.git
@git pull origin master
.PHONY: install-cli
install-ci:
@echo "Downloading and installing fonts..."
@mkdir -p ~/.fonts
@wget "https://github.com/FG42/fonts/archive/0.1.0.tar.gz" -O ~/.fonts/fg42.tar.gz
@tar zxf ~/.fonts/fg42.tar.gz -C ~/.fonts --strip 1
@cp ./config/fg42.user.el ${HOME}/.fg42.el
@echo "Creating the link..."
@echo "#! /bin/sh" > ./fg42
@echo "export FG42_HOME=$(shell pwd)" >> ./fg42
@echo 'emacs --name FG42 --no-site-file --no-site-lisp --no-splash --title FG42 -l $$FG42_HOME/fg42-config.el "$$@"' >> ./fg42
@chmod +x ./fg42
.PHONY: install
install:
@echo "Downloading and installing fonts..."
@mkdir -p ~/.fonts
@ -21,11 +37,8 @@ install:
@echo "------------------------------------------------------------------------------------"
@echo "Make sure to install external dependencies of FG42. For more info checkout README.md"
@echo "Enjoy the bless of GNU/Emacs and FG42 :)"
.PHONY: install-fonts
install-fonts:
@mkdir -p ~/.fonts/
@cp -rv ./share/fonts/vazir/* ~/.fonts/
build-image:
docker build . -t fg42:1 --build-arg emacs_version=26.3
clean-image:
docker rmi fg42:1

47
build.el Normal file
View File

@ -0,0 +1,47 @@
;;; build --- build script for FG42
;;
;; Copyright (C) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; Keywords: lisp fg42 IDE package manager
;; Version: 1.0.0
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;; Code:
(add-to-list 'load-path (concat (getenv "HOME") ".fg42/lib"))
(defvar bootstrap-version nil
"Bootstrap version of straight. This var is used in straight's installer.")
(defun fpkg-initialize ()
"Initilize the straight.e package manager and setup necessary hooks."
(let ((bootstrap-file "~/.fg42/.fpkg/straight/repos/straight.el/bootstrap.el")
(bootstrap-version 5))
(setq straight-base-dir "~/.fg42/.fpkg/")
(if (not (file-exists-p bootstrap-file))
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp))
(load bootstrap-file nil 'nomessage))))
(fpkg-initialize)
(provide 'build)
;;; build.el ends here

View File

@ -30,6 +30,8 @@
(defvar fg42-tmp (concat fg42-home "/tmp"))
(require 'fpkg)
(fpkg-initialize-once)
(require 'fg42/base)
(require 'fg42/splash)
(require 'fg42/race)

View File

@ -1,7 +1,7 @@
;;; fpkg --- a simple package manager for FG42 -*- lexical-binding: t; -*-
;; Copyright (C) 2010-2019 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Copyright (C) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; Keywords: lisp fg42 IDE package manager
;; Version: 1.0.0
@ -36,61 +36,50 @@
(path nil)
(source 'elpa))
(defvar bootstrap-version nil
"Bootstrap version of straight. This var is used in straight's installer.")
(defvar fpkg-packages-path
(expand-file-name ".fpkg/" fg42-home)
"The path to the directory which FPKG will use to store that packages.")
(defvar fpkg-initilized-p nil
"A boolean flag that indicates whether FPKG is initialized or not.")
(defvar required-packages (make-hash-table)
"A hash of `fg42-package structure representing required packages.")
;; Functions ----------------------------------
(defun all-dependencies-installed? ()
"Return t if all the dependencies installed."
(let ((result t))
(dolist (pkg (hash-table-keys required-packages))
(when (not (package-installed-p pkg))
(message "'%s' package is not installed" pkg)
(setq result nil)))
result))
(defun install--package (pkg)
"Intall a package via its propreate source."
(let* ((source (fpkg-dependency-source pkg))
(func-name (concat "install-package-via-" (symbol-name source)))
(install-func
(symbol-function
(intern func-name))))
(funcall install-func pkg)))
(defun fpkg-initialize ()
"Initilize the package.el and related stuff to be used in FG42"
(let ((packages (hash-table-values required-packages)))
"Initilize the straight.e package manager and setup necessary hooks."
(let ((bootstrap-file (concat fpkg-packages-path
"straight/repos/straight.el/bootstrap.el"))
(bootstrap-version 5))
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
;; Initialize package.el
(package-initialize)
(setq url-http-attempt-keepalives nil)
(unless (all-dependencies-installed?)
;; check for new packages (package versions)
(message "%s" "Refreshing package database...")
(package-refresh-contents)
;; install the missing packages
(dolist (pkg packages)
(when (not (package-installed-p (fpkg-dependency-name pkg)))
(install--package pkg))))))
(make-directory fpkg-packages-path t)
(setq straight-base-dir fpkg-packages-path)
(if (not (file-exists-p bootstrap-file))
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp))
(load bootstrap-file nil 'nomessage))))
(defun fpkg-initialize-once ()
"Initilize FPKG only once."
(when (not fpkg-initilized-p)
(fpkg-initialize)))
(defun depends-on (pkgname)
"Install the given PKGNAME if it isn't installed."
(straight-use-package pkgname))
(defun depends-on (pkgname &rest args)
"Global function to specify a single dependency"
(let ((pkg (apply 'make-fpkg-dependency :name pkgname args)))
(puthash pkgname pkg required-packages)))
(message "FPKG has been initialized.")
(provide 'fpkg)
;;; fpkg.el ends here