cvsdist a8bb5f
;;; rpm-spec-mode.el --- RPM spec file editing commands for Emacs/XEmacs
cvsdist a8bb5f
cvsdist a8bb5f
;; Copyright (C) 1997,1998,1999,2000,2001 Stig Bjørlykke, <stigb@tihlde.org>
cvsdist a8bb5f
cvsdist a8bb5f
;; Author:   Stig Bjørlykke, <stigb@tihlde.org>
cvsdist a8bb5f
;; Keywords: unix, languages
cvsdist c08065
;; Version:  0.11h
cvsdist a8bb5f
cvsdist a8bb5f
;; This file is not yet part of FSF Emacs or XEmacs.
cvsdist a8bb5f
cvsdist a8bb5f
;; Emacs/XEmacs is free software; you can redistribute it and/or modify
cvsdist a8bb5f
;; it under the terms of the GNU General Public License as published by
cvsdist a8bb5f
;; the Free Software Foundation; either version 2, or (at your option)
cvsdist a8bb5f
;; any later version.
cvsdist a8bb5f
cvsdist a8bb5f
;; Emacs/XEmacs is distributed in the hope that it will be useful,
cvsdist a8bb5f
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
cvsdist a8bb5f
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
cvsdist a8bb5f
;; General Public License for more details.
cvsdist a8bb5f
cvsdist a8bb5f
;; You should have received a copy of the GNU General Public License
cvsdist a8bb5f
;; along with Emacs/XEmacs; see the file COPYING.  If not, write to the
cvsdist a8bb5f
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
cvsdist a8bb5f
;; MA 02111-1307, USA.
cvsdist a8bb5f
cvsdist a8bb5f
;;; Synched up with:  both in FSF Emacs and XEmacs.
cvsdist a8bb5f
cvsdist a8bb5f
;;; Thanx to:
cvsdist a8bb5f
cvsdist a8bb5f
;;     Tore Olsen <toreo@tihlde.hist.no> for some general fixes. 
cvsdist a8bb5f
;;     Steve Sanbeg <sanbeg@dset.com> for navigation functions and
cvsdist a8bb5f
;;          some Emacs fixes.
cvsdist a8bb5f
cvsdist a8bb5f
;;; ToDo:
cvsdist a8bb5f
cvsdist a8bb5f
;; - rewrite function names and shortcuts.
cvsdist a8bb5f
;; - autofill changelog entries.
cvsdist a8bb5f
;; - customize rpm-tags-list and rpm-group-tags-list.
cvsdist a8bb5f
;; - get values from `rpm --showrc'.
cvsdist a8bb5f
;; - ssh/rsh for compile.
cvsdist a8bb5f
;; - finish integrating the new navigation functions in with existing stuff. 
cvsdist a8bb5f
;; - use a single prefix conistently (internal)
cvsdist a8bb5f
cvsdist a8bb5f
;;; Commentary:
cvsdist a8bb5f
cvsdist a8bb5f
;; This mode is used for editing spec files used for building RPM packages.
cvsdist a8bb5f
;;
cvsdist a8bb5f
;; Most recent version is available from:
cvsdist a8bb5f
;;  <URL:http://www.tihlde.org/~stigb/rpm-spec-mode.el>
cvsdist a8bb5f
;;
cvsdist a8bb5f
;; Put this in your .emacs file to enable autoloading of rpm-spec-mode,
cvsdist a8bb5f
;; and auto-recognition of ".spec" files:
cvsdist a8bb5f
;;
cvsdist a8bb5f
;;  (autoload 'rpm-spec-mode "rpm-spec-mode.el" "RPM spec mode." t)
cvsdist a8bb5f
;;  (setq auto-mode-alist (append '(("\\.spec" . rpm-spec-mode))
cvsdist a8bb5f
;;                                auto-mode-alist))
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
;;
cvsdist a8bb5f
;; Adapted for Red Hat and some fixes made by Tim Powers <timp@redhat.com>
cvsdist a8bb5f
;; and Trond Eivind Glomsrød <teg@redhat.com>.
cvsdist a8bb5f
;;
cvsdist a8bb5f
;; Adapted by Chmouel Boudjnah <chmouel@mandrakesoft.com> for Mandrake
cvsdist a8bb5f
cvsdist a8bb5f
;;; Code:
cvsdist a8bb5f
cvsdist a8bb5f
(defgroup rpm-spec nil
cvsdist a8bb5f
  "RPM Spec mode with Emacs/XEmacs enhancements."
cvsdist a8bb5f
  :prefix "rpm-spec"
cvsdist a8bb5f
  :group 'languages)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-add-attr nil
cvsdist a8bb5f
  "Add %attr entry for filelistings or not."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-short-circuit nil
cvsdist a8bb5f
  "Skip straight to specified stage.
cvsdist a8bb5f
(ie, skip all stages leading up to the specified stage).  Only valid
cvsdist a8bb5f
in \"%build\" and \"%install\" stage."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-timecheck "0"
cvsdist a8bb5f
  "Set the \"timecheck\" age (0 to disable).
cvsdist a8bb5f
The timecheck value expresses, in seconds, the maximum age of a file
cvsdist a8bb5f
being packaged.  Warnings will be printed for all files beyond the
cvsdist a8bb5f
timecheck age."
cvsdist a8bb5f
  :type 'integer
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-buildroot ""
cvsdist a8bb5f
  "Override the BuildRoot tag with directory <dir>."
cvsdist a8bb5f
  :type 'string
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-target ""
cvsdist a8bb5f
  "Interpret given string as `arch-vendor-os'.
cvsdist a8bb5f
Set the macros _target, _target_arch and _target_os accordingly"
cvsdist a8bb5f
  :type 'string
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist 98a749
(defcustom rpm-completion-ignore-case t
cvsdist 98a749
  "*Non-nil means that case differences are ignored during completion.
cvsdist 98a749
A value of nil means that case is significant.
cvsdist 98a749
This is used during Tempo template completion."
cvsdist 98a749
  :type 'boolean
cvsdist 98a749
  :group 'rpm-spec)
cvsdist 98a749
cvsdist a8bb5f
(defcustom rpm-spec-clean nil
cvsdist a8bb5f
  "Remove the build tree after the packages are made."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-rmsource nil
cvsdist a8bb5f
  "Remove the source and spec file after the packages are made."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-test nil
cvsdist a8bb5f
  "Do not execute any build stages.  Useful for testing out spec files."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-spec-sign-gpg nil
cvsdist a8bb5f
  "Embed a GPG signature in the package.
cvsdist a8bb5f
This signature can be used to verify the integrity and the origin of
cvsdist a8bb5f
the package."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-initialize-sections t
cvsdist a8bb5f
  "Automatically add empty section headings to new spec files."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defcustom rpm-insert-version t
cvsdist a8bb5f
  "Automatically add version in a new changelog entry."
cvsdist a8bb5f
  :type 'boolean
cvsdist a8bb5f
  :group 'rpm-spec)
cvsdist a8bb5f
cvsdist a8bb5f
(defgroup rpm-spec-faces nil
cvsdist a8bb5f
  "Font lock faces for RPM Spec mode."
cvsdist a8bb5f
  :group 'rpm-spec
cvsdist a8bb5f
  :group 'faces)
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
;; variables used by navigation functions.
cvsdist a8bb5f
cvsdist a8bb5f
(defconst rpm-sections 
cvsdist a8bb5f
  '("preamble" "description" "prep" "setup" "build" "install" "clean"
cvsdist a8bb5f
    "changelog" "files")
cvsdist a8bb5f
  "Partial list of section names.")
cvsdist a8bb5f
(defvar rpm-section-list
cvsdist a8bb5f
  '(("preamble") ("description") ("prep") ("setup") ("build") ("install")
cvsdist a8bb5f
	 ("clean") ("changelog") ("files"))
cvsdist a8bb5f
  "Partial list of section names.")
cvsdist a8bb5f
(defconst rpm-scripts 
cvsdist a8bb5f
  '("pre" "post" "preun" "postun" "trigger" "triggerun" "triggerpostun")
cvsdist a8bb5f
  "List of rpm scripts")
cvsdist a8bb5f
(defconst rpm-section-seperate "^%\\(\\w+\\)\\s-")
cvsdist a8bb5f
(defconst rpm-section-regexp 
cvsdist a8bb5f
  "^%\\(\\(description\\)\\|\\(prep\\)\\|\\(changelog\\)\\|\\(build\\)\\|\\(install\\)\\|\\(files\\)\\|\\(clean\\)\\|\\(package\\)\\|\\(pre\\|post\\(un\\)?\\)\\|\\(trigger\\(post\\)?\\([iu]n\\)?\\)\\)\\b"
cvsdist a8bb5f
  "Regular expression to match beginning of a section.")
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defface rpm-spec-tag-face
cvsdist a8bb5f
    '(( ((class color) (background light)) (:foreground "blue") )
cvsdist a8bb5f
      ( ((class color) (background dark)) (:foreground "blue") ))
