Compare commits

...

30 Commits
0.1.0 ... main

Author SHA1 Message Date
earnest ma e7aab11f9f
chore(ci): Use Woodpecker CI
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-04-27 18:36:20 -04:00
earnest ma 2271857b7c
chore: Update README
* Update LICENSE to 2022
* Migrated project sources to https://git.earne.link/earnestma/aptpkg
2022-04-27 18:36:20 -04:00
earnest ma a1cffdb13f
chore(release): aptpkg 1.1.0 2021-10-16 18:33:22 -04:00
earnest ma a9e21971fb
feat: -v / --version to show current version 2021-10-16 18:31:55 -04:00
earnest ma 93652c35a3
docs: Document short options as well 2021-10-16 18:31:29 -04:00
earnest ma aa417bebab
feat: --all to build all folders under directory 2021-10-16 18:30:39 -04:00
earnest ma 02bac12c49
docs: Document --auto needing aptpkg in PATH 2021-10-16 18:08:45 -04:00
earnest ma dd285f65a5
chore(release): aptpkg 1.0.1 2021-10-08 13:57:24 -04:00
earnest ma 161b78fd26
chore(docs): Update man pages
* Document $customcontrol
* Ability to skip checksum verification
2021-10-08 12:39:56 -04:00
earnest ma dc4d6244ae
fix: Homepage: $url should point to homepage
Not the first $source
2021-10-08 10:28:02 -04:00
earnest ma 78df941e99
chore(release): aptpkg 1.0.0 2021-10-08 09:23:56 -04:00
earnest ma a3ee2179ef
chore: Update README.md 2021-10-08 09:23:56 -04:00
earnest ma 0383db3690
chore: Add .gitignore 2021-10-07 22:06:30 -04:00
earnest ma 59b5b1c648
fix: Typo in Makefile 2021-10-07 22:05:34 -04:00
earnest ma 9faefc5d50
feat: Skip checksumming
Closes https://todo.sr.ht/~earnestma/aptpkg/4
2021-10-07 22:02:36 -04:00
earnest ma d5b93744a2
chore(docs): Use man pages
Also update CI, README and Makefile
2021-10-07 22:02:35 -04:00
earnest ma 627fc026d1
chore: Update README.md
* builds.sr.ht status: Only show commit statuses (no patch)
2021-10-06 22:12:22 -04:00
earnest ma 778acb4d76
chore(format): Spaces to tabs 2021-10-06 22:09:22 -04:00
earnest ma c209761d1e
feat: "aptpkg-auto-run" trailer for HEAD commit
To build files changed from provided commit hash before HEAD
2021-10-06 22:06:53 -04:00
earnest ma 64e09d296d
feat: Autobuild changed build files from git commit 2021-10-06 18:41:00 -04:00
earnest ma 3f23633dcc
aptpkg Version 0.2.1 2021-09-11 22:08:27 -04:00
earnest ma b083995b70
fix: Prevent error when there is no $customcontrol set
https://github.com/koalaman/shellcheck/wiki/SC2154
2021-09-11 22:05:12 -04:00
earnest ma 3589e04177
fix: sourcing build file
Weird? but works, and prevents shellcheck
2021-09-11 22:05:11 -04:00
earnest ma 854574657f
aptpkg Version 0.2.0 2021-09-06 21:48:01 -04:00
earnest ma 6affcdd5ec
README.md: Remove experimental badge, add ci badge 2021-09-06 21:42:36 -04:00
earnest ma 7cf4b7580e
Configure sourcehut builds 2021-09-06 21:41:02 -04:00
earnest ma 1d8426c13d
Add Makefile 2021-09-06 21:38:37 -04:00
earnest ma ff3f139265
Address shellcheck lint 2021-09-06 21:20:51 -04:00
earnest ma 1c5d190c83
Remove extra line break after help 2021-09-06 21:19:33 -04:00
earnest ma ccb9ffe2c4
Switch to /usr/bin/env bash instead of /usr/bin/bash
To work on NixOS
2021-08-03 11:35:53 -04:00
8 changed files with 261 additions and 38 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.1
*.5

