Compare commits
30 Commits
Author | SHA1 | Date |
---|---|---|
earnest ma | e7aab11f9f | |
earnest ma | 2271857b7c | |
earnest ma | a1cffdb13f | |
earnest ma | a9e21971fb | |
earnest ma | 93652c35a3 | |
earnest ma | aa417bebab | |
earnest ma | 02bac12c49 | |
earnest ma | dd285f65a5 | |
earnest ma | 161b78fd26 | |
earnest ma | dc4d6244ae | |
earnest ma | 78df941e99 | |
earnest ma | a3ee2179ef | |
earnest ma | 0383db3690 | |
earnest ma | 59b5b1c648 | |
earnest ma | 9faefc5d50 | |
earnest ma | d5b93744a2 | |
earnest ma | 627fc026d1 | |
earnest ma | 778acb4d76 | |
earnest ma | c209761d1e | |
earnest ma | 64e09d296d | |
earnest ma | 3f23633dcc | |
earnest ma | b083995b70 | |
earnest ma | 3589e04177 | |
earnest ma | 854574657f | |
earnest ma | 6affcdd5ec | |
earnest ma | 7cf4b7580e | |
earnest ma | 1d8426c13d | |
earnest ma | ff3f139265 | |
earnest ma | 1c5d190c83 | |
earnest ma | ccb9ffe2c4 |
|
@ -0,0 +1,2 @@
|
||||||
|
*.1
|
||||||
|
*.5
|
|
@ -0,0 +1,20 @@
|
||||||
|
branches: main # Ideally, only run on pushes to main branch and PRs
|
||||||
|
pipeline:
|
||||||
|
pull-request:
|
||||||
|
image: ubuntu:jammy
|
||||||
|
when:
|
||||||
|
event: [ pull_request ]
|
||||||
|
commands:
|
||||||
|
- apt -y update
|
||||||
|
- apt -y install dpkg dpkg-dev scdoc shellcheck
|
||||||
|
- make test
|
||||||
|
|
||||||
|
main:
|
||||||
|
image: ubuntu:jammy
|
||||||
|
when:
|
||||||
|
event: push
|
||||||
|
branch: main
|
||||||
|
commands:
|
||||||
|
- apt -y update
|
||||||
|
- apt -y install dpkg dpkg-dev scdoc shellcheck
|
||||||
|
- make test
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
||||||
Copyright © 2021 earnest ma <me@earne.link>
|
Copyright © 2021-2022 earnest ma <me@earne.link>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the “Software”), to deal in
|
this software and associated documentation files (the “Software”), to deal in
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
.POSIX:
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .1 .5 .1.scd .5.scd
|
||||||
|
|
||||||
|
PREFIX?=/usr/local
|
||||||
|
BINDIR?=$(PREFIX)/bin
|
||||||
|
MANDIR?=$(PREFIX)/share/man
|
||||||
|
|
||||||
|
# Exists in GNUMake but not in NetBSD make and others.
|
||||||
|
RM?=rm -f
|
||||||
|
|
||||||
|
RMDIR_IF_EMPTY:=sh -c '\
|
||||||
|
if test -d $$0 && ! ls -1qA $$0 | grep -q . ; then \
|
||||||
|
rmdir $$0; \
|
||||||
|
fi'
|
||||||
|
|
||||||
|
all: docs ## Build and generate files
|
||||||
|
|
||||||
|
docs: docs/aptpkg.1 docs/aptpkg.5 ## Generate docs
|
||||||
|
|
||||||
|
.1.scd.1:
|
||||||
|
scdoc < $< > $@
|
||||||
|
|
||||||
|
.5.scd.5:
|
||||||
|
scdoc < $< > $@
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: ## Remove generated files
|
||||||
|
$(RM) docs/aptpkg.1 docs/aptpkg.5
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help: ## Show this help
|
||||||
|
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: ## Install aptpkg
|
||||||
|
mkdir -m755 -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(MANDIR)/man5
|
||||||
|
install -m755 aptpkg $(DESTDIR)$(BINDIR)/aptpkg
|
||||||
|
install -m644 docs/aptpkg.1 $(DESTDIR)$(MANDIR)/man1/aptpkg.1
|
||||||
|
install -m644 docs/aptpkg.5 $(DESTDIR)$(MANDIR)/man5/aptpkg.5
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: ## Run shellcheck tests
|
||||||
|
shellcheck aptpkg
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall: ## Uninstall aptpkg
|
||||||
|
$(RM) $(DESTDIR)$(BINDIR)/aptpkg
|
||||||
|
$(RM) $(DESTDIR)$(MANDIR)/man1/aptpkg.1
|
||||||
|
$(RM) $(DESTDIR)$(MANDIR)/man5/aptpkg.5
|
||||||
|
${RMDIR_IF_EMPTY} $(DESTDIR)$(BINDIR)
|
||||||
|
${RMDIR_IF_EMPTY} $(DESTDIR)$(MANDIR)
|
30
README.md
30
README.md
|
@ -1,35 +1,27 @@
|
||||||
# aptpkg
|
# aptpkg
|
||||||
[![This project is considered experimental](https://img.shields.io/badge/Status-experimental-red.svg)](https://www.arp242.net/status/experimental)
|
|
||||||
[![sr.ht Project hub](https://img.shields.io/badge/sr.ht-Project%20hub-grey)](https://sr.ht/~earnestma/aptpkg)
|
|
||||||
|
|
||||||
- **[aptpkg.earne.link packaging git
|
**Please note:** I am not actively using or maintaining this project.
|
||||||
repository](https://git.sr.ht/~earnestma/aptpkg-pkgs)**
|
|
||||||
- **[aptpkg.earne.link Package archive setup/
|
|
||||||
info](https://man.sr.ht/~earnestma/aptpkg)**
|
|
||||||
|
|
||||||
Easily create debian packages.
|
- [packaging repo example](https://git.earne.link/earnestma/aptpkg-pkgs)
|
||||||
|
- [wiki page](https://git.earne.link/earnestma/aptpkg/wiki)
|
||||||
|
|
||||||
|
aptpkg can be used to easily create/ get debian packages, and can be used with a tool such as **reprepro**(1).
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- ubuntu-dev-tools
|
- scdoc (build)
|
||||||
|
- dpkg, dpkg-dev
|
||||||
- git, wget, bash
|
- git, wget, bash
|
||||||
- unzip, tar, ar, etc.
|
- unzip, tar, etc.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
See the [wiki](https://man.sr.ht/~earnestma/aptpkg) or run `./aptpkg --help` for
|
Run `aptpkg --help` or `man aptpkg` for more information.
|
||||||
more information.
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
Send patches to [this mailing
|
Creating [issues](https://git.earne.link/earnestma/aptpkg/issues), [discussion](https://discuss.earne.link/t/earnest), or [pull requests](https://git.earne.link/earnestma/aptpkg/pulls) are welcome!
|
||||||
list](https://lists.sr.ht/~earnestma/aptpkg-devel); you can follow [this
|
|
||||||
guide](https://git-send-email.io) if you don't know how.
|
|
||||||
|
|
||||||
File **confirmed** bugs/ feature requests
|
|
||||||
[here](https://todo.sr.ht/~earnestma/aptpkg)!
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
`aptpkg` is published under an MIT License. See the LICENSE file for copyright
|
`aptpkg` is published under an MIT License. See the LICENSE file for copyright and license details.
|
||||||
and license details.
|
|
||||||
|
|
91
aptpkg
91
aptpkg
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
# Init variables
|
# Init variables
|
||||||
APTPKG_VERSION="0.1.0"
|
APTPKG_VERSION="1.1.0"
|
||||||
|
|
||||||
# Show help
|
# Show help
|
||||||
show_help(){
|
show_help(){
|
||||||
|
@ -11,12 +11,14 @@ aptpkg v$APTPKG_VERSION
|
||||||
|
|
||||||
Easily create debian packages.
|
Easily create debian packages.
|
||||||
|
|
||||||
Documentation: https://man.sr.ht/~earnestma/aptpkg
|
For more documentation, run man aptpkg
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
aptpkg [directory]
|
aptpkg [directory]
|
||||||
|
aptpkg --all [directory] Build all folders under directory
|
||||||
|
aptpkg --auto (commit id) Autobuild modified packages from commit
|
||||||
aptpkg -h, --help Show help
|
aptpkg -h, --help Show help
|
||||||
|
aptpkg -v, --version Show version
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +31,9 @@ error_usage_die(){
|
||||||
|
|
||||||
# Verify sha512sums
|
# Verify sha512sums
|
||||||
verify(){
|
verify(){
|
||||||
echo "$sha512sums" | sha512sum -c
|
if [ ! "${sha512sums:?}" = "SKIP" ]; then
|
||||||
|
echo "${sha512sums:?}" | sha512sum -c
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copy/ install wrapper for files
|
# Copy/ install wrapper for files
|
||||||
|
@ -51,36 +55,36 @@ check(){
|
||||||
# Generate the debian control file
|
# Generate the debian control file
|
||||||
gen_control_file(){
|
gen_control_file(){
|
||||||
mkdir -p "$builddir"/DEBIAN
|
mkdir -p "$builddir"/DEBIAN
|
||||||
echo "Package: $name
|
echo "Package: ${name:?}
|
||||||
Version: $version-$rev
|
Version: ${version:?}-${rev:?}
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Maintainer: $(grep -am 1 -hr "Maintainer: " build | sed 's/# Maintainer: //')
|
Maintainer: $(grep -am 1 -hr "Maintainer: " build | sed 's/# Maintainer: //')
|
||||||
Section:
|
Section:
|
||||||
Priority:
|
Priority:
|
||||||
Homepage: $url
|
Homepage: ${url:?}
|
||||||
Description: $description
|
Description: ${description:?}
|
||||||
$customcontrol
|
${customcontrol:=}
|
||||||
" > "$builddir"/DEBIAN/control
|
" > "$builddir"/DEBIAN/control
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download a debian package
|
# Download a debian package
|
||||||
build_deb(){
|
build_deb(){
|
||||||
echo "Getting $source"
|
echo "Getting ${source:?}"
|
||||||
wget "$source" -qP dist/
|
wget "$source" -qP dist/
|
||||||
|
|
||||||
( cd dist ; verify )
|
( cd dist || error_usage_die "Problem with the dist/ directory" && verify )
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download and build using files
|
# Download and build using files
|
||||||
build_file(){
|
build_file(){
|
||||||
builddir=${name}_${version}-${rev}_amd64
|
builddir=${name}_${version}-${rev}_amd64
|
||||||
|
|
||||||
cd "$1"
|
cd "$1" || error_usage_die "Problem with changing directory"
|
||||||
mkdir -p "$builddir"
|
mkdir -p "$builddir"
|
||||||
|
|
||||||
for url in $source; do
|
for urls in $source; do
|
||||||
echo "Getting $source"
|
echo "Getting $source"
|
||||||
wget -q "$url"
|
wget -q "$urls"
|
||||||
done
|
done
|
||||||
|
|
||||||
verify
|
verify
|
||||||
|
@ -94,7 +98,7 @@ build_file(){
|
||||||
[ -f $maintfile ] && cin-bin $maintfile "$builddir"/DEBIAN/$maintfile
|
[ -f $maintfile ] && cin-bin $maintfile "$builddir"/DEBIAN/$maintfile
|
||||||
done
|
done
|
||||||
|
|
||||||
cd -
|
cd - || error_usage_die "Problem with changing directory"
|
||||||
|
|
||||||
dpkg-deb --build --root-owner-group "$1"/"$builddir" dist/
|
dpkg-deb --build --root-owner-group "$1"/"$builddir" dist/
|
||||||
}
|
}
|
||||||
|
@ -104,9 +108,10 @@ load_build(){
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$1/build"
|
# shellcheck disable=SC1091
|
||||||
|
source "${1:?}/build"
|
||||||
|
|
||||||
case "$type" in
|
case "${type:?}" in
|
||||||
deb)
|
deb)
|
||||||
build_deb ;;
|
build_deb ;;
|
||||||
file)
|
file)
|
||||||
|
@ -114,10 +119,60 @@ load_build(){
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Autobuild packages based on git list files changed in commit
|
||||||
|
# latest (HEAD) assumed if commit hash not provided
|
||||||
|
change_autobuild_pkgs(){
|
||||||
|
[ -d .git ] || error_usage_die "Current directory is not a git repository!"
|
||||||
|
|
||||||
|
commitid=$1
|
||||||
|
[ -n "$commitid" ] || commitid=HEAD
|
||||||
|
|
||||||
|
if [[ "$commitid" = HEAD ]]; then
|
||||||
|
before_run=$(git log HEAD^..HEAD | grep aptpkg-auto-run | sed 's#aptpkg-auto-run: ##' | sed 's# ##')
|
||||||
|
|
||||||
|
if [ -n "$before_run" ]; then
|
||||||
|
for m in $before_run; do
|
||||||
|
build_chg_pre=$(git diff-tree --no-commit-id --name-only -r "$m" | grep "build" | sed 's#/build##')
|
||||||
|
echo "Using $m with files $build_chg_pre"
|
||||||
|
|
||||||
|
for a in $build_chg_pre; do
|
||||||
|
aptpkg "$a"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_chg=$(git diff-tree --no-commit-id --name-only -r $commitid | grep "build" | sed 's#/build##')
|
||||||
|
echo "Using $commitid with files $build_chg"
|
||||||
|
|
||||||
|
for f in $build_chg; do
|
||||||
|
aptpkg "$f"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build all in directory
|
||||||
|
build_all_in_dir(){
|
||||||
|
[ -d "$1" ] || error_usage_die "Provide a directory"
|
||||||
|
buildfile_folders=$(ls -d "$1"/*)
|
||||||
|
|
||||||
|
for ww in $buildfile_folders; do
|
||||||
|
printf "\nBuilding %s\n\n" "$ww"
|
||||||
|
aptpkg "$ww"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Run!
|
# Run!
|
||||||
case $1 in
|
case $1 in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
show_help ;;
|
show_help ;;
|
||||||
|
--all)
|
||||||
|
shift
|
||||||
|
build_all_in_dir "$1" ;;
|
||||||
|
--auto)
|
||||||
|
shift
|
||||||
|
change_autobuild_pkgs "$1" ;;
|
||||||
|
-v|--version)
|
||||||
|
echo "aptpkg $APTPKG_VERSION" ;;
|
||||||
*)
|
*)
|
||||||
if [ $# -ne 1 ]; then
|
if [ $# -ne 1 ]; then
|
||||||
error_usage_die "You must provide one directory"
|
error_usage_die "You must provide one directory"
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
aptpkg(1)
|
||||||
|
|
||||||
|
# NAME
|
||||||
|
|
||||||
|
aptpkg - easily create/ get debian packages
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
|
||||||
|
*aptpkg* _path_
|
||||||
|
|
||||||
|
*aptpkg* --all _path_
|
||||||
|
|
||||||
|
*aptpkg* --auto [git commit hash]
|
||||||
|
|
||||||
|
*aptpkg* -h | --help
|
||||||
|
|
||||||
|
*aptpkg* -v | --version
|
||||||
|
|
||||||
|
# DESCRIPTION
|
||||||
|
|
||||||
|
aptpkg can be used to easily create/ get debian packages, and can be used with
|
||||||
|
a tool such as *reprepro*(1).
|
||||||
|
|
||||||
|
Provide aptpkg with a path to a folder containing an *aptpkg*(5) build file.
|
||||||
|
The --auto option can also be used to build modified packages based on a git
|
||||||
|
commit hash, using _HEAD_ if one is not provided. The aptpkg script *must* be
|
||||||
|
available in $PATH.
|
||||||
|
|
||||||
|
For mass rebuilds, aptpkg --auto can be used, passing a directory with folders
|
||||||
|
under which the build files are located.
|
||||||
|
|
||||||
|
# SEE ALSO
|
||||||
|
|
||||||
|
*aptpkg*(5)
|
||||||
|
|
||||||
|
# AUTHORS
|
||||||
|
|
||||||
|
https://git.earne.link/earnestma/aptpkg
|
|
@ -0,0 +1,64 @@
|
||||||
|
aptpkg(5)
|
||||||
|
|
||||||
|
# NAME
|
||||||
|
|
||||||
|
aptpkg - file format reference
|
||||||
|
|
||||||
|
# SYNTAX
|
||||||
|
|
||||||
|
The file must be named _build_ and placed in a directory named the program.
|
||||||
|
|
||||||
|
## MAINTAINERS
|
||||||
|
|
||||||
|
The first line should start like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Maintainer: Name <email@example.org>
|
||||||
|
```
|
||||||
|
|
||||||
|
More maintainers can be listed after.
|
||||||
|
|
||||||
|
## COMMON
|
||||||
|
|
||||||
|
- name: Name of the package
|
||||||
|
- version: Version number
|
||||||
|
- rev: Revision number (often 0, only useful if type=file)
|
||||||
|
- type
|
||||||
|
- type=deb: Debian package that will be downloaded and checked
|
||||||
|
- type=file: Download file(s), check, and execute the _steps_ function
|
||||||
|
- url: Homepage of upstream
|
||||||
|
- description: Description similar to what upstream says
|
||||||
|
- customcontrol: This is optional and only if extra information needs to be
|
||||||
|
added to the control file
|
||||||
|
|
||||||
|
## SOURCE
|
||||||
|
|
||||||
|
Provide URL(s) pointing to the file(s) to download
|
||||||
|
|
||||||
|
## SHA512SUMS
|
||||||
|
|
||||||
|
The output of `sha512sum filename` that will be used to verify. Write SKIP if
|
||||||
|
you do not want any verification done.
|
||||||
|
|
||||||
|
## STEPS
|
||||||
|
|
||||||
|
Steps to extract and "install" the package
|
||||||
|
|
||||||
|
- $builddir: The root directory
|
||||||
|
- cin-bin: Install an executable file (with permissions 755)
|
||||||
|
- cin-file: Install a file (with permissions 644)
|
||||||
|
|
||||||
|
## MAINTAINER SCRIPTS
|
||||||
|
|
||||||
|
Maintainer scripts can be placed along _build_: examples include preinst,
|
||||||
|
postinst, prerm, and postrm
|
||||||
|
|
||||||
|
# SEE ALSO
|
||||||
|
|
||||||
|
*aptpkg*(1)
|
||||||
|
|
||||||
|
Some good packaging file examples: https://git.earne.link/earnestma/aptpkg-pkgs
|
||||||
|
|
||||||
|
# AUTHORS
|
||||||
|
|
||||||
|
https://git.earne.link/earnestma/aptpkg
|
Loading…
Reference in New Issue