cvsdist a8bb5f
  "*The face used for tags."
cvsdist a8bb5f
  :group 'rpm-spec-faces)
cvsdist a8bb5f
cvsdist a8bb5f
(defface rpm-spec-macro-face
cvsdist a8bb5f
    '(( ((class color) (background light)) (:foreground "purple") )
cvsdist a8bb5f
      ( ((class color) (background dark)) (:foreground "yellow") ))
cvsdist a8bb5f
  "*The face used for macros."
cvsdist a8bb5f
  :group 'rpm-spec-faces)
cvsdist a8bb5f
cvsdist a8bb5f
(defface rpm-spec-doc-face
cvsdist a8bb5f
    '(( ((class color) (background light)) (:foreground "magenta") )
cvsdist a8bb5f
      ( ((class color) (background dark)) (:foreground "magenta") ))
cvsdist a8bb5f
  "*The face used for document files."
cvsdist a8bb5f
  :group 'rpm-spec-faces)
cvsdist a8bb5f
cvsdist a8bb5f
(defface rpm-spec-dir-face
cvsdist a8bb5f
    '(( ((class color) (background light)) (:foreground "green") )
cvsdist a8bb5f
      ( ((class color) (background dark)) (:foreground "green") ))
cvsdist a8bb5f
  "*The face used for directories."
cvsdist a8bb5f
  :group 'rpm-spec-faces)
cvsdist a8bb5f
cvsdist a8bb5f
(defface rpm-spec-package-face
cvsdist a8bb5f
    '(( ((class color) (background light)) (:foreground "red") )
cvsdist a8bb5f
      ( ((class color) (background dark)) (:foreground "red") ))
cvsdist a8bb5f
  "*The face used for files."
cvsdist a8bb5f
  :group 'rpm-spec-faces)
cvsdist a8bb5f
cvsdist a8bb5f
(defface rpm-spec-ghost-face
cvsdist a8bb5f
    '(( ((class color) (background light)) (:foreground "red") )
cvsdist a8bb5f
      ( ((class color) (background dark)) (:foreground "red") ))
cvsdist a8bb5f
  "*The face used for ghost tags."
cvsdist a8bb5f
  :group 'rpm-spec-faces)
cvsdist a8bb5f
cvsdist a8bb5f
;;; GNU emacs font-lock needs these...
cvsdist a8bb5f
(defvar rpm-spec-macro-face 'rpm-spec-macro-face "*Face for macros")
cvsdist a8bb5f
(defvar rpm-spec-tag-face 'rpm-spec-tag-face "*Face for tags")
cvsdist a8bb5f
(defvar rpm-spec-package-face 'rpm-spec-package-face "*Face for package tag")
cvsdist a8bb5f
(defvar rpm-spec-dir-face 'rpm-spec-dir-face "*Face for directory entries")
cvsdist a8bb5f
(defvar rpm-spec-doc-face 'rpm-spec-doc-face "*Face for documentation entries")
cvsdist a8bb5f
(defvar rpm-spec-ghost-face 'rpm-spec-ghost-face "*Face for %ghost files")
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-default-umask "-"
cvsdist a8bb5f
  "*Default umask for files, specified with %attr")
cvsdist a8bb5f
(defvar rpm-default-owner "root" 
cvsdist a8bb5f
  "*Default owner for files, specified with %attr")
cvsdist a8bb5f
(defvar rpm-default-group "root" 
cvsdist a8bb5f
  "*Default group for files, specified with %attr")
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-no-gpg nil "Tell rpm not to sign package.")
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-tags-list
cvsdist a8bb5f
  '(("Autoreqprov")
cvsdist a8bb5f
    ("Buildroot")
cvsdist a8bb5f
    ("Conflicts")
cvsdist a8bb5f
    ("Copyright")
cvsdist a8bb5f
    ("%description")
cvsdist a8bb5f
    ("Distribution")
cvsdist a8bb5f
    ("Excludearch")
cvsdist a8bb5f
    ("Excludeos")
cvsdist a8bb5f
    ("Exclusivearch")
cvsdist a8bb5f
    ("Exclusiveos")
cvsdist a8bb5f
    ("%files")
cvsdist a8bb5f
    ("Group")
cvsdist a8bb5f
    ("Icon")
cvsdist a8bb5f
    ("%ifarch")
cvsdist a8bb5f
    ("Name")
cvsdist a8bb5f
    ("Nopatch")
cvsdist a8bb5f
    ("Nosource")
cvsdist a8bb5f
    ("%package")
cvsdist a8bb5f
    ("Packager")
cvsdist a8bb5f
    ("Patch")
cvsdist a8bb5f
    ("Prefix")
cvsdist a8bb5f
    ("Provides")
cvsdist a8bb5f
    ("Release")
cvsdist a8bb5f
    ("Requires")
cvsdist a8bb5f
    ("Serial")
cvsdist a8bb5f
    ("Source")
cvsdist a8bb5f
    ("Summary")
cvsdist a8bb5f
    ("Url")
cvsdist a8bb5f
    ("Vendor")
cvsdist a8bb5f
    ("Version"))
cvsdist a8bb5f
  "List which elements are valid tags.")
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-group-tags-list
cvsdist a8bb5f
  '(("Amusements/Games")
cvsdist a8bb5f
    ("Amusements/Graphics")
cvsdist a8bb5f
    ("Applications/Archiving")
cvsdist a8bb5f
    ("Applications/Communications")
cvsdist a8bb5f
    ("Applications/Databases")
cvsdist a8bb5f
    ("Applications/Editors")
cvsdist a8bb5f
    ("Applications/Emulators")
cvsdist a8bb5f
    ("Applications/Engineering")
cvsdist a8bb5f
    ("Applications/File")
cvsdist a8bb5f
    ("Applications/Internet")
cvsdist a8bb5f
    ("Applications/Multimedia")
cvsdist a8bb5f
    ("Applications/Productivity")
cvsdist a8bb5f
    ("Applications/Publishing")
cvsdist a8bb5f
    ("Applications/System")
cvsdist a8bb5f
    ("Applications/Text")
cvsdist a8bb5f
    ("Development/Debuggers")
cvsdist a8bb5f
    ("Development/Languages")
cvsdist a8bb5f
    ("Development/Libraries")
cvsdist a8bb5f
    ("Development/System")
cvsdist a8bb5f
    ("Development/Tools")
cvsdist a8bb5f
    ("Documentation")
cvsdist a8bb5f
    ("System Environment/Base")
cvsdist a8bb5f
    ("System Environment/Daemons")
cvsdist a8bb5f
    ("System Environment/Kernel")
cvsdist a8bb5f
    ("System Environment/Libraries")
cvsdist a8bb5f
    ("System Environment/Shells")
cvsdist a8bb5f
    ("User Interface/Desktops")
cvsdist a8bb5f
    ("User Interface/X")
cvsdist a8bb5f
    ("User Interface/X Hardware Support")
cvsdist a8bb5f
    )
cvsdist a8bb5f
  "List which elements is valid group tags.")
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-spec-mode-syntax-table nil
cvsdist a8bb5f
  "Syntax table in use in RPM-Spec-mode buffers.")
