summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-08-03 00:25:24 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-08-04 12:59:20 -0400
commit646ac0258c3295943778142468aadfe5b04ad6d1 (patch)
treec4e0695cae1c0e24dd3ea542d2ad7f63ad48a218
parent044b4e16b9bdd2b3c6622af6216888ddf0a16644 (diff)
libremakepkg,chcleanup: Be stricter about network accessv20180804
Objectives: - Once the source package has been created, never run makepkg with networking enabled again, so that we can be 100% sure that the source package has all of the sources that we need. - Don't let makepkg edit the PKGBUILD (eg. by evaluating pkgver()) User-facing changes: - libremakepkg now disables networking during prepare() - libremakepkg no longer runs pkgver() - chcleanup (and thus `librechroot clean-pkgs`) now also installs packages Technical description of changes: - In devtools (and not really in this commit): * No longer split /chrootprepare off of /chrootbuild. The point of splitting it was that we'd have prepare() run from /chrootprepare and the rest later run from /chrootbuild, so that we could leave networking enabled during prepare() but not the rest. Now that we're disabling networking during prepare(), that's pointless. * Have download_sources create a source package (rather than having /chrootbuild create the source package at the same time that we create the binary package). We adjust the caller to temporarily set SRCPKGDEST to a temporary directory, so that we can get the file and control the filename when we move it in to the real SRCPKGDEST. - Have chcleanup install the dependencies. If we used the traditional `makepkg --sync` to install the dependencies, then we'd be breaking the "no networking for makepkg after source package creation" objective. chcleanup already has all of the logic necessary to accomplish this. If there's a discrepancy in chcleanup behavior and makepkg behavior, and makepkg thinks it needs to install something, then that just means we'll have to fix the bug in chcleanup, instead of letting it go for more than a year (*cough* https://labs.parabola.nu/issues/1311 *cough*). - Use files extracted from the source package (rather than files found in the current directory) to build the package. - We mount the temporary directory containing the extracted source package files read-only, to be sure that makepkg doesn't modify the PKGBUILD. This is necessary because --holdver only disables pkgver() if it's a VCS package.
-rw-r--r--po/es/librelib.po2
-rw-r--r--po/es/libretools.po181
-rw-r--r--src/chroot-tools/chcleanup.in15
-rwxr-xr-xsrc/chroot-tools/librechroot3
-rwxr-xr-xsrc/chroot-tools/libremakepkg60
5 files changed, 163 insertions, 98 deletions
diff --git a/po/es/librelib.po b/po/es/librelib.po
index 5c937a4..168d432 100644
--- a/po/es/librelib.po
+++ b/po/es/librelib.po
@@ -144,7 +144,7 @@ msgstr "hecho"
msgid "Aborting..."
msgstr "Abortando..."
-#: src/lib/common.sh:222 src/lib/common.sh:279
+#: src/lib/common.sh:222 src/lib/common.sh:282
msgid "Multiple packages found:"
msgstr "Múltiples paquetes encontrados:"
diff --git a/po/es/libretools.po b/po/es/libretools.po
index 50a9aa3..728c674 100644
--- a/po/es/libretools.po
+++ b/po/es/libretools.po
@@ -149,7 +149,7 @@ msgstr "En el modo de comparación (si se da el indicador `-n`), de forma "
"imprimirá la línea `[REPO]`."
#: src/abslibre-tools/libredbdiff:157 src/abslibre-tools/librerelease:128
-#: src/chroot-tools/librechroot:253 src/chroot-tools/libremakepkg:162
+#: src/chroot-tools/librechroot:253 src/chroot-tools/libremakepkg:170
#: src/devtools/find-libdeps:36 src/librefetch/librefetch:80
#: src/pkgbuild-check-nonfree:51 src/pkgbuild-summarize-nonfree:39
#: src/toru/toru-path:46
@@ -161,7 +161,7 @@ msgid "Don't update anything, just compare already downloaded files."
msgstr "No actualice nada, simplemente compare archivos ya descargados."
#: src/abslibre-tools/libredbdiff:159 src/abslibre-tools/librerelease:134
-#: src/chroot-tools/librechroot:282 src/chroot-tools/libremakepkg:174
+#: src/chroot-tools/librechroot:283 src/chroot-tools/libremakepkg:182
#: src/devtools/find-libdeps:39 src/librefetch/librefetch:92
#: src/pkgbuild-check-nonfree:58 src/pkgbuild-summarize-nonfree:41
#: src/toru/toru-path:51
@@ -520,14 +520,22 @@ msgstr "Creando una lista completa de paquetes..."
msgid "Could not create a full list of packages, exiting."
msgstr "No se pudo crear una lista completa de paquetes, saliendo."
-#: src/chroot-tools/chcleanup:118
+#: src/chroot-tools/chcleanup:117
msgid "No packages to remove"
msgstr "No hay paquetes para remover"
-#: src/chroot-tools/chcleanup:120
+#: src/chroot-tools/chcleanup:119
msgid "Removing %d packages"
msgstr "Removiendo %d paquetes"
+#: src/chroot-tools/chcleanup:132
+msgid "No packages to add"
+msgstr ""
+
+#: src/chroot-tools/chcleanup:134
+msgid "Adding %d packages"
+msgstr ""
+
#: src/chroot-tools/distcc-tool:38
msgid "panic: malformed call to internal function"
msgstr "pánico: llamada malformada a la función interna"
@@ -731,15 +739,15 @@ msgstr "Crear una copia, eliminar una copia o sincronizar una copia puede "
"ser bastante lento; pero son muy rápidos si $CHROOTDIR está en una "
"partición btrfs."
-#: src/chroot-tools/librechroot:254 src/chroot-tools/libremakepkg:164
+#: src/chroot-tools/librechroot:254 src/chroot-tools/libremakepkg:172
msgid "CHROOT"
msgstr "CHROOT"
-#: src/chroot-tools/librechroot:254 src/chroot-tools/libremakepkg:164
+#: src/chroot-tools/librechroot:254 src/chroot-tools/libremakepkg:172
msgid "Name of the chroot to use"
msgstr "Nombre del chroot a usar"
-#: src/chroot-tools/librechroot:255 src/chroot-tools/libremakepkg:165
+#: src/chroot-tools/librechroot:255 src/chroot-tools/libremakepkg:173
msgid "COPY"
msgstr "COPIA"
@@ -774,16 +782,16 @@ msgid "Set the architecture of the copy; simply an alias for the `-C` and `-"
msgstr "Establecer la arquitectura de la copia; simplemente un alias para "
"las opciones `-C` y` -M`, vea arriba."
-#: src/chroot-tools/librechroot:261 src/chroot-tools/libremakepkg:166
+#: src/chroot-tools/librechroot:261 src/chroot-tools/libremakepkg:174
msgid "Bind mount a file or directory, read/write"
msgstr "Enlazar un archivo o directorio, lectura/escritura"
#: src/chroot-tools/librechroot:261 src/chroot-tools/librechroot:262
-#: src/chroot-tools/libremakepkg:166 src/chroot-tools/libremakepkg:167
+#: src/chroot-tools/libremakepkg:174 src/chroot-tools/libremakepkg:175
msgid "PATH[:PATH]"
msgstr "RUTA[:RUTA]"
-#: src/chroot-tools/librechroot:262 src/chroot-tools/libremakepkg:167
+#: src/chroot-tools/librechroot:262 src/chroot-tools/libremakepkg:175
msgid "Bind mount a file or directory, read-only"
msgstr "Enlazar-montar un archivo o directorio, de solo lectura"
@@ -829,92 +837,97 @@ msgid "Like `pacman -Syu`"
msgstr "Como `pacman -Syu`"
#: src/chroot-tools/librechroot:274
-msgid "Remove all packages from the chroot copy that are not in base-devel, "
- "$CHROOTEXTRAPKG, or named as a dependency in the file `/startdir/"
- "PKGBUILD` in the chroot copy"
-msgstr "Eliminar todos los paquetes de la copia chroot que no están en base-"
- "devel, $CHROOTEXTRAPKG, o nombrado como una dependencia en el "
- "archivo`/startdir/PKGBUILD` en la copia chroot"
-
-#: src/chroot-tools/librechroot:278
+#, fuzzy
+#| msgid "Remove all packages from the chroot copy that are not in "
+#| "base-devel, $CHROOTEXTRAPKG, or named as a dependency in the file `/"
+#| "startdir/PKGBUILD` in the chroot copy"
+msgid "Remove all packages from the chroot copy that are not in "
+ "base-devel, $CHROOTEXTRAPKG, or named as a dependency in the file `/"
+ "startdir/PKGBUILD` in the chroot copy; and install all packages that "
+ "are."
+msgstr "Eliminar todos los paquetes de la copia chroot que no están "
+ "en base-devel, $CHROOTEXTRAPKG, o nombrado como una dependencia en "
+ "el archivo`/startdir/PKGBUILD` en la copia chroot"
+
+#: src/chroot-tools/librechroot:279
msgid " Other:"
msgstr " Otro:"
-#: src/chroot-tools/librechroot:279
+#: src/chroot-tools/librechroot:280
msgid "CMD..."
msgstr "CMD..."
-#: src/chroot-tools/librechroot:279
+#: src/chroot-tools/librechroot:280
msgid "Run CMD in the chroot copy"
msgstr "Ejecuta CMD en la copia de chroot"
-#: src/chroot-tools/librechroot:280
+#: src/chroot-tools/librechroot:281
msgid "Enter an interactive shell in the chroot copy"
msgstr "Entrar a un shell interactivo en la copia de chroot"
-#: src/chroot-tools/librechroot:281
+#: src/chroot-tools/librechroot:282
msgid "Clean /repo in the chroot copy"
msgstr "Limpiar /repo en la copia del chroot"
-#: src/chroot-tools/librechroot:307
+#: src/chroot-tools/librechroot:308
msgid "Unsupported architecture: %s"
msgstr "Arquitectura no admitida: %s"
-#: src/chroot-tools/librechroot:325
+#: src/chroot-tools/librechroot:326
msgid "Must specify a command"
msgstr "Debe especificar un comando"
-#: src/chroot-tools/librechroot:331
+#: src/chroot-tools/librechroot:332
msgid "Unrecognized command: %s"
msgstr "Comando no reconocido: %s"
-#: src/chroot-tools/librechroot:339
+#: src/chroot-tools/librechroot:340
msgid "Command `%s` does not take any arguments: %s"
msgstr "El comando `%s` no toma ningún argumento: %s"
-#: src/chroot-tools/librechroot:346
+#: src/chroot-tools/librechroot:347
msgid "Command `%s` requires at least one file"
msgstr "El comando `%s` requiere al menos un archivo"
-#: src/chroot-tools/librechroot:358
+#: src/chroot-tools/librechroot:359
msgid "%s: file(s) not found: %s"
msgstr "%s: archivo(s) no encontrado(s): %s"
-#: src/chroot-tools/librechroot:365
+#: src/chroot-tools/librechroot:366
msgid "Command `%s` requires at least one package name"
msgstr "El comando `%s` requiere al menos un nombre de un paquete"
-#: src/chroot-tools/librechroot:372
+#: src/chroot-tools/librechroot:373
msgid "Command `%s` requires at least one argument"
msgstr "El comando `%s` requiere al menos un argumento"
-#: src/chroot-tools/librechroot:395
+#: src/chroot-tools/librechroot:396
msgid "This program must be run as root."
msgstr "Este programa debe ser ejecutado como root."
-#: src/chroot-tools/librechroot:403
+#: src/chroot-tools/librechroot:404
msgid "Input is not a TTY"
msgstr "La entrada no es un TTY"
-#: src/chroot-tools/librechroot:406
+#: src/chroot-tools/librechroot:407
msgid "Due to a bug in systemd-nspawn, redirecting stdin is not supported."
msgstr "Debido a un error en systemd-nspawn, el redireccionamiento de stdin "
"no está soportado."
-#: src/chroot-tools/librechroot:414 src/chroot-tools/libremakepkg:268
+#: src/chroot-tools/librechroot:415 src/chroot-tools/libremakepkg:274
msgid "Waiting for existing lock on chroot copy to be released: [%s]"
msgstr "Esperando que el bloqueo existente en la copia de chroot sea "
"liberado: [%s]"
-#: src/chroot-tools/librechroot:418
+#: src/chroot-tools/librechroot:419
msgid "Chroot copy is mounted with nosuid or noexec options: [%s]"
msgstr "La copia del chroot se monta con opciones nosuid o noexec: [%s]"
-#: src/chroot-tools/librechroot:423
+#: src/chroot-tools/librechroot:424
msgid "Creating 'root' copy for chroot [%s]"
msgstr "Creando copia 'root' para el chroot [%s]"
-#: src/chroot-tools/librechroot:429
+#: src/chroot-tools/librechroot:430
msgid "Syncing copy [%s] with root copy"
msgstr "Sincronizando copia [%s] con la copia root"
@@ -926,58 +939,58 @@ msgstr "Copiando archivos de registro y del paquete fuera del chroot..."
msgid "Failure(s) in %s: %s"
msgstr "Falla(s) en %s: %s"
-#: src/chroot-tools/libremakepkg:137
+#: src/chroot-tools/libremakepkg:145
msgid "Usage: %s [options]"
msgstr "Uso: %s [opciones]"
-#: src/chroot-tools/libremakepkg:138
+#: src/chroot-tools/libremakepkg:146
msgid "This program will build your package."
msgstr "Este programa compilará su paquete."
-#: src/chroot-tools/libremakepkg:140
+#: src/chroot-tools/libremakepkg:148
msgid "If run from outside of a chroot, this command will make the "
"following configuration changes in the chroot:"
msgstr "Si se ejecuta desde fuera de un chroot, este comando hará los "
"siguientes cambios de configuración en el chroot:"
-#: src/chroot-tools/libremakepkg:142
+#: src/chroot-tools/libremakepkg:150
msgid "whatever changes `librechroot` makes."
msgstr "cualquier cambio que `librechroot` haga."
-#: src/chroot-tools/libremakepkg:143
+#: src/chroot-tools/libremakepkg:151
msgid "set `{PKG,SRC,SRCPKG,LOG}DEST` in `/etc/makepkg.conf`"
msgstr "establece `{PKG,SRC,SRCPKG,LOG}DEST` en `/etc/makepkg.conf`"
-#: src/chroot-tools/libremakepkg:144
+#: src/chroot-tools/libremakepkg:152
msgid "set `MAKEFLAGS` and `PACKAGER` in `/etc/makepkg.conf` to reflect the "
"value outside of the chroot."
msgstr "establece `MAKEFLAGS` y `PACKAGER` en `/etc/makepkg.conf` para "
"reflejar el valor fuera del chroot."
-#: src/chroot-tools/libremakepkg:146
+#: src/chroot-tools/libremakepkg:154
msgid "create a `builduser` with the same numeric UID as the invoking "
"$SUDO_USER."
msgstr "crear un `builduser` con el mismo UID numérico que el invocado "
"$SUDO_USER."
-#: src/chroot-tools/libremakepkg:148
+#: src/chroot-tools/libremakepkg:156
msgid "let this `builduser` call `sudo pacman` without a password."
msgstr "dejar que este `builduser` llame a `sudo pacman` sin una contraseña."
-#: src/chroot-tools/libremakepkg:149
+#: src/chroot-tools/libremakepkg:157
msgid "set `keyserver-options` in `~builduser/.gnupg/gpg.conf`"
msgstr "establecer `keyserver-options` en `~builduser/.gnupg/gpg.conf`"
-#: src/chroot-tools/libremakepkg:150
+#: src/chroot-tools/libremakepkg:158
msgid "copy the user's GnuPG pubring to be the `builduser`'s pubring"
msgstr "copiar el pubring de GnuPG del usuario para que sea el pubring de "
"`builduser`"
-#: src/chroot-tools/libremakepkg:151
+#: src/chroot-tools/libremakepkg:159
msgid "add a pacman repositoriy of locally built packages"
msgstr "agrega un repositorio pacman de los paquetes compilados localmente"
-#: src/chroot-tools/libremakepkg:153
+#: src/chroot-tools/libremakepkg:161
msgid "This command is configured both with `chroot.conf` (either in `/etc/"
"libretools.d/` or `$XDG_CONFIG_HOME/libretools/`), and with makepkg."
"conf(5). However, similarly to makepkg(8), it lets environment "
@@ -989,70 +1002,78 @@ msgstr "Este comando está configurado con `chroot.conf` (ya sea en `/etc/"
"variables de entorno para {SRC,SRCPKG,PKG,LOG}DEST, MAKEFLAGS y "
"PACKAGER sobreescriban la configuración en makepkg.conf(5)."
-#: src/chroot-tools/libremakepkg:159
+#: src/chroot-tools/libremakepkg:167
msgid "The `-n` and `-l` options behave identically to librechroot, see the "
"documentation there."
msgstr "Las opciones `-n` y `-l` se comportan idénticamente a librechroot, "
"vea la documentación allí."
-#: src/chroot-tools/libremakepkg:163 src/chroot-tools/libremakepkg:168
+#: src/chroot-tools/libremakepkg:171 src/chroot-tools/libremakepkg:176
msgid " %s options:"
msgstr "Opciones de %s:"
-#: src/chroot-tools/libremakepkg:165
+#: src/chroot-tools/libremakepkg:173
msgid "Name of, or absolute path to, the chroot copy to use"
msgstr "Nombre del, o ruta absoluta, de la copia del chroot a usar"
-#: src/chroot-tools/libremakepkg:169
-msgid "Don't disable networking during build() and package(). PLEASE don't "
- "use this unless you have a special reason, its use is a violation of "
- "Parabola policy."
-msgstr "No deshabilita la conexión a internet durante build() y package(). "
- "POR FAVOR no use esta opción al menos que tenga una razón en "
- "especial, su uso es una violación a la política de Parabola."
-
-#: src/chroot-tools/libremakepkg:173
+#: src/chroot-tools/libremakepkg:177
+#, fuzzy
+#| msgid "Don't disable networking during build() and package(). "
+#| "PLEASE don't use this unless you have a special reason, its use is a "
+#| "violation of Parabola policy."
+msgid "Don't disable networking during prepare(), build(), and "
+ "package(). PLEASE don't use this unless you have a special reason, "
+ "its use is a violation of Parabola policy."
+msgstr "No deshabilita la conexión a internet durante build() y "
+ "package(). POR FAVOR no use esta opción al menos que tenga una razón "
+ "en especial, su uso es una violación a la política de Parabola."
+
+#: src/chroot-tools/libremakepkg:181
msgid "Repackage contents of the package without rebuilding"
msgstr "Reempaqueta los contenidos del paquete sin recompilar"
-#: src/chroot-tools/libremakepkg:180
+#: src/chroot-tools/libremakepkg:188
msgid "The -%s flag does not make sense inside of a chroot"
msgstr "La opción -%s no tiene sentido dentro de un chroot"
-#: src/chroot-tools/libremakepkg:208
+#: src/chroot-tools/libremakepkg:216
msgid "Extra arguments: %s"
msgstr "Argumentos extras: %s"
-#: src/chroot-tools/libremakepkg:240
+#: src/chroot-tools/libremakepkg:248
msgid "This program must be run as root"
msgstr "Este programa debe ejecutarse como root"
-#: src/chroot-tools/libremakepkg:246
+#: src/chroot-tools/libremakepkg:254
msgid "PKGBUILD does not exist."
msgstr "El PKGBUILD no existe."
-#: src/chroot-tools/libremakepkg:257
+#: src/chroot-tools/libremakepkg:265
msgid "Waiting for existing lock on build directory to be released"
msgstr "Esperando a que se libere el bloqueo existente en el directorio de "
"compilación"
-#: src/chroot-tools/libremakepkg:270
+#: src/chroot-tools/libremakepkg:276
msgid "Initializing the chroot..."
msgstr "Iniciando el chroot..."
-#: src/chroot-tools/libremakepkg:280
+#: src/chroot-tools/libremakepkg:286
msgid "Starting pre-build activities..."
msgstr "Iniciando actividades previas a la compilación..."
-#: src/chroot-tools/libremakepkg:282
+#: src/chroot-tools/libremakepkg:289
msgid "Downloading sources..."
msgstr "Descargando las fuentes..."
-#: src/chroot-tools/libremakepkg:286
+#: src/chroot-tools/libremakepkg:297
+msgid "Something went funny with makepkg --allsource"
+msgstr ""
+
+#: src/chroot-tools/libremakepkg:316
msgid "Starting to build the package..."
msgstr "Comenzando a compilar el paquete..."
-#: src/chroot-tools/libremakepkg:291
+#: src/chroot-tools/libremakepkg:321
msgid "Starting post-build activities..."
msgstr "Iniciando actividades posteriores a la compilación..."
@@ -1084,41 +1105,41 @@ msgstr "No se puede crear el subvolumen %s"
msgid "Removing chroot copy [%s]"
msgstr "Eliminando copia del chroot [%s]"
-#: src/chroot-tools/makechrootpkg.sh:302
+#: src/chroot-tools/makechrootpkg.sh:276
msgid "Could not download sources."
msgstr "No se pudo descargar las fuentes."
-#: src/chroot-tools/makechrootpkg.sh:385
+#: src/chroot-tools/makechrootpkg.sh:359
msgid "This must be run in a directory containing a PKGBUILD."
msgstr "Esto debe ser ejecutado en un directorio con un PKGBUILD."
-#: src/chroot-tools/makechrootpkg.sh:386
+#: src/chroot-tools/makechrootpkg.sh:360
msgid "Invalid makepkg user."
msgstr "Usuario makepkg inválido."
-#: src/chroot-tools/makechrootpkg.sh:393
+#: src/chroot-tools/makechrootpkg.sh:367
msgid "No chroot dir defined, or invalid path '%s'"
msgstr "Directorio del chroot no definido, o ruta inválida '%s'"
-#: src/chroot-tools/makechrootpkg.sh:394
+#: src/chroot-tools/makechrootpkg.sh:368
msgid "Missing chroot dir root directory. Try using: mkarchroot %s/root "
"base-devel"
msgstr "Directorio del choot de root no encontrado. Intente usando: "
"mkarchroot %s/root base-devel"
-#: src/chroot-tools/makechrootpkg.sh:433
+#: src/chroot-tools/makechrootpkg.sh:407
msgid "Locking chroot copy [%s]"
msgstr "Bloqueando copia del chroot [%s]"
-#: src/chroot-tools/makechrootpkg.sh:451
+#: src/chroot-tools/makechrootpkg.sh:425
msgid "Running makepkg as root is not allowed."
msgstr "Ejecutar makepkg como root no está permitido."
-#: src/chroot-tools/makechrootpkg.sh:479
+#: src/chroot-tools/makechrootpkg.sh:448
msgid "Build failed"
msgstr "Compilación fallida"
-#: src/chroot-tools/makechrootpkg.sh:481
+#: src/chroot-tools/makechrootpkg.sh:450
msgid "Build failed, check %s/build"
msgstr "Compilación fallida, revise %s/build"
diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in
index 7826753..317bf10 100644
--- a/src/chroot-tools/chcleanup.in
+++ b/src/chroot-tools/chcleanup.in
@@ -88,7 +88,6 @@ pacman -b "${TEMPDIR}" \
# Diff installed packages against a clean chroot then remove leftovers
packages=($(comm -23 <(pacman -Qq | sort -u) \
<(sort -u "${pkglist}")))
-
if [[ ${#packages[@]} = 0 ]]; then
msg2 "No packages to remove"
else
@@ -101,3 +100,17 @@ else
pacman --noconfirm -R --nosave "${packages[@]}"
fi
fi
+
+packages=($(comm -13 <(pacman -Qq | sort -u) \
+ <(sort -u "${pkglist}")))
+if [[ ${#packages[@]} = 0 ]]; then
+ msg2 "No packages to add"
+else
+ msg2 "Adding %d packages" ${#packages[@]}
+
+ if ${DRYRUN}; then
+ echo "${packages[*]}"
+ else
+ pacman --noconfirm -S "${packages[@]}"
+ fi
+fi
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 6db11a8..923b818 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -274,7 +274,8 @@ usage() {
flag 'clean-pkgs' 'Remove all packages from the chroot copy that
are not in base-devel, $CHROOTEXTRAPKG, or named
as a dependency in the file `/startdir/PKGBUILD`
- in the chroot copy'
+ in the chroot copy; and install all packages
+ that are.'
print ' Other:'
flag "run $(_ CMD...)" 'Run CMD in the chroot copy'
flag 'enter' 'Enter an interactive shell in the chroot copy'
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index f5f4855..c6faf31 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -110,24 +110,32 @@ chroot_cleanup() {
build() (
local copydir=$1
- local repack=$2
- local makepkg_args=("${@:3}")
+ local srcpkg=$2
+ local repack=$3
+ local makepkg_args=("${@:4}")
+
+ local startdir
+ startdir=$(mktemp -d)
+ chown "$LIBREUSER:" "$startdir"
+ trap "rm -rf -- ${startdir@Q}" EXIT
+ sudo -u "$LIBREUSER" bsdtar -xf "$srcpkg" -C "$startdir" --strip-components 1
local run_ynet=()
local run_nnet=()
if $INCHROOT; then
- run_ynet=(unshare)
- run_nnet=(unshare --net)
+ local _run=(sh -c "mount --bind -o ro -- ${startdir@Q} ${startdir@Q} && cd ${startdir@Q} && \$@" --)
+ run_ynet=(unshare --mount -- "${_run[@]}")
+ run_nnet=(unshare --mount --net -- "${_run[@]}")
else
+ librechroot_flags+=(-r "$startdir:/startdir")
run_ynet=(librechroot "${librechroot_flags[@]}" run)
run_nnet=(librechroot "${librechroot_flags[@]}" -N run)
fi
$NONET || run_nnet=("${run_ynet[@]}")
prepare_chroot "$copydir" "$LIBREHOME" "$repack" false
- "${run_ynet[@]}" /chrootprepare "${makepkg_args[@]}" |& indent
run_hook pre_build "$copydir"
- trap "run_hook post_build ${copydir@Q}" EXIT
+ trap "run_hook post_build ${copydir@Q}; rm -rf -- ${startdir@Q}" EXIT
"${run_nnet[@]}" /chrootbuild "${makepkg_args[@]}" |& indent
)
@@ -166,10 +174,10 @@ usage() {
flag "-w <$(_ 'PATH[:PATH]')>" 'Bind mount a file or directory, read/write'
flag "-r <$(_ 'PATH[:PATH]')>" 'Bind mount a file or directory, read-only'
print ' %s options:' libremakepkg
- flag '-N' "Don't disable networking during build() and
- package(). PLEASE don't use this unless you
- have a special reason, its use is a violation
- of Parabola policy."
+ flag '-N' "Don't disable networking during prepare(),
+ build(), and package(). PLEASE don't use this
+ unless you have a special reason, its use is a
+ violation of Parabola policy."
flag '-R' 'Repackage contents of the package without rebuilding'
flag '-h' 'Show this message'
}
@@ -248,7 +256,7 @@ main() {
fi
# Make sure that the various *DEST directories exist
- mkdir -p -- "$PKGDEST" "$SRCDEST" "$SRCPKGDEST" "$LOGDEST"
+ sudo -u "$LIBREUSER" mkdir -p -- "$PKGDEST" "$SRCDEST" "$SRCPKGDEST" "$LOGDEST"
# OK, we are starting now ##############################################
@@ -257,8 +265,6 @@ main() {
"Waiting for existing lock on build directory to be released"
else
librechroot_flags+=(
- -w "$PWD:/startdir"
- -w "$SRCDEST:/srcdest"
-n "$CHROOT"
-l "$copy"
)
@@ -279,13 +285,37 @@ main() {
# Pre-build
msg 'Starting pre-build activities...'
run_hook check_pkgbuild
+
msg 'Downloading sources...'
- download_sources "$copydir" "$LIBREUSER" |& indent
+ local srcpkgdest srcpkg
+ srcpkgdest="$(mktemp -d)"
+ chown "$LIBREUSER:" "$srcpkgdest"
+ trap "rm -rf -- ${srcpkgdest@Q}" EXIT
+ SRCPKGDEST="$srcpkgdest" download_sources "$copydir" "$LIBREUSER" |& indent
+ srcpkg=("$srcpkgdest"/*)
+ if (( ${#srcpkg[@]} != 1 )); then
+ error 'Something went funny with makepkg --allsource'
+ return $EXIT_FAILURE
+ fi
+ # We want to inject "-$pkgarch" in to srcpkg's filename, right before $SRCEXT
+ local srcext pkgarch srcpkg_filename
+ srcext="$(MAKEPKG_CONF=$copydir/etc/makepkg.conf get_var makepkg SRCEXT)"
+ if [[ "$(bsdtar xfO "$srcpkg" --include='*/.SRCINFO' | grep $'\tarch =')" = $'\tarch = any' ]]; then
+ pkgarch=any
+ else
+ pkgarch=$CARCH
+ fi
+ srcpkg_filename=${srcpkg##*/}
+ srcpkg_filename=${srcpkg_filename%"${srcext}"}-${pkgarch}${srcext}
+ mv -T -- "$srcpkg" "$SRCPKGDEST/${srcpkg_filename}"
+ srcpkg="$SRCPKGDEST/${srcpkg_filename}"
+ rmdir -- "${srcpkgdest}"
+ trap EXIT
# Build
msg 'Starting to build the package...'
trap "exit_copy '$copydir' '$LIBREUSER'" EXIT
- build "$copydir" "$repack" "${makepkg_args[@]}"
+ build "$copydir" "$srcpkg" "$repack" "${makepkg_args[@]}"
# Post-build
msg 'Starting post-build activities...'