From 98fa76b0ba07da9e7e99117dd3aab7549647b858 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 15 Mar 2020 22:21:30 +0000 Subject: [PATCH] Straight installation funciton has been added Signed-off-by: Sameer Rahmani --- .gitignore | 3 ++- lib/fg42.el | 2 ++ lib/fpkg.el | 58 +++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index b1409d6..41255ae 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ nohup.out lib/**/*.elc *.elc tmp/ -test-runner/ \ No newline at end of file +test-runner/ +.fpkg/ \ No newline at end of file diff --git a/lib/fg42.el b/lib/fg42.el index 6e9ea25..d534305 100644 --- a/lib/fg42.el +++ b/lib/fg42.el @@ -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) diff --git a/lib/fpkg.el b/lib/fpkg.el index 5c4d8c6..0676f8b 100644 --- a/lib/fpkg.el +++ b/lib/fpkg.el @@ -1,7 +1,7 @@ ;;; fpkg --- a simple package manager for FG42 -*- lexical-binding: t; -*- - -;; Copyright (C) 2010-2019 Sameer Rahmani - +;; +;; Copyright (C) 2010-2012 Sameer Rahmani +;; ;; Author: Sameer Rahmani ;; Keywords: lisp fg42 IDE package manager ;; Version: 1.0.0 @@ -36,6 +36,18 @@ (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.") @@ -49,8 +61,9 @@ (setq result nil))) result)) + (defun install--package (pkg) - "Intall a package via its propreate source." + "Install a package via its propreate source." (let* ((source (fpkg-dependency-source pkg)) (func-name (concat "install-package-via-" (symbol-name source))) (install-func @@ -58,7 +71,8 @@ (intern func-name)))) (funcall install-func pkg))) -(defun fpkg-initialize () + +(defun fpkg-initialize-old () "Initilize the package.el and related stuff to be used in FG42" (let ((packages (hash-table-values required-packages))) @@ -86,11 +100,39 @@ (install--package pkg)))))) +(defun fpkg-initialize () + "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)) -(defun depends-on (pkgname &rest args) - "Global function to specify a single dependency" + (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-old (pkgname &rest args) + "Install the given PKGNAME if it isn't installed. Ignore ARGS for now." (let ((pkg (apply 'make-fpkg-dependency :name pkgname args))) (puthash pkgname pkg required-packages))) -(message "FPKG has been initialized.") +(defun depends-on (pkgname) + "Install the given PKGNAME if it isn't installed." + (straight-use-package pkgname)) + + (provide 'fpkg) +;;; fpkg.el ends here