cvsdist a8bb5f
(unless rpm-spec-mode-syntax-table
cvsdist a8bb5f
  (setq rpm-spec-mode-syntax-table (make-syntax-table))
cvsdist a8bb5f
  (modify-syntax-entry ?\\ "\\" rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?\n ">   " rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?\f ">   " rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?\# "<   " rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?/ "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?* "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?+ "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?- "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?= "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?% "_" rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?< "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?> "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?& "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?| "." rpm-spec-mode-syntax-table)
cvsdist a8bb5f
  (modify-syntax-entry ?\' "." rpm-spec-mode-syntax-table))
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-spec-mode-map nil
cvsdist a8bb5f
  "Keymap used in RPM Spec mode.")
cvsdist a8bb5f
(unless rpm-spec-mode-map
cvsdist a8bb5f
  (setq rpm-spec-mode-map (make-sparse-keymap))
cvsdist a8bb5f
  (and (functionp 'set-keymap-name)
cvsdist a8bb5f
       (set-keymap-name rpm-spec-mode-map 'rpm-spec-mode-map))
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-ca" 'rpm-build-ba)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cb" 'rpm-build-bb)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cc" 'rpm-build-bc)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-ce" 'rpm-add-change-log-entry)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cg" 'rpm-goto-section)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-ci" 'rpm-build-bi)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cl" 'rpm-build-bl)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cp" 'rpm-build-bp)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cr" 'rpm-increase-release-tag)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cs" 'rpm-build-bs)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxa" 'rpm-toggle-add-attr)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxb" 'rpm-change-buildroot-option)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxc" 'rpm-toggle-clean)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxg" 'rpm-toggle-sign-gpg)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxi" 'rpm-change-timecheck-option)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxp" 'rpm-change-target-option)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxr" 'rpm-toggle-rmsource)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxs" 'rpm-toggle-short-circuit)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-cxt" 'rpm-toggle-test)
cvsdist a8bb5f
  ;;May be better to have movement commands on \C-ck, and build on \C-c\C-k
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-i" 'rpm-insert-tag)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-n" 'rpm-forward-section)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-p" 'rpm-backward-section)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-t" 'rpm-insert-true-prefix)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-cg" 'rpm-files-group)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-co" 'rpm-files-owner)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-cu" 'rpm-files-umask)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-dd" 'rpm-insert-dir)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-do" 'rpm-insert-docdir)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-fc" 'rpm-insert-config)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-fd" 'rpm-insert-doc)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-ff" 'rpm-insert-file)
cvsdist a8bb5f
  (define-key rpm-spec-mode-map "\C-c\C-fg" 'rpm-insert-ghost)
cvsdist a8bb5f
  ;(define-key rpm-spec-mode-map "\C-q" 'indent-spec-exp)
cvsdist a8bb5f
  ;(define-key rpm-spec-mode-map "\t" 'sh-indent-line)
cvsdist a8bb5f
  )
cvsdist a8bb5f
cvsdist a8bb5f
(defconst rpm-spec-mode-menu
cvsdist a8bb5f
  (purecopy '("RPM-Spec"
cvsdist a8bb5f
         ["Insert Tag"              rpm-insert-tag                t]
cvsdist a8bb5f
         ["Change Tag"              rpm-change-tag                t]
cvsdist a8bb5f
         "---"
cvsdist a8bb5f
         ["Go to section..."        rpm-mouse-goto-section  :keys "C-c g"]
cvsdist a8bb5f
         ["Forward section"         rpm-forward-section           t]
cvsdist a9afeb
         ["Backward section"        rpm-backward-section          t]
cvsdist a8bb5f
         "---"
cvsdist a8bb5f
         ["Add changelog entry..."  rpm-add-change-log-entry      t]
cvsdist a8bb5f
         ["Increase release-tag"    rpm-increase-release-tag      t]
cvsdist a8bb5f
         "---"
cvsdist a8bb5f
         ("Add file entry"
cvsdist a8bb5f
          ["Regular file..."        rpm-insert-file               t]
cvsdist a8bb5f
          ["Config file..."         rpm-insert-config             t]
cvsdist a8bb5f
          ["Document file..."       rpm-insert-doc                t]
cvsdist a8bb5f
          ["Ghost file..."          rpm-insert-ghost              t]
cvsdist a8bb5f
          "---"
cvsdist a8bb5f
          ["Directory..."           rpm-insert-dir                t]
cvsdist a8bb5f
          ["Document directory..."  rpm-insert-docdir             t]
cvsdist a8bb5f
          "---"
cvsdist a8bb5f
			 ["Insert %{prefix}"       rpm-insert-true-prefix        t] 
cvsdist a8bb5f
			 "---"
cvsdist a8bb5f
          ["Default add \"%attr\" entry" rpm-toggle-add-attr
cvsdist a8bb5f
           :style toggle :selected rpm-spec-add-attr]
cvsdist a8bb5f
          ["Change default umask for files..."  rpm-files-umask   t]
cvsdist a8bb5f
          ["Change default owner for files..."  rpm-files-owner   t]
cvsdist a8bb5f
          ["Change default group for files..."  rpm-files-group   t])
cvsdist a8bb5f
         ("Build Options"
cvsdist a8bb5f
          ["Short Circuit" rpm-toggle-short-circuit
cvsdist a8bb5f
           :style toggle :selected rpm-spec-short-circuit]
cvsdist a8bb5f
          ["Remove source" rpm-toggle-rmsource
cvsdist a8bb5f
           :style toggle :selected rpm-spec-rmsource]
cvsdist a8bb5f
          ["Clean"         rpm-toggle-clean
cvsdist a8bb5f
           :style toggle :selected rpm-spec-clean]
cvsdist a8bb5f
          ["Testing only"  rpm-toggle-test
cvsdist a8bb5f
           :style toggle :selected rpm-spec-test]
cvsdist a8bb5f
          ["GPG Sign"      rpm-toggle-sign-gpg
cvsdist a8bb5f
           :style toggle :selected rpm-spec-sign-gpg]
cvsdist a8bb5f
          "---"
cvsdist a8bb5f
          ["Change timecheck value..."  rpm-change-timecheck-option   t]
cvsdist a8bb5f
          ["Change buildroot value..."  rpm-change-buildroot-option   t]
cvsdist a8bb5f
          ["Change target value..."     rpm-change-target-option      t])
cvsdist a8bb5f
         ("RPM Build"
cvsdist a8bb5f
          ["Execute \"%prep\" stage"    rpm-build-bp                  t]
cvsdist a8bb5f
          ["Do a \"list check\""        rpm-build-bl                  t]
cvsdist a8bb5f
          ["Do the \"%build\" stage"    rpm-build-bc                  t]
cvsdist a8bb5f
          ["Do the \"%install\" stage"  rpm-build-bi                  t]
cvsdist a8bb5f
          "---"
cvsdist a8bb5f
          ["Build binary package"       rpm-build-bb                  t]
cvsdist a8bb5f
          ["Build source package"       rpm-build-bs                  t]
cvsdist a8bb5f
          ["Build binary and source"    rpm-build-ba                  t])
cvsdist a8bb5f
         "---"
cvsdist a8bb5f
         ["About rpm-spec-mode"         rpm-about-rpm-spec-mode       t]
cvsdist a8bb5f
         )))
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-spec-font-lock-keywords
cvsdist a8bb5f
  '(
cvsdist a8bb5f
    ("%[a-zA-Z0-9_]+" 0 rpm-spec-macro-face)
cvsdist c08065
    ("^\\([a-zA-Z0-9]+\\)\\(\([a-zA-Z0-9,]+\)\\):"
cvsdist a8bb5f
     (1 rpm-spec-tag-face)
cvsdist a8bb5f
     (2 rpm-spec-ghost-face))
cvsdist a8bb5f
    ("^\\([a-zA-Z0-9]+\\):" 1 rpm-spec-tag-face)
cvsdist a8bb5f
    ("%\\(define\\|files\\|package\\|description\\)[ \t]+\\([^ \t\n-]+\\)"
cvsdist a8bb5f
     (2 rpm-spec-package-face))
cvsdist a8bb5f
    ("%configure " 0 rpm-spec-macro-face)
cvsdist a8bb5f
    ("%dir[ \t]+\\([^ \t\n]+\\)[ \t]*" 1 rpm-spec-dir-face)
cvsdist a8bb5f
    ("%doc\\(\\|dir\\)[ \t]+\\(.*\\)\n" 2 rpm-spec-doc-face)
cvsdist a8bb5f
    ("%\\(ghost\\|config\\)[ \t]+\\(.*\\)\n" 2 rpm-spec-ghost-face)
cvsdist a8bb5f
    ("^%.+-[a-zA-Z][ \t]+\\([a-zA-Z0-9\.-]+\\)" 1 rpm-spec-doc-face)
cvsdist a8bb5f
    ("^\\(.+\\)(\\([a-zA-Z]\\{2,2\\}\\)):" 
cvsdist a8bb5f
     (1 rpm-spec-tag-face)
cvsdist a8bb5f
     (2 rpm-spec-doc-face))
cvsdist a8bb5f
    ("^\\*\\(.*[0-9] \\)\\(.*\\)\\(<.*>\\)\\(.*\\)\n"
cvsdist a8bb5f
     (1 rpm-spec-dir-face)
cvsdist a8bb5f
     (2 rpm-spec-package-face)
cvsdist a8bb5f
     (3 rpm-spec-tag-face)
cvsdist a8bb5f
     (4 font-lock-warning-face))
cvsdist a8bb5f
    ("%{[^{}]*}" 0 rpm-spec-macro-face)
cvsdist a8bb5f
    )