20
.woodpecker.yml Normal file
View File

@ -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

View File

@ -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
this software and associated documentation files (the “Software”), to deal in

52
Makefile Normal file
View File

@ -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)

View File

@ -1,35 +1,27 @@
# 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
repository](https://git.sr.ht/~earnestma/aptpkg-pkgs)**
- **[aptpkg.earne.link Package archive setup/
info](https://man.sr.ht/~earnestma/aptpkg)**
**Please note:** I am not actively using or maintaining this project.
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
- ubuntu-dev-tools
- scdoc (build)
- dpkg, dpkg-dev
- git, wget, bash
- unzip, tar, ar, etc.
- unzip, tar, etc.
## Usage
See the [wiki](https://man.sr.ht/~earnestma/aptpkg) or run `./aptpkg --help` for
more information.
Run `aptpkg --help` or `man aptpkg` for more information.
## Contribute
Send patches to [this mailing
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)!
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!
## License
`aptpkg` is published under an MIT License. See the LICENSE file for copyright
and license details.
`aptpkg` is published under an MIT License. See the LICENSE file for copyright and license details.

91
aptpkg
View File

@ -1,7 +1,7 @@
#!/usr/bin/bash
#! /usr/bin/env bash
# Init variables
APTPKG_VERSION="0.1.0"
APTPKG_VERSION="1.1.0"
# Show help
show_help(){
@ -11,12 +11,14 @@ aptpkg v$APTPKG_VERSION
Easily create debian packages.
Documentation: https://man.sr.ht/~earnestma/aptpkg
For more documentation, run man aptpkg
Usage:
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 -v, --version Show version
EOF
}
@ -29,7 +31,9 @@ error_usage_die(){
# Verify sha512sums
verify(){
echo "$sha512sums" | sha512sum -c
if [ ! "${sha512sums:?}" = "SKIP" ]; then
echo "${sha512sums:?}" | sha512sum -c
fi
}
# Copy/ install wrapper for files
@ -51,36 +55,36 @@ check(){
# Generate the debian control file
gen_control_file(){
mkdir -p "$builddir"/DEBIAN
echo "Package: $name
Version: $version-$rev
echo "Package: ${name:?}
Version: ${version:?}-${rev:?}
Architecture: amd64
Maintainer: $(grep -am 1 -hr "Maintainer: " build | sed 's/# Maintainer: //')
Section:
Priority:
Homepage: $url
Description: $description
$customcontrol
Homepage: ${url:?}
Description: ${description:?}
${customcontrol:=}
" > "$builddir"/DEBIAN/control
}
# Download a debian package
build_deb(){
echo "Getting $source"
echo "Getting ${source:?}"
wget "$source" -qP dist/
( cd dist ; verify )
( cd dist || error_usage_die "Problem with the dist/ directory" && verify )
}
# Download and build using files
build_file(){
builddir=${name}_${version}-${rev}_amd64
cd "$1"
cd "$1" || error_usage_die "Problem with changing directory"
mkdir -p "$builddir"
for url in $source; do
for urls in $source; do
echo "Getting $source"
wget -q "$url"
wget -q "$urls"
done
verify
@ -94,7 +98,7 @@ build_file(){
[ -f $maintfile ] && cin-bin $maintfile "$builddir"/DEBIAN/$maintfile
done
cd -
cd - || error_usage_die "Problem with changing directory"
dpkg-deb --build --root-owner-group "$1"/"$builddir" dist/
}
@ -104,9 +108,10 @@ load_build(){
mkdir -p dist
# shellcheck disable=SC1090
source "$1/build"
# shellcheck disable=SC1091
source "${1:?}/build"
case "$type" in
case "${type:?}" in
deb)
build_deb ;;
file)
@ -114,10 +119,60 @@ load_build(){
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!
case $1 in
-h|--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
error_usage_die "You must provide one directory"

38
docs/aptpkg.1.scd Normal file
View File

@ -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

64
docs/aptpkg.5.scd Normal file
View File

@ -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