diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3ee2fec --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,73 @@ +name: Compile and Publish genext2fs + +on: + push: + branches: + - master + - main + +jobs: + build: + runs-on: ubuntu-20.04 + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get next version + uses: reecetech/version-increment@2023.10.1 + id: version + with: + use_api: true + + - name: Build + run: | + docker run --rm -v $PWD:/app/src -w /app/src ubuntu:20.04 bash -c " \ + export DEBIAN_FRONTEND=noninteractive; \ + sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list; \ + apt-get update && apt-get install -y devscripts build-essential lintian debhelper wget libarchive-dev && \ + apt-get build-dep -y genext2fs && \ + wget http://deb.debian.org/debian/pool/main/g/genext2fs/genext2fs_1.5.0.orig.tar.gz && \ + mv genext2fs_1.5.0.orig.tar.gz ../ && \ + debuild -S -us -uc; \ + debuild -us -uc; \ + mv ../genext2fs_*.deb ./genext2fs.deb; \ + " + + - name: Save package + uses: actions/upload-artifact@v3 + with: + name: genext2fs + path: build + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.v-version }} + release_name: Release ${{ steps.version.outputs.v-version }} ${{ github.ref }} + body: | + Release ${{ steps.version.outputs.v-version }} @${{ github.ref }} + draft: true + prerelease: false + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./genext2fs.deb + asset_name: genext2fs.deb + asset_content_type: application/gzip + + - name: Publish release + uses: StuYarrow/publish-release@v1.1.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + id: ${{ steps.create_release.outputs.id }} diff --git a/debian/changelog b/debian/changelog index 53248f0..fac5ca6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,250 @@ +genext2fs (1.5.0-3ubuntu1) UNRELEASED; urgency=medium + + * Skip device if parent is a file and not a dir + + -- Zak Estrada Sat, 16 Dec 2023 09:07:13 -0500 + +genext2fs (1.5.0-3) unstable; urgency=medium + + * debian/tests/control: run wrap-and-sort -astb + * debian/control: make Multi-Arch:foreign + + -- Johannes Schauer Marin Rodrigues Mon, 19 Sep 2022 06:05:48 +0200 + +genext2fs (1.5.0-2) unstable; urgency=medium + + [ Balint Reczey ] + * debian/tests/general: Don't follow symlinks in result comparison + (LP: #1910549) + + [ Debian Janitor ] + * Remove constraints unnecessary since buster + + [ Johannes Schauer Marin Rodrigues ] + * fix up my name in d/copyright and d/control + * Enable system locale - change from the standard (C) to system locale. + + -- Johannes Schauer Marin Rodrigues Sun, 26 Dec 2021 22:17:34 +0100 + +genext2fs (1.5.0-1) unstable; urgency=medium + + [ Debian Janitor ] + * Set upstream metadata fields: Bug-Database, Bug-Submit. + + [ Johannes 'josch' Schauer ] + * new upstream version + * add debian/watch + * drop patches + * debian/tests/general: adjust new tarball on stdin interface + * debian/control: bump dh compat to 13 + * debian/upstream/metadata: add Repository and Repository-Browse fields + + -- Johannes 'josch' Schauer Fri, 26 Jun 2020 10:11:37 +0200 + +genext2fs (1.4.2-3) unstable; urgency=medium + + * debian/tests/general: export LIBGUESTFS_BACKEND_SETTINGS=force_tcg as + workaround for #958751 (closes: #958733) + + -- Johannes 'josch' Schauer Sat, 25 Apr 2020 00:50:27 +0200 + +genext2fs (1.4.2-2) unstable; urgency=medium + + * debian/tests/control: make kernel image architecture-specific + + -- Johannes 'josch' Schauer Thu, 09 Apr 2020 23:54:45 +0200 + +genext2fs (1.4.2-1) unstable; urgency=medium + + * new upstream version (closes: #954871) + * debian/control: Adopting package with previous maintainer consent + * debian/control: bump standards-version (no changes) + * debian/control: add Rules-Requires-Root:no + * debian/control: change vcs fields to salsa + * debian/rules: add DEB_BUILD_MAINT_OPTIONS = hardening=+all + * debian/control: add Homepage field + * debian/copyright: use dep5 + * debian/rules: remove old cruft (newer debhelper runs autoreconf for us) + * debian/rules: run test.sh (except with nocheck) + * add patches from upstream pull requests: + - support SOURCE_DATE_EPOCH + - allow tarballs on stdin + - support changing permissions of / + * add autopkgtest + * run wrap-and-sort -asbt + * remove debian/watch: project moved to github without release tags + + -- Johannes 'josch' Schauer Wed, 08 Apr 2020 10:08:50 +0200 + +genext2fs (1.4.1-4) unstable; urgency=low + + * debian/patches/byteswap_fix.diff: New patch by Samuel Thibault, + fix a segfault in the byte swapping code on little-endian architectures + (closes: 644776). + + -- Jérémie Koenig Tue, 29 Nov 2011 17:42:14 +0100 + +genext2fs (1.4.1-3) unstable; urgency=low + + * New maintainer (closes: 579369). + * Packaging cleanup: + - update autotools dependencies; + - update to debhelper 8; + - switch to source format 3.0 (quilt); + - bump Standards-Version to 3.9.2. + * debian/patches/blocksize+creator.diff: New patch, add options -B and -o + to select the block size and creator OS (closes: 562999). + * Add Vcs-Git and Vcs-Browser fields to debian/control. + * Add debian/gbp.conf (configuration for git-buildpackage). + + -- Jérémie Koenig Sat, 03 Sep 2011 21:35:48 +0200 + +genext2fs (1.4.1-2.2) unstable; urgency=low + + * Non-maintainer upload. + * Build depend on automake instead of automake1.4. (Closes: #549097). + * Version GPL version in debian/copyright. + * Bump Standards Version to 3.8.3. + + -- Barry deFreese Wed, 30 Sep 2009 14:49:16 -0400 + +genext2fs (1.4.1-2.1) unstable; urgency=low + + * Non-Maintainer Upload, at BSP in Zurich + * in sscanf the "a" could mean "malloc" or the new C99 floating, + so don't use it, not to have surprises. + + -- Giacomo Catenazzi Sat, 12 Jan 2008 23:03:59 +0100 + +genext2fs (1.4.1-2) unstable; urgency=low + + * configure.in: Change AC_CONFIG_HEADER to AM_CONFIG_HEADER. + + -- Franz Pletz Sun, 29 Jul 2007 19:13:04 +0200 + +genext2fs (1.4.1-1) unstable; urgency=low + + * New upstream release. (Closes: #406078) + * clean.sh: updated. + * Switch to debhelper 5. + + -- Franz Pletz Sun, 29 Jul 2007 19:10:18 +0200 + +genext2fs (1.4-rc1-2.1) unstable; urgency=low + + * Non-maintainer upload. + * FTBFS: Cannot satisfy Build-Depends on automake (Closes: #395150) + + -- Neil Williams Fri, 27 Oct 2006 19:08:55 +0100 + +genext2fs (1.4-rc1-2) unstable; urgency=low + + * Fixed description (Closes: #371083) + + -- Franz Pletz Mon, 26 Jun 2006 10:50:19 +0200 + +genext2fs (1.4-rc1-1) unstable; urgency=low + + * New upstream release, removed cvs blurb from diff. + * debian/control: + - New Maintainer. (Closes: #369191) + - Tweaked Description. + - Bumped Standards-Version to 3.7.2, no further changes necessary. + * Updated debian/changelog. + * debian/rules: + - Moved debhelper compatibility level setting to debian/compat. + - Miscellaneous minor cleanups. + * Added debian/watch. + + -- Franz Pletz Sun, 28 May 2006 15:47:23 +0200 + +genext2fs (1.3-10) unstable; urgency=low + + * Add build depends on automake and autoconf. (Closes: #341750) + + -- David Kimdon Mon, 5 Dec 2005 18:09:00 -0800 + +genext2fs (1.3-9) unstable; urgency=low + + * chmod +x clean.sh before running it. (Closes: #341457) + + -- David Kimdon Thu, 1 Dec 2005 17:45:34 -0800 + +genext2fs (1.3-8) unstable; urgency=low + + * Update to upstream cvs as of 29-11-2005. This is similar to what 1.4 + will be. + Preserve permissions. (Closes: #341173) + Create lost+found (Closes: #258661) + + -- David Kimdon Tue, 29 Nov 2005 11:12:31 -0800 + +genext2fs (1.3-7.1) unstable; urgency=high + + * Non-maintainer upload. + * Apply patch from Finn Thain to fix byteswapping code issues that broke + d-i on several arches. Thanks. (Closes: #266039) + + -- Joshua Kwan Tue, 24 Aug 2004 19:09:01 -0700 + +genext2fs (1.3-7) unstable; urgency=low + + * Fix block count rounding. The -b switch again specifies the + size of the resulting filesystem image. + Patch thanks to Finn Thain + (closes: #262352) + + -- David Kimdon Sat, 7 Aug 2004 09:51:37 +0200 + +genext2fs (1.3-6) unstable; urgency=low + + * Fix block counts, now created image fsck clean. (closes: #232023) + Thanks to Finn Thain for the fix. + + -- David Kimdon Sat, 10 Jul 2004 17:37:17 +0200 + +genext2fs (1.3-5) unstable; urgency=low + + * - Compile with -O2. + - get_workblk() should return zero'd memory. This way we get + nul terminations in the produced image. + - get_workblk() now allocates the block dynamically on the heap. + The previous method of allocating the block as 'static' apparently + results in undefined behavior since get_workblk() is 'inline'. + Thanks to Vincent Sanders for the patch. + (closes: #248987) + + -- David Kimdon Sat, 15 May 2004 19:37:54 +0200 + +genext2fs (1.3-4) unstable; urgency=low + + * Fix assertion failure when there is a 268K file on the + filesystem. Patch thanks to Matt Kraai + (closes: #201277) + + -- David Kimdon Mon, 17 Nov 2003 22:53:15 +0100 + +genext2fs (1.3-3) unstable; urgency=low + + * Update to current upstream cvs + - support triple indirect blocks (removes 8MB limit) + - support for groups. + + -- David Kimdon Sat, 11 Jan 2003 18:45:58 -0800 + +genext2fs (1.3-2) unstable; urgency=low + + * apply fix from upstream cvs that appears to fix endian bug + (closes: #122411) + * mention filesystem size limit in manpage (closes: #122729) + * mention that hard links are not supported in manpage + (closes: #155464) + * add sanity check at the end of the build + + -- David Kimdon Fri, 8 Mar 2002 23:17:36 -0800 + genext2fs (1.3-1) unstable; urgency=low * Initial Release. (closes: #105263) -- David Kimdon Sat, 14 Jul 2001 13:24:49 -0700 - -Local variables: -mode: debian-changelog -End: diff --git a/debian/control b/debian/control index 10ba604..02eb103 100644 --- a/debian/control +++ b/debian/control @@ -1,19 +1,28 @@ Source: genext2fs Section: admin Priority: optional -Maintainer: David Kimdon -Build-Depends: debhelper (>> 3.0.0) -Standards-Version: 3.5.2 +Maintainer: Johannes Schauer Marin Rodrigues +Vcs-Git: https://salsa.debian.org/debian/genext2fs.git +Vcs-Browser: https://salsa.debian.org/debian/genext2fs +Build-Depends: + autoconf, + automake, + debhelper-compat (= 12), + libarchive-dev, +Build-Conflicts: + autoconf2.13, +Standards-Version: 4.5.0 +Rules-Requires-Root: no +Homepage: https://github.com/bestouff/genext2fs Package: genext2fs Architecture: any -Depends: ${shlibs:Depends} +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Multi-Arch: foreign Description: ext2 filesystem generator for embedded systems - `genext2fs' is meant to generate an ext2 filesystem - as a normal (non-root) user. It doesn't require you to mount - the image file to copy files on it. It doesn't even require - you to be the superuser to make device nodes. - . - Warning ! `genext2fs' has been designed for embedded - systems. As such, it will generate a filesystem for single-user - usage: all files/directories/etc... will belong to UID/GID 0 + genext2fs is meant to generate an ext2 filesystem as a normal + (non-root) user. It doesn't require you to mount the image file + to copy files on it. It doesn't even require you to be the + superuser to make device nodes. diff --git a/debian/copyright b/debian/copyright index 559efdf..b474668 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,15 +1,27 @@ -This package was debianized by David Kimdon on -Sat, 14 Jul 2001 13:24:49 -0700. +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: genext2fs +Upstream-Contact: Xavier Bestel +Source: https://github.com/bestouff/genext2fs -It was downloaded from http://freshmeat.net/projects/genext2fs/ -Upstream Author(s): Xavier Bestel +Files: * +Copyright: 1999 - 2000 Lineo, inc. and John Beppu + 1999 - 2001 John Beppu + 2000 - 2019 Xavier Bestel + 2002 Edward Betts + 2002 Ixia communications +License: GPL-2 -Copyright (C) 2000 Xavier Bestel +Files: debian/* +Copyright: 2020, Johannes Schauer Marin Rodrigues + 2011, Jérémie Koenig + 2006, Franz Pletz + 2001, David Kimdon +License: GPL-2 -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; version -2 of the License. - -On Debian systems, the complete text of the GNU General Public -License can be found in /usr/share/common-licenses/GPL file. +License: GPL-2 + 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; version 2. + . + On Debian systems, the complete text of version 2 of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-2' diff --git a/debian/patches/0001-Enable-system-locale-change-from-the-standard-C-to-s.patch b/debian/patches/0001-Enable-system-locale-change-from-the-standard-C-to-s.patch new file mode 100644 index 0000000..2ff3dbc --- /dev/null +++ b/debian/patches/0001-Enable-system-locale-change-from-the-standard-C-to-s.patch @@ -0,0 +1,66 @@ +From 6909cdeca83d1b1057dd50f2cc55cbd95b1d8cd2 Mon Sep 17 00:00:00 2001 +From: Johannes Schauer Marin Rodrigues +Date: Sun, 26 Dec 2021 22:12:10 +0100 +Subject: [PATCH] Enable system locale - change from the standard (C) to system + locale. + +This allows libarchive (in case it is activated) to handle filenames. +We only change LC_CTYPE since libarchive only needs the charset set. +We don't use LC_ALL because it causes problems on some systems. +We restore the original LC_CTYPE after extraction to avoid side effects. +We use uselocale instead of setlocale to avoid setting LC_CTYPE globally. +See on libarchive Website for a more complete description of the issue: + https://github.com/libarchive/libarchive/issues/587 + https://github.com/libarchive/libarchive/wiki/Filenames + https://github.com/sbabic/swupdate/blob/master/handlers/archive_handler.c#L94 +--- + genext2fs.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/genext2fs.c b/genext2fs.c +index 96bbb43..f0b4c77 100644 +--- a/genext2fs.c ++++ b/genext2fs.c +@@ -151,6 +151,7 @@ + #ifdef HAVE_LIBARCHIVE + #include + #include ++#include + #endif + + #include "cache.h" +@@ -2475,6 +2476,22 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids, + char *path2, *path3, *dir, *name, *lnk; + size_t filesize; + uint32 uid, gid, mode, ctime, mtime; ++ locale_t archive_locale; ++ locale_t old_locale; ++ /* ++ * Enable system locale - change from the standard (C) to system locale. ++ * This allows libarchive (in case it is activated) to handle filenames. ++ * We only change LC_CTYPE since libarchive only needs the charset set. ++ * We don't use LC_ALL because it causes problems on some systems. ++ * We restore the original LC_CTYPE after extraction to avoid side effects. ++ * We use uselocale instead of setlocale to avoid setting LC_CTYPE globally. ++ * See on libarchive Website for a more complete description of the issue: ++ * https://github.com/libarchive/libarchive/issues/587 ++ * https://github.com/libarchive/libarchive/wiki/Filenames ++ * https://github.com/sbabic/swupdate/blob/master/handlers/archive_handler.c#L94 ++ */ ++ archive_locale = newlocale(LC_CTYPE_MASK, "", (locale_t)0); ++ old_locale = uselocale(archive_locale); + a = archive_read_new(); + if (a == NULL) + error_msg_and_die("Couldn't create archive reader."); +@@ -2596,6 +2613,8 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids, + } + archive_read_close(a); + archive_read_free(a); ++ uselocale(old_locale); ++ freelocale(archive_locale); + #endif + } + +-- +2.33.0 + diff --git a/debian/patches/0002-Skip-if-parent-is-dev.patch b/debian/patches/0002-Skip-if-parent-is-dev.patch new file mode 100644 index 0000000..ca08cf7 --- /dev/null +++ b/debian/patches/0002-Skip-if-parent-is-dev.patch @@ -0,0 +1,67 @@ +Description: + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + genext2fs (1.5.0-3ubuntu1) UNRELEASED; urgency=medium + . + * Skip device if parent is a file and not a dir +Author: Zak Estrada + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: , +Bug: +Bug-Debian: https://bugs.debian.org/ +Bug-Ubuntu: https://launchpad.net/bugs/ +Forwarded: +Reviewed-By: +Last-Update: 2023-12-16 + +--- genext2fs-1.5.0.orig/genext2fs.c ++++ genext2fs-1.5.0/genext2fs.c +@@ -2648,6 +2648,8 @@ add2fs_from_file(filesystem *fs, uint32 + size_t len; + struct stat st; + int nbargs, lineno = 0; ++ nod_info *ni; ++ inode *pnode; + + fstat(fileno(fh), &st); + ctime = fs_timestamp; +@@ -2703,6 +2705,14 @@ add2fs_from_file(filesystem *fs, uint32 + { + error_msg("device table line %d skipped: can't find directory '%s' to create '%s''", lineno, dir, name); + continue; ++ } else { ++ pnode = get_nod(fs, nod, &ni); ++ if((pnode->i_mode & FM_IFMT) != FM_IFDIR) { ++ error_msg("device table line %d skipped: parent '%s' is not a directory so won't create '%s''", lineno, dir, name); ++ put_nod(ni); ++ continue; ++ } ++ put_nod(ni); + } + } + else +@@ -3871,13 +3881,13 @@ main(int argc, char **argv) + if (strcmp(layers[i].path, "-") == 0) + numstdin++; + if (numstdin == 1 && nbinodes == -1 && bytes_per_inode == -1) +- fprintf(stderr, "Cannot count the required inodes for input from stdin -- use the -N or -i options to set the number of inodes or work with temporary files."); ++ fprintf(stderr, "Cannot count the required inodes for input from stdin -- use the -N or -i options to set the number of inodes or work with temporary files.\n"); + if (numstdin > 1) + error_msg_and_die("only one input can come from stdin"); + + if(fsin) + { +- fprintf(stderr, "starting from existing image %s", fsin); ++ fprintf(stderr, "starting from existing image %s\n", fsin); + if(strcmp(fsin, "-")) + { + FILE * fh = xfopen(fsin, "rb"); diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..5f59084 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,2 @@ +0001-Enable-system-locale-change-from-the-standard-C-to-s.patch +0002-Skip-if-parent-is-dev.patch diff --git a/debian/rules b/debian/rules index f729e50..19cf063 100755 --- a/debian/rules +++ b/debian/rules @@ -1,69 +1,15 @@ #!/usr/bin/make -f -# Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 +export DEB_BUILD_MAINT_OPTIONS = hardening=+all -# This is the debhelper compatability version to use. -export DH_COMPAT=2 +%: + dh $@ -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - # ./configure --prefix=/usr --mandir=/usr/share/man/ +override_dh_auto_configure: + dh_auto_configure -- --enable-libarchive - touch configure-stamp - -build: configure-stamp build-stamp -build-stamp: - dh_testdir - - # Add here commands to compile the package. - $(MAKE) - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - -$(MAKE) clean - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/genext2fs. - $(MAKE) install DESTDIR=`pwd`/debian/genext2fs - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installdocs - dh_installchangelogs - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + ./test.sh +endif + dh_auto_test diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml new file mode 100644 index 0000000..892f3cd --- /dev/null +++ b/debian/salsa-ci.yml @@ -0,0 +1,3 @@ +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 0000000..f76543a --- /dev/null +++ b/debian/source/options @@ -0,0 +1 @@ +extend-diff-ignore = "^\.github/" diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..fbfa1f6 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,9 @@ +Tests: general +Restrictions: allow-stderr, needs-root +Depends: + debootstrap, + libguestfs-tools, + linux-image-amd64 [amd64], + linux-image-arm64 [arm64], + linux-image-powerpc64le [ppc64el], + @, diff --git a/debian/tests/general b/debian/tests/general new file mode 100644 index 0000000..b4d9320 --- /dev/null +++ b/debian/tests/general @@ -0,0 +1,85 @@ +#!/bin/sh + +set -exu + +export SOURCE_DATE_EPOCH=$(date +%s) + +if [ "$(dpkg --print-architecture)" != amd64 ]; then + echo "export LIBGUESTFS_BACKEND_SETTINGS=force_tcg as workaround for #958751">&2 + export LIBGUESTFS_BACKEND_SETTINGS=force_tcg +fi + +debootstrap --variant=minbase unstable rootfs.in +tar --numeric-owner --sort=name -C rootfs.in -cf rootfs.in.tar . +numblocks=$(du --apparent-size --block-size 1024 --summarize rootfs.in | cut -f 1) +# add 5% more blocks than strictly needed +numblocks=$((numblocks+numblocks/10)) + +genext2fs -B 1024 -b $numblocks -d rootfs.in rootfs.dir.img +rm -rf rootfs.in + +genext2fs -B 1024 -b $numblocks -i 16384 -a - rootfs.tar.img < rootfs.in.tar +genext2fs -B 1024 -b $numblocks -i 16384 -a - rootfs2.tar.img < rootfs.in.tar + +# make sure that SOURCE_DATE_EPOCH was respected and images are bit-by-bit identical +cmp rootfs.tar.img rootfs2.tar.img +rm rootfs2.tar.img + +for img in rootfs.dir.img rootfs.tar.img; do + guestfish add-ro "$img" : run : mount /dev/sda / : tar-out / rootfs.tar + + mkdir rootfs.in + tar -C rootfs.in -xf rootfs.in.tar + + mkdir rootfs.out + tar -C rootfs.out -xf rootfs.tar + rm rootfs.tar + rmdir rootfs.out/lost+found + + # diff cannot compare device nodes, so we use tar to do that for us and then + # delete the directory + tar --numeric-owner --sort=name -C rootfs.in -cf dev1.tar ./dev + tar --numeric-owner --sort=name -C rootfs.out -cf dev2.tar ./dev + ret=0 + cmp dev1.tar dev2.tar || ret=$? + if [ "$ret" -ne 0 ]; then + if type diffoscope >/dev/null; then + diffoscope dev1.tar dev2.tar + exit 1 + else + echo "no diffoscope installed" >&2 + fi + if type base64 >/dev/null; then + base64 dev1.tar + base64 dev2.tar + exit 1 + else + echo "no base64 installed" >&2 + fi + if type xxd >/dev/null; then + xxd dev1.tar + xxd dev2.tar + exit 1 + else + echo "no xxd installed" >&2 + fi + exit 1 + fi + rm dev1.tar dev2.tar + rm -r rootfs.in/dev rootfs.out/dev + + # compare file content + diff -rq --no-dereference rootfs.in rootfs.out + + # check permissions, ownership, symlink targets, modification times + tar -C rootfs.in --numeric-owner --sort=name -cf root1.tar . + tar -C rootfs.out --numeric-owner --sort=name -cf root2.tar . + tar --full-time --verbose -tf root1.tar > root1.tar.list + tar --full-time --verbose -tf root2.tar > root2.tar.list + diff -u root1.tar.list root2.tar.list + rm root1.tar root2.tar root1.tar.list root2.tar.list + + rm -rf rootfs.in rootfs.out +done + +rm rootfs.dir.img rootfs.tar.img rootfs.in.tar diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..ad21fd6 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,4 @@ +Bug-Database: https://github.com/bestouff/genext2fs/issues +Bug-Submit: https://github.com/bestouff/genext2fs/issues/new +Repository: https://github.com/bestouff/genext2fs.git +Repository-Browse: https://github.com/bestouff/genext2fs diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..7fb67d7 --- /dev/null +++ b/debian/watch @@ -0,0 +1,4 @@ +version=4 +opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%genext2fs-$1.tar.gz%" \ + https://github.com/bestouff/genext2fs/tags \ + (?:.*?/)?v?(\d[\d.]*)\.tar\.gz diff --git a/genext2fs.c b/genext2fs.c index 96bbb43..a1e5233 100644 --- a/genext2fs.c +++ b/genext2fs.c @@ -2629,6 +2629,8 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp size_t len; struct stat st; int nbargs, lineno = 0; + nod_info *ni; + inode *pnode; fstat(fileno(fh), &st); ctime = fs_timestamp; @@ -2684,6 +2686,14 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp { error_msg("device table line %d skipped: can't find directory '%s' to create '%s''", lineno, dir, name); continue; + } else { + pnode = get_nod(fs, nod, &ni); + if((pnode->i_mode & FM_IFMT) != FM_IFDIR) { + error_msg("device table line %d skipped: parent '%s' is not a directory so won't create '%s''", lineno, dir, name); + put_nod(ni); + continue; + } + put_nod(ni); } } else