cvsdist a8bb5f
  "Additional expressions to highlight in RPM Spec mode.")
cvsdist a8bb5f
cvsdist a8bb5f
;;Initialize font lock for xemacs
cvsdist a8bb5f
(put 'rpm-spec-mode 'font-lock-defaults '(rpm-spec-font-lock-keywords))
cvsdist a8bb5f
cvsdist a8bb5f
(defvar rpm-spec-mode-abbrev-table nil
cvsdist a8bb5f
  "Abbrev table in use in RPM-Spec-mode buffers.")
cvsdist a8bb5f
(define-abbrev-table 'rpm-spec-mode-abbrev-table ())
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
;;;###autoload
cvsdist a8bb5f
(defun rpm-spec-mode ()
cvsdist a8bb5f
  "Major mode for editing spec files.
cvsdist a8bb5f
This is much like C mode except for the syntax of comments.  It uses
cvsdist a8bb5f
the same keymap as C mode and has the same variables for customizing
cvsdist a8bb5f
indentation.  It has its own abbrev table and its own syntax table.
cvsdist a8bb5f
cvsdist a8bb5f
Turning on RPM Spec mode calls the value of the variable `rpm-spec-mode-hook'
cvsdist a8bb5f
with no args, if that value is non-nil."
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (kill-all-local-variables)
cvsdist a8bb5f
  (condition-case nil
cvsdist a8bb5f
      (require 'shindent)
cvsdist a8bb5f
    (error
cvsdist a8bb5f
     (require 'sh-script)))
cvsdist a8bb5f
  (require 'cc-mode)
cvsdist a8bb5f
  (use-local-map rpm-spec-mode-map)
cvsdist a8bb5f
  (setq major-mode 'rpm-spec-mode)
cvsdist a8bb5f
  (setq mode-name "RPM-SPEC")
cvsdist a8bb5f
  (setq local-abbrev-table rpm-spec-mode-abbrev-table)
cvsdist a8bb5f
  (set-syntax-table rpm-spec-mode-syntax-table)
cvsdist a8bb5f
cvsdist a8bb5f
  (require 'easymenu)
cvsdist a8bb5f
  (easy-menu-define rpm-spec-call-menu rpm-spec-mode-map 
cvsdist a8bb5f
                    "Post menu for rpm-spec-mode" rpm-spec-mode-menu)
cvsdist a8bb5f
  (easy-menu-add rpm-spec-mode-menu)
cvsdist a8bb5f
cvsdist a8bb5f
  (if (= (buffer-size) 0)
cvsdist a8bb5f
      (rpm-spec-initialize))
cvsdist a8bb5f
cvsdist a8bb5f
  (make-local-variable 'paragraph-start)
cvsdist a8bb5f
  (setq paragraph-start (concat "$\\|" page-delimiter))
cvsdist a8bb5f
  (make-local-variable 'paragraph-separate)
cvsdist a8bb5f
  (setq paragraph-separate paragraph-start)
cvsdist a8bb5f
  (make-local-variable 'paragraph-ignore-fill-prefix)
cvsdist a8bb5f
  (setq paragraph-ignore-fill-prefix t)
cvsdist a8bb5f
;  (make-local-variable 'indent-line-function)
cvsdist a8bb5f
;  (setq indent-line-function 'c-indent-line)
cvsdist a8bb5f
  (make-local-variable 'require-final-newline)
cvsdist a8bb5f
  (setq require-final-newline t)
cvsdist a8bb5f
  (make-local-variable 'comment-start)
cvsdist a8bb5f
  (setq comment-start "# ")
cvsdist a8bb5f
  (make-local-variable 'comment-end)
cvsdist a8bb5f
  (setq comment-end "")
cvsdist a8bb5f
  (make-local-variable 'comment-column)
cvsdist a8bb5f
  (setq comment-column 32)
cvsdist a8bb5f
  (make-local-variable 'comment-start-skip)
cvsdist a8bb5f
  (setq comment-start-skip "#+ *")
cvsdist a8bb5f
;  (make-local-variable 'comment-indent-function)
cvsdist a8bb5f
;  (setq comment-indent-function 'c-comment-indent)
cvsdist a8bb5f
  ;;Initialize font lock for GNU emacs.
cvsdist a8bb5f
  (make-local-variable 'font-lock-defaults)
cvsdist a8bb5f
  (setq font-lock-defaults '(rpm-spec-font-lock-keywords nil t))
cvsdist a8bb5f
  (run-hooks 'rpm-spec-mode-hook))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-command-filter (process string)
cvsdist a8bb5f
  "Filter to process normal output."
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (set-buffer (process-buffer process))
cvsdist a8bb5f
    (save-excursion
cvsdist a8bb5f
      (goto-char (process-mark process))
cvsdist a8bb5f
      (insert-before-markers string)
cvsdist a8bb5f
      (set-marker (process-mark process) (point)))))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-add-change-log-entry (&optional change-log-entry)
cvsdist a8bb5f
  "Find change log and add an entry for today."
cvsdist a8bb5f
  (interactive "sChangelog entry: ")
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (rpm-goto-section "changelog")
cvsdist a8bb5f
    (let ((string (concat "* " (substring (current-time-string) 0 11)
cvsdist a8bb5f
           (substring (current-time-string) -4) " "
cvsdist a8bb5f
           (user-full-name) " <" user-mail-address ">")))
cvsdist a8bb5f
      (if (not (search-forward string nil t))
cvsdist a8bb5f
     (insert "\n" string "\n")
cvsdist a8bb5f
   (forward-line 2))
cvsdist a8bb5f
      (insert "- " change-log-entry "\n"))))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-f (&optional filetype filename)
cvsdist a8bb5f
  "Insert new %files entry."
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (and (rpm-goto-section "files") (rpm-end-of-section))
cvsdist a8bb5f
    (if (or (eq filename 1) (not filename))
cvsdist a8bb5f
        (insert (read-file-name
cvsdist a8bb5f
                 (concat filetype "filename: ") "" "" nil) "\n")
cvsdist a8bb5f
      (insert filename "\n"))
cvsdist a8bb5f
    (forward-line -1)
cvsdist a8bb5f
    (if rpm-spec-add-attr
cvsdist a8bb5f
        (let ((rpm-default-mode rpm-default-umask))
cvsdist a8bb5f
          (insert "%attr(" rpm-default-mode ", " rpm-default-owner ", "
cvsdist a8bb5f
                  rpm-default-group ") ")))
cvsdist a8bb5f
    (insert filetype)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-file (&optional filename)
cvsdist a8bb5f
  "Insert regular file."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-insert-f "" filename))
cvsdist a8bb5f
  
cvsdist a8bb5f
(defun rpm-insert-config (&optional filename)
cvsdist a8bb5f
  "Insert config file."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-insert-f "%config " filename))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-doc (&optional filename)
cvsdist a8bb5f
  "Insert doc file."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-insert-f "%doc " filename))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-ghost (&optional filename)
cvsdist a8bb5f
  "Insert ghost file."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-insert-f "%ghost " filename))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-dir (&optional dirname)
cvsdist a8bb5f
  "Insert directory."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-insert-f "%dir " dirname))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-docdir (&optional dirname)
cvsdist a8bb5f
  "Insert doc directory."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-insert-f "%docdir " dirname))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist 98a749
(defun rpm-completing-read (prompt table &optional pred require init hist)
cvsdist 98a749
  "Read from the minibuffer, with completion.
cvsdist 98a749
Like `completing-read', but the variable `rpm-completion-ignore-case'
cvsdist 98a749
controls whether case is significant."
cvsdist 98a749
  (let ((completion-ignore-case rpm-completion-ignore-case))
cvsdist 98a749
    (completing-read prompt table pred require init hist)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert (&optional what file-completion)
cvsdist a8bb5f
  "Insert given tag.  Use file-completion if argument is t."
cvsdist a8bb5f
  (beginning-of-line)
cvsdist a8bb5f
  (if (not what)
cvsdist 98a749
      (setq what (rpm-completing-read "Tag: " rpm-tags-list)))
cvsdist a8bb5f
  (if (string-match "^%" what)
cvsdist a8bb5f
      (setq read-text (concat "Packagename for " what ": ")
cvsdist a8bb5f
            insert-text (concat what " "))
cvsdist a8bb5f
    (setq read-text (concat what ": ")
cvsdist a8bb5f
          insert-text (concat what ": ")))
cvsdist a8bb5f
  (cond
cvsdist a8bb5f
   ((string-equal what "Group")
cvsdist a8bb5f
    (rpm-insert-group))
cvsdist a8bb5f
   ((string-equal what "Source")
cvsdist a8bb5f
    (rpm-insert-n "Source"))
cvsdist a8bb5f
   ((string-equal what "Patch")
cvsdist a8bb5f
    (rpm-insert-n "Patch"))
cvsdist a8bb5f
   (t
cvsdist a8bb5f
    (if file-completion
cvsdist a8bb5f
        (insert insert-text (read-file-name (concat read-text) "" "" nil) "\n")
cvsdist a8bb5f
      (insert insert-text (read-from-minibuffer (concat read-text)) "\n")))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-topdir ()
cvsdist a8bb5f
  (or
cvsdist a8bb5f
   (getenv "RPM")
cvsdist a8bb5f
   (getenv "rpm")
cvsdist a8bb5f
   (if (file-directory-p "~/rpm") "~/rpm/")
cvsdist a8bb5f
   (if (file-directory-p "~/RPM") "~/RPM/")
cvsdist a8bb5f
   (if (file-directory-p "/usr/src/redhat/")"/usr/src/redhat/")
cvsdist a8bb5f
   "/usr/src/RPM"))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-n (what &optional arg)
cvsdist a8bb5f
  "Insert given tag with possible number."
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (goto-char (point-max))
cvsdist a8bb5f
    (if (search-backward-regexp (concat "^" what "\\([0-9]*\\):") nil t)
cvsdist a8bb5f
        (let ((release (1+ (string-to-int (match-string 1)))))
cvsdist a8bb5f
          (forward-line 1)
cvsdist a8bb5f
          (let ((default-directory (concat (rpm-topdir) "/SOURCES/")))
cvsdist a8bb5f
            (insert what (int-to-string release) ": "
cvsdist a8bb5f
                    (read-file-name (concat what "file: ") "" "" nil) "\n")))
cvsdist a8bb5f
      (goto-char (point-min))
cvsdist a8bb5f
      (rpm-end-of-section)
cvsdist a8bb5f
      (insert what ": " (read-from-minibuffer (concat what "file: ")) "\n"))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change (&optional what arg)
cvsdist a8bb5f
  "Update given tag."
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (if (not what)
cvsdist 98a749
        (setq what (rpm-completing-read "Tag: " rpm-tags-list)))
cvsdist a8bb5f
    (cond
cvsdist a8bb5f
     ((string-equal what "Group")
cvsdist a8bb5f
      (rpm-change-group))
cvsdist a8bb5f
     ((string-equal what "Source")
cvsdist a8bb5f
      (rpm-change-n "Source"))
cvsdist a8bb5f
     ((string-equal what "Patch")
cvsdist a8bb5f
      (rpm-change-n "Patch"))
cvsdist a8bb5f
     (t
cvsdist a8bb5f
      (goto-char (point-min))
cvsdist a8bb5f
      (if (search-forward-regexp (concat "^" what ":\\s-*\\(.*\\)$") nil t)
cvsdist a8bb5f
          (replace-match
cvsdist a8bb5f
           (concat what ": " (read-from-minibuffer
cvsdist a8bb5f
                              (concat "New " what ": ") (match-string 1))))
cvsdist a8bb5f
        (message (concat what " tag not found...")))))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-n (what &optional arg)
cvsdist a8bb5f
  "Change given tag with possible number."
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (goto-char (point-min))
cvsdist a8bb5f
    (let ((number (read-from-minibuffer (concat what " number: "))))
cvsdist a8bb5f
      (if (search-forward-regexp
cvsdist a8bb5f
           (concat "^" what number ":\\s-*\\(.*\\)") nil t)
cvsdist a8bb5f
          (let ((default-directory (concat (rpm-topdir) "/SOURCES/")))
cvsdist a8bb5f
            (replace-match
cvsdist a8bb5f
             (concat what number ": "
cvsdist a8bb5f
                     (read-file-name (concat "New " what number " file: ")
cvsdist a8bb5f
                                     "" "" nil (match-string 1)))))
cvsdist a8bb5f
        (message (concat what " number \"" number "\" not found..."))))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-group (group)
cvsdist a8bb5f
  "Insert Group tag."
cvsdist 98a749
  (interactive (list (rpm-completing-read "Group: " rpm-group-tags-list)))
cvsdist a8bb5f
  (beginning-of-line)
cvsdist a8bb5f
  (insert "Group: " group "\n"))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-group (&optional arg)
cvsdist a8bb5f
  "Update Group tag."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (goto-char (point-min))
cvsdist a8bb5f
    (if (search-forward-regexp "^Group: \\(.*\\)$" nil t)
cvsdist a8bb5f
        (replace-match
cvsdist a8bb5f
         (concat "Group: "
cvsdist 98a749
                 (insert (rpm-completing-read "Group: " rpm-group-tags-list
cvsdist a8bb5f
                                          nil nil (match-string 1)))))
cvsdist a8bb5f
      (message "Group tag not found..."))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-tag (&optional arg)
cvsdist 98a749
  "Insert or change a tag."
cvsdist a8bb5f
  (interactive "p")
cvsdist 98a749
  (if current-prefix-arg
cvsdist 98a749
      (rpm-change)
cvsdist 98a749
    (rpm-insert)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-tag (&optional arg)
cvsdist a8bb5f
  "Change a tag."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-change))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-packager (&optional arg)
cvsdist a8bb5f
  "Insert Packager tag."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (beginning-of-line)
cvsdist a8bb5f
  (insert "Packager: " (user-full-name) " <" user-mail-address ">\n"))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-packager (&optional arg)
cvsdist a8bb5f
  "Update Packager tag."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (rpm-change "Packager"))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-current-section nil
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (rpm-forward-section)
cvsdist a8bb5f
    (rpm-backward-section)
