-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
actions: Support for local packages installation #165
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ Yaml syntax: | |
- action: apt | ||
recommends: bool | ||
unauthenticated: bool | ||
local-packages-dir: directory | ||
packages: | ||
- package1 | ||
- package2 | ||
|
@@ -20,10 +21,18 @@ Optional properties: | |
- recommends -- boolean indicating if suggested packages will be installed | ||
|
||
- unauthenticated -- boolean indicating if unauthenticated packages can be installed | ||
- local-packages-dir -- directory containing local packages to be installed, | ||
located in the recipe directory ($RECIPEDIR) | ||
*/ | ||
package actions | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
"strings" | ||
|
||
"github.com/go-debos/debos" | ||
) | ||
|
||
|
@@ -32,6 +41,7 @@ type AptAction struct { | |
Recommends bool | ||
Unauthenticated bool | ||
Packages []string | ||
LocalPackagesDir string `yaml:"local-packages-dir"` // external path containing local packages | ||
} | ||
|
||
func (apt *AptAction) Run(context *debos.DebosContext) error { | ||
|
@@ -49,6 +59,51 @@ func (apt *AptAction) Run(context *debos.DebosContext) error { | |
aptOptions = append(aptOptions, "install") | ||
aptOptions = append(aptOptions, apt.Packages...) | ||
|
||
if apt.LocalPackagesDir != "" { | ||
localpackagesdir := path.Join(context.RecipeDir, apt.LocalPackagesDir) | ||
destination, err := ioutil.TempDir(path.Join(context.Rootdir, "usr/local"), "debs") | ||
if err != nil { | ||
return err | ||
} | ||
defer os.RemoveAll(destination) | ||
|
||
err = debos.CopyTree(localpackagesdir, destination) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
currentDir, _ := os.Getwd() | ||
os.Chdir(destination) | ||
|
||
// apt-ftparchive tries to read /etc/apt/apt.conf.d, add this path temporarily to prevent warnings | ||
os.MkdirAll("/etc/apt/apt.conf.d", 0755) | ||
defer os.RemoveAll("/etc/apt/apt.conf.d/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is only a warning i wonder if this should be a separate patch since debootstrap action also moans about this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see this warning with As it is related to following |
||
|
||
err = debos.Command{}.Run("apt", "sh", "-c", "apt-ftparchive packages . > Packages") | ||
if err != nil { | ||
return err | ||
} | ||
err = debos.Command{}.Run("apt", "sh", "-c", "apt-ftparchive release . > Release") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
os.Chdir(currentDir) | ||
|
||
locallist, err := os.OpenFile(path.Join(context.Rootdir, "/etc/apt/sources.list.d/debos-local-debs.list"), | ||
os.O_RDWR | os.O_CREATE, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
defer os.RemoveAll(locallist.Name()) | ||
_, err = locallist.WriteString(fmt.Sprintf("deb [trusted=yes] file://%s ./\n", | ||
strings.TrimPrefix(destination, context.Rootdir))) | ||
if err != nil { | ||
return err | ||
} | ||
locallist.Close() | ||
} | ||
|
||
c := debos.NewChrootCommandForContext(*context) | ||
c.AddEnv("DEBIAN_FRONTEND=noninteractive") | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ LABEL org.label-schema.docker.cmd 'docker run \ | |
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
apt-transport-https \ | ||
apt-utils \ | ||
This comment was marked as resolved.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, you're right but this is not managed in this project |
||
binfmt-support \ | ||
bmap-tools \ | ||
btrfs-progs \ | ||
|
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defer statement runs at the end of the function.
So, the
destination
directory is only available during thisapt
action, and subsequentapt
actions will not have access to it.This comment was marked as resolved.
Sorry, something went wrong.