cvsdist a8bb5f
    (if (bobp) "preamble" 
cvsdist a8bb5f
      (buffer-substring (match-beginning 1) (match-end 1)))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-backward-section nil
cvsdist a8bb5f
  "Move backward to the beginning of the previous section.
cvsdist a8bb5f
Go to beginning of previous section."
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (or (re-search-backward rpm-section-regexp nil t)
cvsdist a8bb5f
      (goto-char (point-min))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-beginning-of-section nil
cvsdist a8bb5f
  "Move backward to the beginning of the current section.
cvsdist a8bb5f
Go to beginning of current section."
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (or (and (looking-at rpm-section-regexp) (point))
cvsdist a8bb5f
      (re-search-backward rpm-section-regexp nil t)
cvsdist a8bb5f
      (goto-char (point-min))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-forward-section nil
cvsdist a8bb5f
  "Move forward to the beginning of the next section."
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (forward-char)
cvsdist a8bb5f
  (if (re-search-forward rpm-section-regexp nil t)
cvsdist a8bb5f
      (progn (forward-line 0) (point))
cvsdist a8bb5f
    (goto-char (point-max))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-end-of-section nil
cvsdist a8bb5f
  "Move forward to the end of this section."
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (forward-char)
cvsdist a8bb5f
  (if (re-search-forward rpm-section-regexp nil t)
cvsdist a8bb5f
      (forward-line -1)
cvsdist a8bb5f
    (goto-char (point-max)))
cvsdist a8bb5f
;;  (while (or (looking-at paragraph-separate) (looking-at "^\\s-*#"))
cvsdist a8bb5f
  (while (looking-at "^\\s-*\\($\\|#\\)")
cvsdist a8bb5f
    (forward-line -1))
cvsdist a8bb5f
  (forward-line 1)
cvsdist a8bb5f
  (point))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-goto-section (section)
cvsdist a8bb5f
  "Move point to the beginning of the specified section; 
cvsdist a8bb5f
leave point at previous location."
cvsdist 98a749
  (interactive (list (rpm-completing-read "Section: " rpm-section-list)))
cvsdist a8bb5f
  (push-mark)
cvsdist a8bb5f
  (goto-char (point-min))
cvsdist a8bb5f
  (or 
cvsdist a8bb5f
   (equal section "preamble")
cvsdist a8bb5f
   (re-search-forward (concat "^%" section "\\b") nil t)
cvsdist a8bb5f
   (let ((s (cdr rpm-sections)))
cvsdist a8bb5f
     (while (not (equal section (car s)))
cvsdist a8bb5f
       (re-search-forward (concat "^%" (car s) "\\b") nil t)
cvsdist a8bb5f
       (setq s (cdr s)))
cvsdist a8bb5f
     (if (re-search-forward rpm-section-regexp nil t)
cvsdist a8bb5f
         (forward-line -1) (goto-char (point-max)))
cvsdist a8bb5f
     (insert "\n%" section "\n"))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-mouse-goto-section (&optional section)
cvsdist a8bb5f
  (interactive 
cvsdist a8bb5f
   (x-popup-menu nil
cvsdist a8bb5f
    (list "sections" 
cvsdist a8bb5f
          (cons "Sections" (mapcar (lambda (e) (list e e)) rpm-sections))
cvsdist a8bb5f
          (cons "Scripts" (mapcar (lambda (e) (list e e)) rpm-scripts))
cvsdist a8bb5f
          )))
cvsdist a8bb5f
  (and section ;if user doesn't pick a section, exit quietly.
cvsdist a8bb5f
       (if (member section rpm-sections)
cvsdist a8bb5f
           (rpm-goto-section section)
cvsdist a8bb5f
         (goto-char (point-min))
cvsdist a8bb5f
         (or (re-search-forward (concat "^%" section "\\b") nil t)
cvsdist a8bb5f
             (and (re-search-forward "^%files\\b" nil t) (forward-line -1))
cvsdist a8bb5f
             (goto-char (point-max))))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-insert-true-prefix () 
cvsdist a8bb5f
  (interactive)
cvsdist a8bb5f
  (insert "%{prefix}"))
cvsdist a8bb5f
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build (buildoptions)
cvsdist a8bb5f
  "Build this rpm-package."
cvsdist a8bb5f
  (setq rpm-buffer-name
cvsdist a9afeb
        (concat "*rpmbuild " buildoptions " "
cvsdist a8bb5f
                (file-name-nondirectory buffer-file-name) "*"))
cvsdist a8bb5f
  (rpm-process-check rpm-buffer-name)
cvsdist a8bb5f
  (if (get-buffer rpm-buffer-name)
cvsdist a8bb5f
      (kill-buffer rpm-buffer-name))
cvsdist a8bb5f
  (create-file-buffer rpm-buffer-name)
cvsdist a8bb5f
  (display-buffer rpm-buffer-name)
cvsdist a8bb5f
  (setq buildoptions (list buildoptions buffer-file-name))
cvsdist a8bb5f
  (if (or rpm-spec-short-circuit rpm-spec-test)
cvsdist a8bb5f
      (setq rpm-no-gpg t))
cvsdist a8bb5f
  (if rpm-spec-rmsource
cvsdist a8bb5f
      (setq buildoptions (cons "--rmsource" buildoptions)))
cvsdist a8bb5f
  (if rpm-spec-clean
cvsdist a8bb5f
      (setq buildoptions (cons "--clean" buildoptions)))
cvsdist a8bb5f
  (if rpm-spec-short-circuit
cvsdist a8bb5f
      (setq buildoptions (cons "--short-circuit" buildoptions)))
cvsdist a8bb5f
  (if (and (not (equal rpm-spec-timecheck "0"))
cvsdist a8bb5f
           (not (equal rpm-spec-timecheck "")))
cvsdist a8bb5f
      (setq buildoptions (cons "--timecheck" (cons rpm-spec-timecheck
cvsdist a8bb5f
                                                   buildoptions))))
cvsdist a8bb5f
  (if (not (equal rpm-spec-buildroot ""))
cvsdist a8bb5f
      (setq buildoptions (cons "--buildroot" (cons rpm-spec-buildroot
cvsdist a8bb5f
                                                   buildoptions))))
cvsdist a8bb5f
  (if (not (equal rpm-spec-target ""))
cvsdist a8bb5f
      (setq buildoptions (cons "--target" (cons rpm-spec-target
cvsdist a8bb5f
                                                buildoptions))))
cvsdist a8bb5f
  (if rpm-spec-test
cvsdist a8bb5f
      (setq buildoptions (cons "--test" buildoptions)))
cvsdist a8bb5f
  (if (and rpm-spec-sign-gpg (not rpm-no-gpg))
cvsdist a8bb5f
      (setq buildoptions (cons "--sign" buildoptions)))
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (set-buffer (get-buffer rpm-buffer-name))
cvsdist a8bb5f
    (goto-char (point-max)))
cvsdist a8bb5f
  (let ((process
cvsdist a9afeb
         (apply 'start-process "rpmbuild" rpm-buffer-name "rpmbuild"
cvsdist a9afeb
                buildoptions)))
cvsdist a8bb5f
    (if (and rpm-spec-sign-gpg (not rpm-no-gpg))
cvsdist a8bb5f
        (let ((rpm-passwd-cache (read-passwd "GPG passphrase: ")))
cvsdist a8bb5f
          (process-send-string process (concat rpm-passwd-cache "\n"))))
cvsdist a8bb5f
    (set-process-filter process 'rpm-command-filter)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-bp (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -bp'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (if rpm-spec-short-circuit
cvsdist a9afeb
      (message "Cannot run `rpmbuild -bp' with --short-circuit")
cvsdist a8bb5f
    (setq rpm-no-gpg t)
cvsdist a8bb5f
    (rpm-build "-bp")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-bl (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -bl'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (if rpm-spec-short-circuit
cvsdist a9afeb
      (message "Cannot run `rpmbuild -bl' with --short-circuit")
cvsdist a8bb5f
    (setq rpm-no-gpg t)
cvsdist a8bb5f
    (rpm-build "-bl")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-bc (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -bc'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-no-gpg t)
cvsdist a8bb5f
  (rpm-build "-bc"))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-bi (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -bi'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-no-gpg t)
cvsdist a8bb5f
  (rpm-build "-bi"))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-bb (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -bb'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (if rpm-spec-short-circuit
cvsdist a9afeb
      (message "Cannot run `rpmbuild -bb' with --short-circuit")
cvsdist a8bb5f
    (setq rpm-no-gpg nil)
cvsdist a8bb5f
    (rpm-build "-bb")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-bs (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -bs'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (if rpm-spec-short-circuit
cvsdist a9afeb
      (message "Cannot run `rpmbuild -bs' with --short-circuit")
cvsdist a8bb5f
    (setq rpm-no-gpg nil)
cvsdist a8bb5f
    (rpm-build "-bs")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-build-ba (&optional arg)
cvsdist a9afeb
  "Run a `rpmbuild -ba'."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (if rpm-spec-short-circuit
cvsdist a9afeb
      (message "Cannot run `rpmbuild -ba' with --short-circuit")
cvsdist a8bb5f
    (setq rpm-no-gpg nil)
cvsdist a8bb5f
    (rpm-build "-ba")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-process-check (buffer)
cvsdist a8bb5f
  "Check if BUFFER has a running process.
cvsdist a8bb5f
If so, give the user the choice of aborting the process or the current
cvsdist a8bb5f
command."
cvsdist a8bb5f
  (let ((process (get-buffer-process (get-buffer buffer))))
cvsdist a8bb5f
    (if (and process (eq (process-status process) 'run))
cvsdist a8bb5f
        (if (yes-or-no-p (concat "Process `" (process-name process)
cvsdist a8bb5f
                                 "' running.  Kill it? "))
cvsdist a8bb5f
            (delete-process process)
cvsdist a8bb5f
          (error "Cannot run two simultaneous processes ...")))))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-toggle-short-circuit (&optional arg)
cvsdist a8bb5f
  "Toggle rpm-spec-short-circuit."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-short-circuit (not rpm-spec-short-circuit))
cvsdist a8bb5f
  (rpm-update-mode-name)
cvsdist a8bb5f
  (message (concat "Turned `--short-circuit' "
cvsdist a8bb5f
                   (if rpm-spec-short-circuit "on" "off") ".")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-toggle-rmsource (&optional arg)
cvsdist a8bb5f
  "Toggle rpm-spec-rmsource."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-rmsource (not rpm-spec-rmsource))
cvsdist a8bb5f
  (rpm-update-mode-name)
cvsdist a8bb5f
  (message (concat "Turned `--rmsource' "
cvsdist a8bb5f
                   (if rpm-spec-rmsource "on" "off") ".")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-toggle-clean (&optional arg)
cvsdist a8bb5f
  "Toggle rpm-spec-clean."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-clean (not rpm-spec-clean))
cvsdist a8bb5f
  (rpm-update-mode-name)
cvsdist a8bb5f
  (message (concat "Turned `--clean' "
cvsdist a8bb5f
                   (if rpm-spec-clean "on" "off") ".")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-toggle-test (&optional arg)
cvsdist a8bb5f
  "Toggle rpm-spec-test."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-test (not rpm-spec-test))
cvsdist a8bb5f
  (rpm-update-mode-name)
cvsdist a8bb5f
  (message (concat "Turned `--test' "
cvsdist a8bb5f
                   (if rpm-spec-test "on" "off") ".")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-toggle-sign-gpg (&optional arg)
cvsdist a8bb5f
  "Toggle rpm-spec-sign-gpg."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-sign-gpg (not rpm-spec-sign-gpg))
cvsdist a8bb5f
  (rpm-update-mode-name)
cvsdist a8bb5f
  (message (concat "Turned `--sign' "
cvsdist a8bb5f
                   (if rpm-spec-sign-gpg "on" "off") ".")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-toggle-add-attr (&optional arg)
cvsdist a8bb5f
  "Toggle rpm-spec-add-attr."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-add-attr (not rpm-spec-add-attr))
cvsdist a8bb5f
  (rpm-update-mode-name)
cvsdist a8bb5f
  (message (concat "Default add \"attr\" entry turned "
cvsdist a8bb5f
                   (if rpm-spec-add-attr "on" "off") ".")))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-update-mode-name ()
cvsdist a8bb5f
  "Update mode-name according to values set."
cvsdist a8bb5f
  (setq mode-name "RPM-SPEC")
cvsdist a8bb5f
  (setq modes (concat (if rpm-spec-add-attr      "A")
cvsdist a8bb5f
							 (if rpm-spec-clean         "C")
cvsdist a8bb5f
							 (if rpm-spec-sign-gpg      "G")
cvsdist a8bb5f
							 (if rpm-spec-rmsource      "R")
cvsdist a8bb5f
							 (if rpm-spec-short-circuit "S")
cvsdist a8bb5f
							 (if rpm-spec-test          "T")
cvsdist a8bb5f
							 ))
cvsdist a8bb5f
  (if (not (equal modes ""))
cvsdist a8bb5f
		(setq mode-name (concat mode-name ":" modes))))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-timecheck-option (&optional arg)
cvsdist a8bb5f
  "Change the value for timecheck."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-timecheck
cvsdist a8bb5f
        (read-from-minibuffer "New timecheck: " rpm-spec-timecheck)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-buildroot-option (&optional arg)
cvsdist a8bb5f
  "Change the value for buildroot."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-buildroot
cvsdist a8bb5f
        (read-from-minibuffer "New buildroot: " rpm-spec-buildroot)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-change-target-option (&optional arg)
cvsdist a8bb5f
  "Change the value for target."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-spec-target
cvsdist a8bb5f
        (read-from-minibuffer "New target: " rpm-spec-target)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-files-umask (&optional arg)
cvsdist a8bb5f
  "Change the default umask for files."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-default-umask
cvsdist a8bb5f
        (read-from-minibuffer "Default file umask: " rpm-default-umask)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-files-owner (&optional arg)
cvsdist a8bb5f
  "Change the default owner for files."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-default-owner
cvsdist a8bb5f
        (read-from-minibuffer "Default file owner: " rpm-default-owner)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-files-group (&optional arg)
cvsdist a8bb5f
  "Change the source directory."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (setq rpm-default-group
cvsdist a8bb5f
        (read-from-minibuffer "Default file group: " rpm-default-group)))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-increase-release-tag (&optional arg)
cvsdist a8bb5f
  "Increase the release tag by 1."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (goto-char (point-min))
cvsdist a8bb5f
    (if (search-forward-regexp "^Release:[ \t]*\\([0-9]+\\)\\(.*\\)" nil t)
cvsdist a8bb5f
        (let ((release (1+ (string-to-int (match-string 1)))))
cvsdist a8bb5f
          (setq release (concat (int-to-string release) (match-string 2)))
cvsdist a8bb5f
          (replace-match (concat "Release: " release))
cvsdist 98a749
          (message (concat "Release tag changed to " release ".")))
cvsdist 98a749
		(if (search-forward-regexp "^Release:[ \t]*%{?\\([^}]*\\)}?$" nil t)
cvsdist 98a749
			 (rpm-increase-release-with-macros)
cvsdist 98a749
		  (message "No Release tag found...")))))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-spec-field-value (field max)
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (let ((str
cvsdist a8bb5f
           (progn
cvsdist a8bb5f
             (goto-char (point-min))
cvsdist a8bb5f
             (search-forward-regexp (concat field ":[ \t]*\\(.+\\).*$") max)
cvsdist a8bb5f
             (match-string 1))))
cvsdist a8bb5f
      (if (string-match "%{?\\([^}]*\\)}?$" str)
cvsdist a8bb5f
          (progn
cvsdist a8bb5f
            (goto-char (point-min))
cvsdist a8bb5f
            (search-forward-regexp
cvsdist a8bb5f
             (concat "%define[ \t]+" (substring str (match-beginning 1)
cvsdist a8bb5f
                                                (match-end 1))
cvsdist a8bb5f
                     "[ \t]+\\(.*\\)"))
cvsdist a8bb5f
            (match-string 1))
cvsdist a8bb5f
        str))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-find-spec-version ()
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (goto-char (point-min))
cvsdist a8bb5f
    (let* ((max (search-forward-regexp rpm-section-regexp))
cvsdist a8bb5f
           (version (rpm-spec-field-value "Version" max))
cvsdist a8bb5f
           (release (rpm-spec-field-value "Release" max)) )
cvsdist a8bb5f
      (concat version "-" release))))
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-increase-release-with-macros ()
cvsdist a8bb5f
  (save-excursion
cvsdist a8bb5f
    (let ((str
cvsdist a8bb5f
           (progn
cvsdist a8bb5f
             (goto-char (point-min))
cvsdist a8bb5f
             (search-forward-regexp (concat "Release:[ \t]*\\(.+\\).*$") nil)
cvsdist a8bb5f
             (match-string 1))))
cvsdist a8bb5f
      (let ((inrel
cvsdist a8bb5f
             (if (string-match "%{?\\([^}]*\\)}?$" str)
cvsdist a8bb5f
                 (progn
cvsdist a8bb5f
                   (goto-char (point-min))
cvsdist a8bb5f
                   (setq macros (substring str (match-beginning 1)
cvsdist a8bb5f
                                           (match-end 1)))
cvsdist a8bb5f
                   (search-forward-regexp
cvsdist a8bb5f
                    (concat "%define[ \t]+" macros
cvsdist a8bb5f
                            "[ \t]+\\(\\([0-9]\\|\\.\\)+\\)\\(.*\\)"))
cvsdist a8bb5f
                   (concat macros " " (int-to-string (1+ (string-to-int
cvsdist a8bb5f
                                                          (match-string 1))))
cvsdist a8bb5f
                           (match-string 3)))
cvsdist a8bb5f
               str)))
cvsdist a8bb5f
        (setq dinrel inrel)
cvsdist a8bb5f
        (replace-match (concat "%define " dinrel))
cvsdist a8bb5f
        (message (concat "Release tag changed to " dinrel "."))))))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-spec-initialize ()
cvsdist a8bb5f
  "Create a default spec file if one does not exist or is empty."
cvsdist a8bb5f
  (let (file name version (release "1"))
cvsdist a8bb5f
    (setq file (if (buffer-file-name)
cvsdist a8bb5f
                   (file-name-nondirectory (buffer-file-name))
cvsdist a8bb5f
                 (buffer-name)))
cvsdist a8bb5f
    (cond
cvsdist a8bb5f
     ((eq (string-match "\\(.*\\)-\\([^-]*\\)-\\([^-]*\\).spec" file) 0)
cvsdist a8bb5f
      (setq name (match-string 1 file))
cvsdist a8bb5f
      (setq version (match-string 2 file))
cvsdist a8bb5f
      (setq release (match-string 3 file)))
cvsdist a8bb5f
     ((eq (string-match "\\(.*\\)-\\([^-]*\\).spec" file) 0)
cvsdist a8bb5f
      (setq name (match-string 1 file))
cvsdist a8bb5f
      (setq version (match-string 2 file)))
cvsdist a8bb5f
     ((eq (string-match "\\(.*\\).spec" file) 0)
cvsdist a8bb5f
      (setq name (match-string 1 file))))
cvsdist a8bb5f
    
cvsdist a8bb5f
    (insert
cvsdist a8bb5f
     "Summary: "
cvsdist a8bb5f
     "\nName: " (or name "")
cvsdist a8bb5f
     "\nVersion: " (or version "")
cvsdist a8bb5f
     "\nRelease: " (or release "")
cvsdist a8bb5f
     "\nURL: "
cvsdist a8bb5f
     "\nSource0: %{name}-%{version}.tar.gz"
cvsdist a8bb5f
     "\nLicense: \nGroup: "
cvsdist a8bb5f
     "\nBuildRoot: %{_tmppath}/%{name}-root"
cvsdist a8bb5f
     "\n\n%description\n"
cvsdist a8bb5f
     "\n%prep"
cvsdist a8bb5f
     "\n%setup -q"
cvsdist a8bb5f
     "\n\n%build"
cvsdist a8bb5f
     "\n\n%install"
cvsdist a8bb5f
     "\nrm -rf $RPM_BUILD_ROOT"
cvsdist a8bb5f
     "\n\n%clean"
cvsdist a8bb5f
     "\nrm -rf $RPM_BUILD_ROOT"
cvsdist a8bb5f
     "\n\n%files"
cvsdist a8bb5f
     "\n%defattr(-,root,root)\n" 
cvsdist a8bb5f
     "\n\n%changelog\n")
cvsdist a8bb5f
            
cvsdist a8bb5f
    (rpm-add-change-log-entry "Initial build.\n")))
cvsdist a8bb5f
cvsdist a8bb5f
;;------------------------------------------------------------
cvsdist a8bb5f
cvsdist a8bb5f
(defun rpm-about-rpm-spec-mode (&optional arg)
cvsdist a8bb5f
  "About rpm-spec-mode."
cvsdist a8bb5f
  (interactive "p")
cvsdist a8bb5f
  (message "Made by Stig Bjørlykke, <stigb@tihlde.org>"))
cvsdist a8bb5f
cvsdist a8bb5f
(provide 'rpm-spec-mode)
cvsdist a8bb5f
cvsdist a8bb5f
;;; rpm-spec-mode.el ends here